Skip to content

cgroup: apply HugeTLB reservation limits - #2387

Closed
sairex53 wants to merge 2 commits into
containers:mainfrom
sairex53:fix-hugetlb-rsvd-limit-2284
Closed

sairex53 wants to merge 2 commits into
containers:mainfrom
sairex53:fix-hugetlb-rsvd-limit-2284

Conversation

@sairex53

Copy link
Copy Markdown

Summary

On cgroup v2, crun applied OCI hugepageLimits only to hugetlb.<size>.max. When the kernel exposes reservation accounting, the corresponding hugetlb.<size>.rsvd.max stayed unlimited, so the configured limit did not constrain hugepage reservations.

Write the same limit to both files. If the reservation file is absent, keep the existing usage-accounting fallback for kernels that do not support reservation accounting; other write errors still fail. Add a runtime regression test for available 2 MB and 1 GB page sizes.

Fixes #2284.

Validation

  • ./autogen.sh && ./configure --disable-systemd && make -j2 — passed on Fedora 44 aarch64.
  • python3 -m py_compile tests/test_cgroup_resources.py — passed.
  • git diff --check — passed.
  • The runtime cgroup test could not run here: the host does not expose the hugetlb controller and the SSH user is unprivileged.

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>

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

Comment thread tests/test_cgroup_resources.py Outdated

page_sizes = [
page_size for page_size in ('2MB', '1GB')
if os.path.exists(f'/sys/fs/cgroup/hugetlb.{page_size}.rsvd.max')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Have you ever tried running this test, and what was the result?

See, this file does not exist on a root cgroup, so the test always skips. I mentioned it in #2290.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated the test to discover page sizes through hugetlb..max and check .rsvd.max from inside the container. It skips only when reservation accounting is unavailable in that container cgroup. Python compilation passed; I could not run the rootful cgroup v2 test on macOS.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I could not run the rootful cgroup v2 test on macOS.

See my comment below #2387 (comment)

@kolyshkin

Copy link
Copy Markdown
Collaborator

The runtime cgroup test could not run here: the host does not expose the hugetlb controller and the SSH user is unprivileged.

@sairex53 if you want to contribute to crun, I suggest you to actually use it and have a setup to run the tests you're authoring (perhaps in a VM).

fixup! cgroup: apply HugeTLB reservation limits

Read the reservation limit from inside the container cgroup and skip only when the controller is unavailable there.

Agent: Codex
@kolyshkin

kolyshkin commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Your test is now broken in more than one place and won't work. The situation we had with #2290 is repeating. I will fix the issue myself.

@sairex53 Please do not contribute something that you can't reasonably test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crun leaves supported HugeTLB reservation limits unlimited

3 participants