Skip to content

Add support for rsvd hugetlb cgroup#2719

Merged
utam0k merged 1 commit into
youki-dev:mainfrom
omprakaash:rsvd-hugetlb
Apr 7, 2024
Merged

Add support for rsvd hugetlb cgroup#2719
utam0k merged 1 commit into
youki-dev:mainfrom
omprakaash:rsvd-hugetlb

Conversation

@omprakaash

@omprakaash omprakaash commented Mar 4, 2024

Copy link
Copy Markdown
Contributor

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

@omprakaash

Copy link
Copy Markdown
Contributor Author

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

@utam0k

utam0k commented Mar 6, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

@utam0k

utam0k commented Mar 13, 2024

Copy link
Copy Markdown
Member

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

@omprakaash

Copy link
Copy Markdown
Contributor Author

Oh yes ! Will add one.

@YJDoc2

YJDoc2 commented Mar 18, 2024

Copy link
Copy Markdown
Collaborator

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

@utam0k

utam0k commented Apr 1, 2024

Copy link
Copy Markdown
Member

@omprakaash friendly remind ;)

@utam0k

utam0k commented Apr 1, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread crates/libcgroups/src/v1/hugetlb.rs
Comment thread crates/libcgroups/src/v1/hugetlb.rs Outdated
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
Copy Markdown
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
Copy Markdown
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.

Comment thread crates/libcgroups/src/v1/hugetlb.rs Outdated

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
Copy Markdown
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
Copy Markdown
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 thread crates/libcgroups/src/v2/hugetlb.rs Outdated
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
Copy Markdown
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(),
)?;

Comment thread crates/libcgroups/src/v2/hugetlb.rs Outdated
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
Copy Markdown
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

utam0k commented Apr 2, 2024

Copy link
Copy Markdown
Member

@omprakaash

Copy link
Copy Markdown
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

utam0k commented Apr 3, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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

utam0k commented Apr 4, 2024

Copy link
Copy Markdown
Member

@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
Copy Markdown
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 <omsuseela@gmail.com>
Signed-off-by: om <omsuseela@gmail.com>
Signed-off-by: Om Prakaash <omsuseela@gmail.com>

@utam0k utam0k left a comment

Copy link
Copy Markdown
Member

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
@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