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

Kernel memory limit is unsupported on Linux kenrel >= 5.16 #81

Closed
dubek opened this issue Jun 7, 2022 · 4 comments · Fixed by #82
Closed

Kernel memory limit is unsupported on Linux kenrel >= 5.16 #81

dubek opened this issue Jun 7, 2022 · 4 comments · Fixed by #82
Labels
bug Something isn't working needs-review

Comments

@dubek
Copy link

dubek commented Jun 7, 2022

Describe the bug

As described first in kata-containers/kata-containers#4390 , Linux 5.16 merged a change which causes writes to cgroup's memory.kmem.limit_in_bytes to return -ENOTSUPP and do nothing.

This means that the unit tests fail with Linux 5.16 and cgroup v1.

To reproduce this, I installed an Ubuntu 22.04 VM (default kernel 5.15). I added systemd.unified_cgroup_hierarchy=0 to the kernel command-line. On 5.15 make test passes OK.

I then installed kernel 5.16.20 from Ubuntu (link). When I run the tests:

     Running tests/builder.rs (target/debug/deps/builder-4ff582e8201f8686)

running 7 tests
test test_blkio_res_build ... ignored
test test_devices_res_build ... ignored
thread 'test_memory_res_build' panicked at 'assertion failed: `(left == right)`
  left: `9223372036854771712`,
 right: `134217728`', tests/builder.rs:50:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test test_memory_res_build ... FAILED
test test_network_res_build ... ok
test test_cpu_res_build ... ok
test test_hugepages_res_build ... ok
test test_pid_res_build ... ok

failures:

failures:
    test_memory_res_build

test result: FAILED. 4 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.07s

Expected behavior
Unit tests pass.

It's a design question of whether to "swallow" the unsupported error from the OS and just do nothing, or keep the error (and fix the callers, such as kata agent). This is also related to the question in #76.

Additional context

  1. With cgroup v2 this doesn't happen because the tests skip this.
  2. I added a new test which attempts to call set_kmem_limit -- this indeed fails with OS error (95 unsupported).
@liubin
Copy link
Member

liubin commented Jun 7, 2022

Thank you @dubek , are you ready to fix this?

@dubek
Copy link
Author

dubek commented Jun 7, 2022

@liubin I can submit a PR with a fix, but I need to understand your preference for the solution. One option is to simply make all the set_kmem_limit operations do nothing. Another option is to try to do it and ignore the Unsupported error. In both cases the current test (that sets a value and then reads it back) won't work, so need to be removed (in test_memory_res_build).

There might be other ideas. Please let me know what you think will work best (for this crate and for its users).

@wainersm
Copy link

Hi @dubek , @liubin , the fix for this issue is needed to enable a CI job for AMD SEV, so my interest on this.

I'm not an expert on this area but I'd like to share my opinion on the solutions raised by @dubek:

dubek added a commit to dubek/cgroups-rs that referenced this issue Jun 27, 2022
Setting (writing into) `memory.kmem.limit_in_bytes` is not supported in
Linux kernel >= 5.16 (see kernel commit 58056f77502: "memcg, kmem:
further deprecate kmem.limit_in_bytes"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58056f77502

If the write call in `set_kmem_limit()` returns EOPNOTSUPP, log a
warning message but ignore the error (do nothing).

Add a unit-test for `set_kmem_limit` in cgroups v1.

Fix kata-containers#81
dubek added a commit to dubek/cgroups-rs that referenced this issue Jun 27, 2022
Setting (writing into) `memory.kmem.limit_in_bytes` is not supported in
Linux kernel >= 5.16 (see kernel commit 58056f77502: "memcg, kmem:
further deprecate kmem.limit_in_bytes"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58056f77502

If the write call in `set_kmem_limit()` returns EOPNOTSUPP, log a
warning message but ignore the error (do nothing).

Add a unit-test for `set_kmem_limit` in cgroups v1.

Fix kata-containers#81
dubek added a commit to dubek/cgroups-rs that referenced this issue Jun 27, 2022
Setting (writing into) `memory.kmem.limit_in_bytes` is not supported in
Linux kernel >= 5.16 (see kernel commit 58056f77502: "memcg, kmem:
further deprecate kmem.limit_in_bytes"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58056f77502

If the write call in `set_kmem_limit()` returns EOPNOTSUPP, log a
warning message but ignore the error (do nothing).

Add a unit-test for `set_kmem_limit` in cgroups v1.

Fix kata-containers#81

Signed-off-by: Dov Murik <[email protected]>
@dubek
Copy link
Author

dubek commented Jun 27, 2022

I submitted PR #82 as a possible fix for this issue, according to the short term suggestion from @wainersm .

power-more pushed a commit to power-more/cgroups-rs that referenced this issue Jul 7, 2022
Setting (writing into) `memory.kmem.limit_in_bytes` is not supported in
Linux kernel >= 5.16 (see kernel commit 58056f77502: "memcg, kmem:
further deprecate kmem.limit_in_bytes"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58056f77502

If the write call in `set_kmem_limit()` returns EOPNOTSUPP, log a
warning message but ignore the error (do nothing).

Add a unit-test for `set_kmem_limit` in cgroups v1.

Fix kata-containers#81

Signed-off-by: Dov Murik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants