On Fri, 23 Apr 2021 13:33:42 GMT, Hao Tang <github.com+7947546+tanghaot...@openjdk.org> wrote:
> OperatingSystemImpl.getCpuLoad() may return 1.0 in a container, even though > the CPU load is obviously below 100%. > > We created a 5-core container and run 4 "while (true)" loops in the > container. OperatingSystemImpl.getCpuLoad() returned 1.0, which is incorrect > (0.8 is correct). > "systemLoad" in getCpuLoad() is exactly 4.0 before "systemLoad = > Math.min(1.0, systemLoad);". The problem is caused by using the elapsed time > (specified by "cpu.cfs_period_us") instead of the total CPU time (specified > by "cpu.cfs_quota_us"). Therefore, it is more reasonable to divide cpu usage > time by "quotaNanos" instead of "elapsedNanos". This pull request has now been integrated. Changeset: ef368b32 Author: Hao Tang <albert...@alibaba-inc.com> Committer: Severin Gehwolf <sgehw...@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/ef368b32bc8609bdc46cda628fa25e9bcad751e3 Stats: 90 lines in 4 files changed: 78 ins; 2 del; 10 mod 8265836: OperatingSystemImpl.getCpuLoad() returns incorrect CPU load inside a container Co-authored-by: Shaojun Wang <jeffery....@alibaba-inc.com> Co-authored-by: Severin Gehwolf <sgehw...@openjdk.org> Reviewed-by: sgehwolf, ysuenaga ------------- PR: https://git.openjdk.java.net/jdk/pull/3656