Add support for rsvd hugetlb cgroup#2719
Conversation
|
I can also open up a PR in oci-spec-rs if necessary to update info about huge-tlb limits. |
Let's do it. |
|
Hey, sorry for the delay. Opened up a corresponding PR in oci-spec-rs repo as well. |
|
@omprakaash May I ask you to add a e2e test? |
|
Oh yes ! Will add one. |
|
Hey, do we need a oci-spec release and update its version in this PR ? |
|
@omprakaash friendly remind ;) |
If needed, I can do it. |
274287d to
4e2a9cb
Compare
Codecov Report
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 |
| let _ = common::write_cgroup_file( | ||
| root_path.join(format!( | ||
| "hugetlb.{}.rsvd.limit_in_bytes", | ||
| hugetlb.page_size() | ||
| )), | ||
| hugetlb.limit(), | ||
| ); | ||
|
|
There was a problem hiding this comment.
Please take care of Result type.
| 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(), | |
| )?; | |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
How about this?
| let mut rsvd = ".rsvd"; | |
| let mut file_prefix= format!("hugetlb.{page_size}.rsvd"); |
There was a problem hiding this comment.
Oh that is better, will change it.
| let _ = common::write_cgroup_file( | ||
| root_path.join(format!("hugetlb.{}.rsvd.max", hugetlb.page_size())), | ||
| hugetlb.limit(), | ||
| ); | ||
|
|
There was a problem hiding this comment.
| 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"; |
|
@omprakaash It looks like the unit test failed. Please check it |
|
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( |
|
Hey, sorry I might be misunderstanding, but that is what the newly added tests do (eg: |
|
@omprakaash But there are possibilities of errors except for what you expect when writing the cgroup file, so we can't ignore this result.
How about checking if the rvsd is supported before writing rvsd's cgroup file? |
|
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>
Adds support for rsvg hugetlb cgroup. More Info on why this is necessary: opencontainers/runtime-spec#1116. Should fix #1707.