JDK-8333446 : Add tests for hierarchical container support
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2024-06-03
  • Updated: 2024-09-16
  • Resolved: 2024-09-11
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 24
24 b15Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
JDK-8217338 added support for running the JDK in systemd slices which follows a slightly different model for how resource restrictions based on cgroups work. However, no test was ever added for this and we need to fix that.

One example of how this can regress is JDK-8322420 (cgroup v2 specific), though.
Comments
These tests when run as regular user need to have the user@.slice properly set up so that for example 'systemctl --user status' works. $ systemctl --user status; echo $? ● F39 State: running Units: 168 loaded (incl. loaded aliases) Jobs: 0 queued Failed: 0 units Since: Mon 2024-09-16 12:20:49 UTC; 1h 28min ago systemd: 254.9-1.fc39 CGroup: /user.slice/user-1000.slice/user@1000.service └─init.scope ├─3295 /usr/lib/systemd/systemd --user └─3296 "(sd-pam)" 0 When this isn't the case (as below), then the test will be skipped. Details in JDK-8340092. $ systemctl --user status; echo $? Failed to connect to bus: No medium found 1
16-09-2024

[~mbaesken] OK. I'll take a look. I've filed JDK-8340092 to track it.
13-09-2024

We see containers/systemd/SystemdMemoryAwarenessTest.java failing on an system with Linux Ubuntu 22.04 (Linux x86_64) and one another with Linux RHEL 9.3 (ppc64le). stdout DEBUG: Running test with a CPU limit of 1 stderr java.nio.file.FileAlreadyExistsException: /<ourhomedir>/.config/systemd/user/jdk_internal.slice.d at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:446) at java.base/java.nio.file.Files.createDirectory(Files.java:700) at jdk.test.lib.containers.systemd.SystemdTestUtils.buildSystemdSlices(SystemdTestUtils.java:138) at jdk.test.lib.containers.systemd.SystemdTestUtils.buildAndRunSystemdJava(SystemdTestUtils.java:90) at SystemdMemoryAwarenessTest.testHelloSystemd(SystemdMemoryAwarenessTest.java:69) at SystemdMemoryAwarenessTest.main(SystemdMemoryAwarenessTest.java:48) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:573) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1576)
13-09-2024

Changeset: d9fdf69c Branch: master Author: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2024-09-11 16:57:13 +0000 URL: https://git.openjdk.org/jdk/commit/d9fdf69c34c20e0f2d526c2f04450acb904c3e80
11-09-2024

When run as a regular user on cg v2 this new added test needs to have cpu delegation enabled (provided the cpu controller is enabled to begin with). This can be done on RHEL 9 (for example) like so: # cat /etc/systemd/system/user\@.service.d/cgroup2_cpu.conf [Service] Delegate=yes I.e. add Delegate=yes to all user* services. When configuring a system it also requires a reboot for the delegation to get into effect.
10-09-2024

The proposed change adds automated tests similar to these manual runs: $ cat /etc/systemd/system/test-cpu-mem.slice [Unit] Description=Demo cgroup Before=slices.target [Slice] MemoryAccounting=true MemoryLimit=4100M $ cat /etc/systemd/system/test-cpu.slice [Unit] Description=Demo cpu cgroup Before=slices.target [Slice] CPUAccounting=true # 2 CPU cores CPUQuota=200% $ cat /etc/systemd/system/test.slice.d/memory-limit.conf [Slice] MemoryAccounting=true MemoryLimit=1024M $ sudo systemctl daemon-reload && sudo systemd-run --slice test-cpu-mem.slice --scope ./bin/java -Xlog:os+container=trace <class> That is, test-cpu-mem.slice is nested in test-cpu.slice and has an additional, top-level, memory limit via test.slice.d (memory-limit.conf). This covers a CPU limit somewhere different in the hierarchy as the memory limit. It also covers the case where a memory limit further down the hierarchy is present, yet a lower limit (that the kernel enforces), is higher up the hierarchy and should be the detected memory limit (1024M).
03-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/19530 Date: 2024-06-03 17:28:09 +0000
09-07-2024

[~mseledtsov] Would you be able to help review this, please?
20-06-2024