[PING] RFR: 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy

Bob Vandette bob.vandette at oracle.com
Mon Dec 2 17:13:30 UTC 2019


Sorry for the delay in responding.  See comments below:

> On Nov 29, 2019, at 4:05 AM, Severin Gehwolf <sgehwolf at redhat.com> wrote:
> 
> On Fri, 2019-11-15 at 17:51 +0100, Severin Gehwolf wrote:
>> Hi,
>> 
>> Could I please get reviews of these core-libs, Linux-only, changes to
>> the Metrics subsystem? This patch implements cgroupv2 support for
>> Metrics which are currently cgroupv1-only. Fedora 31 switched to
>> cgroupv2 by default so it's time to get OpenJDK recognize it.
>> 
>> Note that a couple of metrics are no longer supported with cgroupv2.
>> Most notably (not an exhaustive list, though):
>> 
>> Metrics.getKernel*() family of methods.
>> Metrics.getTcp*() family of methods.
>> Metrics.getBlkIO*() family of methods.
>> Metrics.isMemoryOOMKillEnabled()
>> 
>> A couple of open questions with regards to that:
>> 
>> 1)
>> Most API docs of Metrics make no distiction between "unlimited" and
>> "not supported", both returning -1 for longs, for example. This is a
>> problem, because output of "java -XshowSettings:system -version" will
>> not distinguish between unlimited and not supported metrics. Would it
>> be acceptable to change the API to distinguish those cases so that
>> LauncherHelper could display them appropriately?
>> 
>> 2)
>> How should we deal with "not supported" for booleans/arrays, etc.?
>> Would it make sense to return record objects from the Metrics API so
>> that this could be dealt with? E.g.
>> 
>> Metrics m = ...
>> MetricResult<int[]> result = m.getCpuSetCpus();
>> switch(result.getType()) {
>>   case NOT_SUPPORTED: /* do something */; break;
>>   case SUPPORTED: int[] val = result.get(); break;
>>   ...         
>> }
>> 
>> I'm bringing this up, because the proposed patch doesn't deal with the
>> above open questions as of yet. With that being said, it's mostly
>> identical to the proposed hotspot changes in [1].

For issue 1 and 2 …

I wonder if we should change the API to throw UnsupportedOperationException for those methods 
that are not available.  This exception is used quite a lot in the java/nio and java/net packages
for dealing with functionality not available on a host platform.

As an alternate suggestion, we already return -2 for "not supported" for most APIs in the hotspot
implementation.  We could use this for non boolean values in the Metrics API.  For boolean
values, we could change the API to return “Boolean”.  A null return would signify not
implemented.

>> 
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8231111
>> webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8231111/04/webrev/
>> 

http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8231111/04/webrev/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemFactory.java.html

Should we check to make sure that there are no mixed cgroupv1 and cgroupv2 mounted subsystems since
you are not supporting mixing.


http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8231111/04/webrev/src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java.html

It looks looks like there may be alternate ways of reporting some of the metrics that you have classified as RETVAL_NOT_SUPPORTED.

BlkIOServicedCount (io.stat)
KernelMemory (memory.stat)
TcpMemory (memory.stat)

You could try the same trick for getMemoryAndSwapMaxUsage which keeps track of the highest returned value.

for the benefit of other reviewers, you should provide links to the cgroupv1 and v2 docs.

https://www.kernel.org/doc/Documentation/cgroup-v2.txt

>> Testing: jdk/submit and platform docker tests on Linux x86_64 (with
>> hybrid hierarchy, docker/podman) and on Linux x86_64 with unified
>> hierarchy (podman only).
>> 
>> Thoughts? Suggestions?

Do you think we should check the docker version being used for the tests to make sure it
supports cgroupv2?  I assume a fairly recent version is required to work with cgroupv2.

Bob.



> 
> Ping?
> 
>> Thanks,
>> Severin
>> 
>> [1] http://mail.openjdk.java.net/pipermail/hotspot-dev/2019-November/039909.html
> 



More information about the core-libs-dev mailing list