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

Yasumasa Suenaga ysuenaga at openjdk.java.net
Tue Apr 13 07:03:04 UTC 2021


On Tue, 13 Apr 2021 06:14:42 GMT, David Holmes <dholmes at openjdk.org> wrote:

> 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.

I pushed new commit to move the fix into `getCpuLoad()`.

> 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?

I think this problem is similar to [JDK-8264482](https://bugs.openjdk.java.net/browse/JDK-8264482) (PR #3280 ). Currently both HotSpot and MBean check whether cgroups exists, but the the host (not into the container) might have it. We've discussed about it in #3280 , then I think it is difficult to modify to check whether the VM is in the container. Thus I think it is reasonable to just return host CPU load value at here.

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

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


More information about the serviceability-dev mailing list