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: 2020-09-11
  • 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 15
15 b11Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
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)
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/ad9525a5d546 User: sgehwolf Date: 2020-02-19 19:00:12 +0000
19-02-2020

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
15-11-2019

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)
11-11-2019