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

David Holmes david.holmes at oracle.com
Fri Apr 16 21:54:04 UTC 2021


On 16/04/2021 10:26 pm, Severin Gehwolf wrote:
> 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.

I don't see why the user cares about this distinction. We might care for 
logging purposes but that is different. There is no difference to the 
end user between cgroups defines no quota and cgroups quotas are not 
compiled into the kernel.

David
-----

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


More information about the hotspot-runtime-dev mailing list