JDK-8253797 : [cgroups v2] Account for the fact that swap accounting is disabled on some systems
Type:Bug
Component:hotspot
Sub-Component:runtime
Affected Version:16
Priority:P3
Status:Resolved
Resolution:Fixed
OS:linux
CPU:generic
Submitted:2020-09-29
Updated:2022-12-15
Resolved:2020-12-10
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
This is similar to JDK-8250984, but for cgroups v2.
If no swap limit files are available the memory limit should be returned. That makes cgroups v1 and cgroups v2 consistent again.
Comments
Fix request (8u)
Please consider this as part of the cgroups v2 backport to jdk8u. This is a clean patch. Thanks!
08-12-2022
A pull request was submitted for review.
URL: https://git.openjdk.org/jdk8u-dev/pull/185
Date: 2022-11-18 09:56:24 +0000
18-11-2022
Fix Request 11u
Requesting a backport to 11u as part of CGroups v2 support. The patch applies cleanly and passes tier 1 and container tests.
13-04-2022
A pull request was submitted for review.
URL: https://git.openjdk.java.net/jdk11u-dev/pull/987
Date: 2022-04-01 20:19:16 +0000
Without this fix and with JDK-8250984 in place only one test fails for me on cgroups v2 with swapaccount=0
FAILED: jdk/internal/platform/docker/TestDockerMemoryMetrics.java
More specifically, containers/docker/TestMemoryAwareness.java test passes without the fix.
07-12-2020
Before:
----------
$ podman run --rm -it -v $(pwd)/openjdk-16-jdk:/jdk --memory=300m fedora:33 /bin/bash
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[root@206dcc27af24 /]# ./jdk/bin/java -XshowSettings:system -version
Operating System Metrics:
Provider: cgroupv2
Effective CPU Count: 4
CPU Period: 100000us
CPU Quota: -1
CPU Shares: -1
List of Processors: N/A
List of Effective Processors, 4 total:
0 1 2 3
List of Memory Nodes: N/A
List of Available Memory Nodes, 1 total:
0
Memory Limit: 300.00M
Memory Soft Limit: 0.00K
Memory & Swap Limit: Unlimited
openjdk version "16-internal" 2021-03-16
OpenJDK Runtime Environment (fastdebug build 16-internal+0-adhoc.sgehwolf.jdk-jdk)
OpenJDK 64-Bit Server VM (fastdebug build 16-internal+0-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
After:
-------
$ podman run --rm -ti --memory=300m -v $(pwd)/openjdk-16-jdk:/jdk fedora:33
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[root@fdd2aed99d39 /]# /jdk/bin/java -XshowSettings:system -version
Operating System Metrics:
Provider: cgroupv2
Effective CPU Count: 4
CPU Period: 100000us
CPU Quota: -1
CPU Shares: -1
List of Processors: N/A
List of Effective Processors, 4 total:
0 1 2 3
List of Memory Nodes: N/A
List of Available Memory Nodes, 1 total:
0
Memory Limit: 300.00M
Memory Soft Limit: 0.00K
Memory & Swap Limit: 300.00M
Note the difference in "Memory & Swap Limit" output.
07-12-2020
Fedora 33 has podman 2.2.0 so this should be ready now for development:
$ podman --version
podman version 2.2.0
$ grep swapaccount /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.9.12-200.fc33.x86_64 root=UUID=be19c1c6-2985-4a4b-add9-011cd5ae0e1c ro rootflags=subvol=root rhgb quiet swapaccount=0
$ podman run --rm -it --memory-reservation=200m --memory=300m --memory-swap=300m fedora:33 /bin/bash
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[root@6c381aa047f6 /]#
07-12-2020
Looks like this will be part of podman 2.2 and better.
07-12-2020
PR for podman to fix this:
https://github.com/containers/podman/pull/8197
30-10-2020
Right now this case is impossible on systems I've access to.
$ grep swapaccount= /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.8.11-300.fc33.x86_64 root=UUID=be19c1c6-2985-4a4b-add9-011cd5ae0e1c ro rootflags=subvol=root rhgb quiet swapaccount=0
$ podman run --rm -it --memory-reservation=200m --memory=300m --memory-swap=300m fedora:33 /bin/bash
Error: opening file `memory.swap.max` for writing: Permission denied: OCI runtime permission denied error
This is different for cgroups v1 where 'docker' allows one to start a container on such systems. In contrast, podman on such cgroups v1 systems doesn't allow that[1]:
# grep swapaccount= /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.6.6-300.fc32.x86_64 root=/dev/mapper/fedora_localhost--live-root ro resume=/dev/mapper/fedora_localhost--live-swap rd.lvm.lv=fedora_localhost-live/root rd.lvm.lv=fedora_localhost-live/swap rhgb quiet systemd.unified_cgroup_hierarchy=0 swapaccount=0
# docker run --rm -it --memory-reservation=200m --memory=300m --memory-swap=300m fedora:32 /bin/bash
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[root@7b583400a1f2 /]#
# podman run --rm -it --memory-reservation=200m --memory=300m --memory-swap=300m fedora:32 /bin/bash
Your kernel does not support swap limit capabilities,or the cgroup is not mounted. Memory limited without swap.
Error: writing file `memory.memsw.limit_in_bytes`: Permission denied: OCI runtime permission denied error
[1] https://github.com/containers/podman/issues/6365
Once the podman issue is properly resolved this could be looked at.