Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rsvd hugetlb cgroup #2719

Merged
merged 1 commit into from
Apr 7, 2024
Merged

Conversation

omprakaash
Copy link
Contributor

@omprakaash omprakaash commented Mar 4, 2024

Adds support for rsvg hugetlb cgroup. More Info on why this is necessary: opencontainers/runtime-spec#1116. Should fix #1707.

@omprakaash
Copy link
Contributor Author

I can also open up a PR in oci-spec-rs if necessary to update info about huge-tlb limits.

@utam0k
Copy link
Member

utam0k commented Mar 6, 2024

I can also open up a PR in oci-spec-rs if necessary to update info about huge-tlb limits.

Let's do it.

@omprakaash
Copy link
Contributor Author

Hey, sorry for the delay. Opened up a corresponding PR in oci-spec-rs repo as well.

@utam0k
Copy link
Member

utam0k commented Mar 13, 2024

@omprakaash May I ask you to add a e2e test?
https://containers.github.io/youki/developer/e2e/rust_oci_test.html

@omprakaash
Copy link
Contributor Author

Oh yes ! Will add one.

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Mar 18, 2024

Hey, do we need a oci-spec release and update its version in this PR ?

@utam0k
Copy link
Member

utam0k commented Apr 1, 2024

@omprakaash friendly remind ;)

@utam0k
Copy link
Member

utam0k commented Apr 1, 2024

Hey, do we need a oci-spec release and update its version in this PR ?

If needed, I can do it.

@omprakaash omprakaash force-pushed the rsvd-hugetlb branch 2 times, most recently from 274287d to 4e2a9cb Compare April 1, 2024 00:46
@codecov-commenter
Copy link

Codecov Report

Merging #2719 (4e2a9cb) into main (ed2c08d) will increase coverage by 0.25%.
Report is 27 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2719      +/-   ##
==========================================
+ Coverage   65.21%   65.47%   +0.25%     
==========================================
  Files         133      133              
  Lines       16981    17099     +118     
==========================================
+ Hits        11074    11195     +121     
+ Misses       5907     5904       -3     

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

crates/libcgroups/src/v1/hugetlb.rs Show resolved Hide resolved
Comment on lines 113 to 120
let _ = common::write_cgroup_file(
root_path.join(format!(
"hugetlb.{}.rsvd.limit_in_bytes",
hugetlb.page_size()
)),
hugetlb.limit(),
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take care of Result type.

Suggested change
let _ = common::write_cgroup_file(
root_path.join(format!(
"hugetlb.{}.rsvd.limit_in_bytes",
hugetlb.page_size()
)),
hugetlb.limit(),
);
common::write_cgroup_file(
root_path.join(format!(
"hugetlb.{}.rsvd.limit_in_bytes",
hugetlb.page_size()
)),
hugetlb.limit(),
)?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I ignored the result because the desired behavior was falling back to just writing to the non-rsvd file if the rsvd file was not present.


let usage_file = format!("hugetlb.{page_size}.usage_in_bytes");
let usage_content = common::read_cgroup_file(cgroup_path.join(usage_file))?;
let mut rsvd = ".rsvd";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
let mut rsvd = ".rsvd";
let mut file_prefix= format!("hugetlb.{page_size}.rsvd");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that is better, will change it.

Comment on lines 109 to 113
let _ = common::write_cgroup_file(
root_path.join(format!("hugetlb.{}.rsvd.max", hugetlb.page_size())),
hugetlb.limit(),
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let _ = common::write_cgroup_file(
root_path.join(format!("hugetlb.{}.rsvd.max", hugetlb.page_size())),
hugetlb.limit(),
);
common::write_cgroup_file(
root_path.join(format!("hugetlb.{}.rsvd.max", hugetlb.page_size())),
hugetlb.limit(),
)?;

let events_file = format!("hugetlb.{page_size}.events");
let path = cgroup_path.join(events_file);
let events = common::read_cgroup_file(&path)?;
let mut rsvd = ".rsvd";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment in cgroup v1.

@utam0k
Copy link
Member

utam0k commented Apr 2, 2024

@omprakaash It looks like the unit test failed. Please check it
https://github.com/containers/youki/actions/runs/8515994057/job/23342405969?pr=2719

@omprakaash
Copy link
Contributor Author

Oh that is because the functions fails if the write to the new rsvd file fails. If rsvd is not supported, I think we should fallback to just writing to the non-rsvd file (https://github.com/opencontainers/runtime-spec/pull/1116/files). I left a follow up comment in the code review - review

@utam0k
Copy link
Member

utam0k commented Apr 3, 2024

Oh that is because the functions fails if the write to the new rsvd file fails. If rsvd is not supported, I think we should fallback to just writing to the non-rsvd file (https://github.com/opencontainers/runtime-spec/pull/1116/files). I left a follow up comment in the code review - review

These unit tests use temporary dirs(/tmp). It means we don't use actual cgroup fs. You can put any file to simulate support rsvd in a temporary dir.

@omprakaash
Copy link
Contributor Author

Hey, sorry I might be misunderstanding, but that is what the newly added tests do (eg: test_set_rsvd_hugetlb() ). So this test is testing that the application of hugetlb stats does not error out if rsvd-hugetlb file is not present.

@utam0k
Copy link
Member

utam0k commented Apr 4, 2024

@omprakaash
Oh, I was wrong. I understood.

But there are possibilities of errors except for what you expect when writing the cgroup file, so we can't ignore this result.

Oh, I ignored the result because the desired behavior was falling back to just writing to the non-rsvd file if the rsvd file was not present.

How about checking if the rvsd is supported before writing rvsd's cgroup file?
https://github.com/omprakaash/youki/blob/f2bf35c0b4244bf4d1a73e56c85de3c7b3b11def/crates/libcgroups/src/v2/hugetlb.rs#L109-L112

@omprakaash
Copy link
Contributor Author

Gotcha, changed it so that we first check if the rsvd file exists before attempting to write into it.

Signed-off-by: omprakaash <[email protected]>
Signed-off-by: om <[email protected]>
Signed-off-by: Om Prakaash <[email protected]>
Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks, @omprakaash

@utam0k utam0k enabled auto-merge (squash) April 7, 2024 05:26
@utam0k utam0k merged commit e94e103 into youki-dev:main Apr 7, 2024
28 checks passed
@github-actions github-actions bot mentioned this pull request Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for rsvd hugetlb cgroup
4 participants