本来是排查 JDK-8265836 导致的 CPU 使用率不准确的问题,无意发现该修复方案存在一点小问题,顺手提交了个 PR 进行修复。
Reference
Java SE OperatingSystemMXBean.getSystemCpuLoad() Method Returns Incorrect Value in Containers
8265836: OperatingSystemImpl.getCpuLoad() returns incorrect CPU load inside a container by tanghaoth90 · Pull Request #3656 · openjdk/jdk · GitHub
8265836: OperatingSystemImpl.getCpuLoad() returns incorrect CPU load … · openjdk/jdk@ef368b3 · GitHub
JDK-8297173 usageTicks and totalTicks should be volatile to ensure that different threads get the latest ticks - Java Bug System