RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v7]
Severin Gehwolf
sgehwolf at openjdk.java.net
Tue Jul 13 15:12:59 UTC 2021
On Tue, 13 Jul 2021 05:19:25 GMT, xpbob <github.com+7837910+xpbob at openjdk.org> wrote:
>> …ocess cpu usage in containers
>
> xpbob has updated the pull request incrementally with one additional commit since the last revision:
>
> Set 1.0 for cpu set max
Except for the missing comments in the new code blocks this looks good to me.
src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java line 98:
> 96: hostTicks = hostTicks * containerCPUs / totalCPUs;
> 97: return getUsageDividesTotal(cpuUsageSupplier().getAsLong(), hostTicks);
> 98: } else {
The old code had these comments here. We should add them as they're still relevant:
// If CPU quotas and shares are not active then find the average system load for
// all online CPUs that are allowed to run this container.
// If the cpuset is the same as the host's one there is no need to iterate over each CPU
src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java line 106:
> 104: cpuSet = containerMetrics.getCpuSetCpus();
> 105: }
> 106: if (cpuSet == null) {
Please add the comment as it was in the original code:
// cgroups is mounted, but CPU resource is not limited.
// We can assume the VM is run on the host CPUs.
-------------
Marked as reviewed by sgehwolf (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/4702
More information about the serviceability-dev
mailing list