JDK-8231111 : Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
  • Type: Sub-task
  • Component: core-libs
  • Affected Version: 8u231,11.0.5,13.0.1,14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2019-09-17
  • Updated: 2022-12-05
  • Resolved: 2020-02-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 11 JDK 15 JDK 8 Other
11.0.16-oracleFixed 15 b11Fixed 8u361Fixed openjdk8u372Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Currently, the Linux-only Metrics class in jdk/internal/platform/Metrics.java hard-codes cgroups version 1:

     * Returns an instance of the Metrics class.
     * @return Metrics object or null if not supported on this platform.
    public static Metrics systemMetrics() {
        try {
            // We currently only support cgroupv1
            Class<?> c = Class.forName("jdk.internal.platform.cgroupv1.Metrics");

For the cgroups v2 effort this needs to be reworked.

On a F31 system with unified hierarchy only, java -XshowSettings:system look like this:

$ bin/java -XshowSettings:system -version
Operating System Metrics:
    No metrics available for this platform
openjdk version "14-internal" 2020-03-17
OpenJDK Runtime Environment (fastdebug build 14-internal+0-adhoc.sgehwolf.jdk-jdk)
OpenJDK 64-Bit Server VM (fastdebug build 14-internal+0-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
Fix Request (8u) Please consider this backport for OpenJDK 8u (targetting 8u372) as part of an effort to backport Cgroups V2 support. This patch is one identified as being good candidates for initial integration (8230305, 8231111, 253714, 8253727, 8224506). Thanks!

A pull request was submitted for review. URL: https://git.openjdk.org/jdk8u-dev/pull/121 Date: 2022-09-21 10:12:07 +0000

Fix Request (11u) I would like to backport this patch to 11u for Cgroup V2 support. The original patch does not apply cleanly and 11u patch has been reviewed.

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk11u-dev/pull/863 Date: 2022-03-08 18:47:32 +0000

[~neato] Why did you change component from core-libs to hotspot? This bug is about a core-libs change (in java.base). The equivalent hotspot change is JDK-8230305.

URL: https://hg.openjdk.java.net/jdk/jdk/rev/ad9525a5d546 User: sgehwolf Date: 2020-02-19 19:00:12 +0000

Latest webrev which passes tests: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8231111/04/webrev/ RFR: http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-November/063464.html

Initial (untested) webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8231111/01/webrev/ Since MetricsTester seems to be cgroupv1 specific, tests cannot possibly pass. With that said on a f31 podman container: $ podman run -ti --rm --memory=200M jdk-test-metrics Operating System Metrics: Provider: cgroupv2 Effective CPU Count: 4 CPU Period: 100000us CPU Quota: -1 CPU Shares: -1 List of Processors, 0 total: List of Effective Processors, 0 total: List of Memory Nodes, 0 total: List of Available Memory Nodes, 0 total: CPUSet Memory Pressure Enabled: false Memory Limit: 200.00M Memory Soft Limit: Unlimited Memory & Swap Limit: 400.00M Kernel Memory Limit: Unlimited TCP Memory Limit: Unlimited openjdk version "14-internal" 2020-03-17 OpenJDK Runtime Environment (build 14-internal+0-adhoc.sgehwolf.openjdk-head-2) OpenJDK 64-Bit Server VM (build 14-internal+0-adhoc.sgehwolf.openjdk-head-2, mixed mode, sharing)