RFR: 8239559: Cgroups v2: Incorrect detection logic on some systems

Baesken, Matthias matthias.baesken at sap.com
Mon Feb 24 11:05:28 UTC 2020

Hi Severin, I'll put your patch into our internal  build/test queue .

Additionally I can confirm that the error I reported last week  when running  jtreg tests : 

> > ./jtregojdk.sh tools/jpackage
> java.lang.InternalError: java.lang.reflect.InvocationTargetException
>                 at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:65)
>                 at java.base/jdk.internal.platform.Container.metrics(Container.java:43)
>                 at jdk.management/com.sun.management.internal.OperatingSystemImpl.<init>(OperatingSystemImpl.java:48)
>                 at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl.getOperatingSystemMXBean(PlatformMBeanProviderImpl.java:281)
>                 at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl$3.nameToMBeanMap(PlatformMBeanProviderImpl.java:198)
>                 at java.management/sun.management.spi.PlatformMBeanProvider$PlatformComponent.getMBeans(PlatformMBeanProvider.java:195)
>                 at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:686)
>                 at java.management/java.lang.management.ManagementFactory.getOperatingSystemMXBean(ManagementFactory.java:388)

Is gone with the patch.

Best regards, Matthias

> Could I please get a review of this fix to the detection heuristic of
> cgroup v1 vs cgroup v2? Matthias (in CC) discovered that on some old
> systems the JDK Metrics code throws InternalError caused by wrong
> detection logic when Metrics are being created on Linux.
> The reason for this is that hierarchy IDs of 0 in /proc/cgroups is
> being used as a heuristic to detect cgroups v2 systems. Apparently some
> old systems like RHEL 6 and SLES 11 have no cgroups controllers
> mounted, thus, triggering a false positive.
> The fix is to also look at /proc/self/mountinfo and correct logic in
> this case.
> Bug: https://bugs.openjdk.java.net/browse/JDK-8239559
> webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-
> 8239559/01/webrev/
> Testing: docker/cgroups tests on hybrid (cgroups v1) and unified
> hierarchy (cgroups v2). New regression test. Looks good here.
> Unfortunately, I wasn't able to reproduce this on an actual affected
> system. I somewhat reproduced via the derived regression test based on
> data from reporters. I'd appreciate any testing on systems where this
> reproduces.
> Thanks,
> Severin

More information about the core-libs-dev mailing list