JDK-8327946 : containers/docker/TestJFREvents.java fails when host kernel config vm.swappiness=0 after JDK-8325139
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-03-12
  • Updated: 2024-04-26
  • Resolved: 2024-04-17
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.

To download the current JDK release, click here.
JDK 23
23 b19Fixed
Related Reports
Relates :  
Description
If the kernel config vm.swappiness=0, the testcase containers/docker/TestJFREvents.java fails: 'totalSize = 104857600' missing from stdout/stderr

> sudo swapon --show ; free -h ; cat /etc/os-release ; uname -a ; sudo sysctl -a | grep swap -i
              total        used        free      shared  buff/cache   available
Mem:          187Gi       5.1Gi        67Gi        95Mi       115Gi       180Gi
Swap:            0B          0B          0B
NAME="Alibaba Cloud Linux"
VERSION="3 (Soaring Falcon)"
ID="alinux"
ID_LIKE="rhel fedora centos anolis"
VERSION_ID="3"
UPDATE_ID="9"
PLATFORM_ID="platform:al8"
PRETTY_NAME="Alibaba Cloud Linux 3 (Soaring Falcon)"
ANSI_COLOR="0;31"
HOME_URL="https://www.aliyun.com/"

Linux j66e07344.sqa.eu95 5.10.134-16.1.al8.x86_64 #1 SMP Thu Dec 7 14:11:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
vm.swappiness = 0

test command:
rm -rf tmp ; jtreg -w tmp -nr -v:fail,error test/hotspot/jtreg/containers/docker/TestJFREvents.java
cd tmp/scratch
docker build --no-cache --tag jdk-internal:test jdk-internal-test-containers-docker-TestJFREvents-jfr-events
cd ../..
export CLASSPATH=$PWD/tmp/classes/containers/docker/TestJFREvents.d
docker run --pids-limit -1 --network host --privileged -h docker -u $(id -u ${USER}):$(id -g ${USER}) -w $HOME -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v /etc/shadow:/etc/shadow:ro --rm -it -v $HOME:$HOME -e CLASSPATH=$CLASSPATH --name jtreg -w $PWD --memory=200m --memory-swap=300m jdk-internal:test java JfrReporter jdk.SwapSpace


testcase fail message:
STDERR:
 stdout: [===== EventType: jdk.SwapSpace
startTime = 699024071
totalSize = 0
freeSize = 0
===== EventType: jdk.SwapSpace
startTime = 699480132
totalSize = 0
freeSize = 0
];
 stderr: []
 exitValue = 0

java.lang.RuntimeException: 'totalSize = 104857600' missing from stdout/stderr
        at jdk.test.lib.process.OutputAnalyzer.shouldContain(OutputAnalyzer.java:252)
        at TestJFREvents.testSwapMemory(TestJFREvents.java:226)
        at TestJFREvents.main(TestJFREvents.java:73)

If we add docker run parameter --memory-swappiness=60, then the jfr output contains the expected message: "totalSize = 104857600"

According to the docker document(https://docs.docker.com/config/containers/resource_constraints/#--memory-swappiness-details), the default value of --memory-swappiness is inherited from the host machine.
So, when the the kervnel config vm.swappiness=0 on the host machine, this testcase will fail, because of docker container can not use swap memory, the deafult value of --memory-swappiness is 0.


Comments
Changeset: 7744b004 Author: SendaoYan <syan@openjdk.org> Committer: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2024-04-17 08:39:12 +0000 URL: https://git.openjdk.org/jdk/commit/7744b0046af4dbacb7068ae819d8a973cfbf8e40
17-04-2024

It seems than only cgroupv1 can reproduce this failure. On fedora35, the default config of "vm.swappiness" is 0, but this test run success. root@fedora35:[~]> sudo swapon --show ; free -h ; cat /etc/os-release ; uname -a ; sudo sysctl -a | grep swap -i total used free shared buff/cache available Mem: 1.7Gi 313Mi 838Mi 3.0Mi 576Mi 1.2Gi Swap: 0B 0B 0B NAME="Fedora Linux" VERSION="35 (Thirty Five)" ID=fedora VERSION_ID=35 VERSION_CODENAME="" PLATFORM_ID="platform:f35" PRETTY_NAME="Fedora Linux 35 (Thirty Five)" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:35" HOME_URL="https://fedoraproject.org/" DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/" SUPPORT_URL="https://ask.fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=35 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=35 PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" Linux fedora35 5.18.18-100.fc35.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 17 16:09:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux vm.swappiness = 0 root@fedora35:[~]> docker info 2>&1 | grep -i "Cgroup.*Version" cgroupVersion: v2 root@fedora35:[~]> docker run --pids-limit -1 --network host --privileged -h docker -u $(id -u ${USER}):$(id -g ${USER}) -w $HOME -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v /etc/shadow:/etc/shadow:ro --rm -it -v $HOME:$HOME -e CLASSPATH=$CLASSPATH --name jtreg -w $PWD --memory=200m --memory-swap=300m jdk-internal:test /jdk/bin/java JfrReporter jdk.SwapSpace ===== EventType: jdk.SwapSpace startTime = 485984657 totalSize = 104857600 freeSize = 104857600 ===== EventType: jdk.SwapSpace startTime = 488044019 totalSize = 104857600 freeSize = 104857600
12-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18225 Date: 2024-03-12 09:06:45 +0000
12-03-2024

I found a test machine, which the default kernel config vm.swappiness=60. With the default docker run parameter, i.e. without give --memory-swappiness parameter, the jfr contains expected output: "totalSize = 104857600". After add the --memory-swappiness=0, the jfr print: "totalSize = 0"
12-03-2024