RFR: 8265836: OperatingSystemImpl.getCpuLoad() returns incorrect CPU load inside a container [v5]

Hao Tang github.com+7947546+tanghaoth90 at openjdk.java.net
Tue May 25 11:42:21 UTC 2021


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

Hao Tang has updated the pull request incrementally with one additional commit since the last revision:

  remove PER_CPU_SHARES

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3656/files
  - new: https://git.openjdk.java.net/jdk/pull/3656/files/066083e9..c7abec03

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=3656&range=04
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=3656&range=03-04

  Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3656.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3656/head:pull/3656

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


More information about the serviceability-dev mailing list