RFR: 8268098: jdk.CPULoad event reports incorrect CPU usage inside a container
Severin Gehwolf
sgehwolf at openjdk.java.net
Mon Jun 7 12:28:59 UTC 2021
On Wed, 2 Jun 2021 06:59:53 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:
> jdk.CPULoad event reports CPU usage.
> If JVM runs in a container which is limited CPU resource (quota, shares, cpu), it is incorrect.
>
> When I ran following program inside a container with `--cpuset-cpu=0,1`, I expected jdk.CPULoad event reports 50%, however it reported 25% because container host has 4 CPUs.
>
>
> public class InfiniteLoop{
> public static void main(String[] args){
> while(true){
> }
> }
> }
>
>
> jdk.CPULoad event uses the result from `get_cpu_load()` in os_perf_linux.cpp, but it does not consider cgroups.
> _Mailing list message from [David Holmes](mailto:david.holmes at oracle.com) on [hotspot-runtime-dev](mailto:hotspot-runtime-dev at mail.openjdk.java.net):_
[...]
> Leaving aside that consolidating to one copy of the code should be done
> as a future RFE, shouldn't the existing two copies behave in exactly the
> same way?
Yes, I agree. My comment wasn't really a review of any kind, just mentioning the status quo.
Since there has been [JDK-8203359](https://bugs.openjdk.java.net/browse/JDK-8203359) implemented in JDK 17 I wonder if changing jdk.CPULoad event the way it's proposed makes sense. Maybe `ContainerCPUUsage` event should be used in order to gather this info instead?
-------------
PR: https://git.openjdk.java.net/jdk/pull/4299
More information about the hotspot-runtime-dev
mailing list