RFR: 8268098: jdk.CPULoad event reports incorrect CPU usage inside a container

David Holmes dholmes at openjdk.java.net
Thu Jun 3 02:43:36 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.

Hi Yasumasa,

I'm a bit confused. We seem to have this logic in two places  - one in the VM and one in the JDK libraries. Shouldn't this fix look like the fix for JDK-8265836? Can we have just one chunk of code that handles all this?

Thanks,
David

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

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


More information about the hotspot-runtime-dev mailing list