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

[1.1] libct/cg: support hugetlb rsvd #4077

Merged
merged 2 commits into from Oct 24, 2023

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Oct 19, 2023

This is a backport of #4073 and #4086 to release-1.1 branch. Fixes #3859.


This adds support for hugetlb.<pagesize>.rsvd limiting and accounting.

The previous non-rsvd max/limit_in_bytes does not account for reserved huge page memory, making it possible for a processes to reserve all the huge page memory, without being able to allocate it (due to cgroup restrictions).

In practice this makes it possible to successfully mmap more huge page memory than allowed via the cgroup settings, but when using the memory the process will get a SIGBUS and crash. This is bad for applications trying to mmap at startup (and it succeeds), but the program crashes when starting to use the memory. eg. postgres is doing this by default.

This also keeps writing to the old max/limit_in_bytes, for backward compatibility.

More info can be found here: https://lkml.org/lkml/2020/2/3/1153

(commit message mostly written by Odin Ugedal)

@kolyshkin kolyshkin added this to the 1.1.10 milestone Oct 19, 2023
@kolyshkin
Copy link
Contributor Author

CI is broken, see #4078 and #4079

@kolyshkin
Copy link
Contributor Author

Need to merge #4081 first

@lifubang
Copy link
Member

😢 There is no CGROUP_V1 and CGROUP_V2 in release-1.1, it uses CGROUP_UNIFIED=no to check cgroup v1/v2.

Separate it out of get_cgroup_value. Needed for the next commit.

This function was initially introduced in main branch commit d4582ae.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This adds support for hugetlb.<pagesize>.rsvd limiting and accounting.

The previous non-rsvd max/limit_in_bytes does not account for reserved
huge page memory, making it possible for a processes to reserve all the
huge page memory, without being able to allocate it (due to cgroup
restrictions).

In practice this makes it possible to successfully mmap more huge page
memory than allowed via the cgroup settings, but when using the memory
the process will get a SIGBUS and crash. This is bad for applications
trying to mmap at startup (and it succeeds), but the program crashes
when starting to use the memory. eg. postgres is doing this by default.

This also keeps writing to the old max/limit_in_bytes, for backward
compatibility.

More info can be found here: https://lkml.org/lkml/2020/2/3/1153

(commit message mostly written by Odin Ugedal)

[1.1 backport: check for CGROUP_UNIFIED in integration test]

Co-authored-by: Odin Ugedal <odin@ugedal.com>
(cherry picked from commit 4a7d3ae)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin mentioned this pull request Oct 24, 2023
@AkihiroSuda AkihiroSuda merged commit e1adc7f into opencontainers:release-1.1 Oct 24, 2023
29 checks passed
@cyphar cyphar mentioned this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants