RFR: 8327946: containers/docker/TestJFREvents.java fails when host kernel config vm.swappiness=0 after JDK-8325139
Severin Gehwolf
sgehwolf at openjdk.org
Thu Apr 11 09:53:42 UTC 2024
On Tue, 12 Mar 2024 09:06:45 GMT, SendaoYan <syan at openjdk.org> wrote:
> Hi,
>
> 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 kernel 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.
>
> When the host kernel config "vm.swappiness = 0", In order to run this testcase passed , there are three methods:
>
> 1. change `.shouldContain("totalSize = " + expectedTotalValue)` to `.shouldContain("totalSize = "`, which ignored the `expectedTotalValue`, because the `expectedTotalValue` could be 0(swap memroy is disable when --memory-swappiness=0) or could be 104857600(300MB-200MB=100MB), it depends on the host machine config `vm.swappiness`
> 2. Change the default `--memory-swappiness` 0 to non-zero, such as 60.
> 3. Change the host kernel config `vm.swappiness=0` to `vm.swappiness=60`. I think it's not a good idea.
>
> Maybe the 2rd method seems more resonable.
>
>
> Thanks,
> -sendao
`--memory-swappiness` is cgv1 specific and needs to be handled for the cgv2 case.
test/hotspot/jtreg/containers/docker/TestJFREvents.java line 225:
> 223: .addDockerOpts("--memory-swap=" + swapValueToSet)
> 224: //The default memory-swappiness vaule is inherited from the host machine, which maybe 0
> 225: .addDockerOpts("--memory-swappiness=60")
Nit: Space after `//`.
`--memory-swappiness` is cgroup v1 (legacy specific):
$ podman run --rm -ti --memory-swappiness=60 fedora:39
Error: OCI runtime error: crun: cannot set memory swappiness with cgroupv2
Therefore, we need to ensure we are running on cgroups v1 when we add that option.
-------------
Changes requested by sgehwolf (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/18225#pullrequestreview-1993768230
PR Review Comment: https://git.openjdk.org/jdk/pull/18225#discussion_r1560753959
More information about the hotspot-dev
mailing list