RFR: 8265104: CpuLoad and SystemCpuLoad in OperatingSystem MXBean returns -1.0

David Holmes dholmes at openjdk.java.net
Tue Apr 13 06:17:58 UTC 2021


On Tue, 13 Apr 2021 02:00:24 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

> I got -1.0 from both CpuLoad and SystemCpuLoad in OperatingSystem MXBean when I run the application on Fedora 33 x64 which is installed cgroups V2.
> 
> ![jconsole-cpuload](https://user-images.githubusercontent.com/7421132/114485721-6372a180-9c47-11eb-81d9-568324cba336.png)
> 
> I do not run the application in the container, nor do not run with resource limitation on cgroups, so JMX should report CPU load on host value in this case.

Hi Yasumasa,

This strikes me as the wrong fix to the problem. isCpuSetSameAsHostCpuSet is only intended to be used as a simple optimization when the configured cpuset happens to match the hosts. What you are looking for is a fix to the problem when there is no cpuset set at all. It strikes me that in getCpuLoad() if there are no quotas and no effective-cpu-set and no cpusets.cpus value, then it should fallback to using the host values rather than returning -1. That said, the problem may also be that we have a containerMetrics object when no container is actually active! Perhaps that is the true bug here?

Thanks,
David

David

-------------

PR: https://git.openjdk.java.net/jdk/pull/3447


More information about the serviceability-dev mailing list