JDK-8336881 : [Linux] Support for hierarchical limits for Metrics
  • Type: Enhancement
  • Component: core-svc
  • Affected Version: 24
  • Priority: P3
  • Status: In Progress
  • Resolution: Unresolved
  • OS: linux
  • CPU: generic
  • Submitted: 2024-07-22
  • Updated: 2024-08-19
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
24Unresolved
Related Reports
Blocks :  
Blocks :  
Description
The hotspot implementation for this is done as part of JDK-8322420. However, we will need a similar fix to the Java implementation of the jdk.internal.platform classes on Linux to appropriately report the limits when they're not set on the leaf nodes:

# cat /sys/fs/cgroup/user.slice/user-cg.slice/user-cg-cpu.slice/run-rd82109f39ab843ff828c868d54a063f5.scope/memory.max
max
# cat /sys/fs/cgroup/user.slice/user-cg.slice/user-cg-cpu.slice/memory.max 
max
# cat /sys/fs/cgroup/user.slice/user-cg.slice/memory.max 
2097152000
# ./bin/java -XshowSettings:system --version
Operating System Metrics:
    Provider: cgroupv2
    Effective CPU Count: 2
    CPU Period: -1
    CPU Quota: -1
    CPU Shares: -1
    List of Processors: N/A
    List of Effective Processors: N/A
    List of Memory Nodes: N/A
    List of Available Memory Nodes: N/A
    Memory Limit: Unlimited
    Memory Soft Limit: 0.00K
    Memory & Swap Limit: Unlimited
    Maximum Processes Limit: 31000

That is, the memory limit is set two levels up the hierarchy instead of the leaf node (/sys/fs/cgroup/user.slice/user-cg.slice/user-cg-cpu.slice/run-rd82109f39ab843ff828c868d54a063f5.scope/memory.max) and the system metrics don't list the limit correctly.

Expected:

Memory Limit: 2GB

Actual:

Memory Limit: Unlimited

This fix will depend on the hotspot fix, since the "-XshowSettings:system" output will (wrongly) show "System not containerized", since it thinks no limits are set. The fix in JDK-8322420 will alleviate this.

A real-world test will likely depend on the framework added in JDK-8333446 since container frameworks like docker/podman have the limits at the leaf node.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20280 Date: 2024-07-22 16:56:00 +0000
19-08-2024

A regression test uses the framework introduced with JDK-8333446. Adding it as blocking.
22-07-2024