RFR: 8262953: [TESTBUG] Test /runtime/containers/cgroup/PlainRead.java fails if CPU quoata is not enabled

Severin Gehwolf sgehwolf at openjdk.java.net
Fri Apr 16 12:26:36 UTC 2021


On Fri, 16 Apr 2021 12:18:05 GMT, David Holmes <dholmes at openjdk.org> wrote:

> I'm not sure my, simple, point is getting through. Here's the cgroupv1 code:
> 
> ```
> /* cpu_quota
>  *
>  * Return the number of microseconds per period
>  * process is guaranteed to run.
>  *
>  * return:
>  *    quota time in microseconds
>  *    -1 for no quota
>  *    OSCONTAINER_ERROR for not supported
>  */
> int CgroupV1Subsystem::cpu_quota() {
>   GET_CONTAINER_INFO(int, _cpu->controller(), "/cpu.cfs_quota_us",
>                      "CPU Quota is: %d", "%d", quota);
>   return quota;
> }
> ```
> 
> But if GET_CONTAINER_INFO doesn't find /cpu.cfs_quota_us the macro does "return OSCONTAINER_ERROR" which is "return -2". Yet the spec states that if there is no quota then -1 is returned, so why are we not returning -1?

@dholmes-ora Because they're not equivalent. `-1` means, the system supports it in general, but no cgroups quota is in place. I.e. unlimited. For example A) `docker run --memory 200M <somejavacontainer>` on a cgroup capable system with all the kernel support should report the memory limit. B) `docker run <somejavacontainer>`. Case B) would return -1. `-2` is usually something unexpected and means the system doesn't support it (be it by kernel config, the file not being present where a file is expected to be present, etc.). We want to distinguish those two cases.

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

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


More information about the hotspot-runtime-dev mailing list