RFR: 8292083: Detected container memory limit may exceed physical machine memory [v8]
Jonathan Dowland
jdowland at openjdk.org
Tue Aug 23 08:32:29 UTC 2022
On Mon, 22 Aug 2022 15:09:45 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
>> Jonathan Dowland has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove cgroup sanity checking logic from os::Linux::available_memory
>>
>> and rely upon it from os::physical_memory instead.
>
> src/hotspot/os/linux/os_linux.cpp line 198:
>
>> 196: if (OSContainer::is_containerized()) {
>> 197: jlong mem_limit, mem_usage;
>> 198: mem_limit = os::physical_memory();
>
> `os:physical_memory()` will never return a value `<= 0`. Thus, with this change, `OSContainer::memory_usage_in_bytes()` will always be called on a system with no limits set. Previously it (likely) detected that and `mem_limit` was set to `-1` (for unlimited). This is a concern since it would circumvent some caching. `memory_limit_in_bytes` uses caching, `memory_usage_in_bytes` not. I'd suggest to change this to something like this:
>
>
> jlong mem_limit, mem_usage, host_mem;
> mem_limit = OSContainer::memory_limit_in_bytes();
> host_mem = Linux::physical_memory();
> if (mem_limit > host_mem) {
> mem_limit = -1; // bail out of container code
> }
> [...]
>
>
> `Linux::physical_memory()` is just a field read and `memory_limit_in_bytes()` uses caches. So this should be OK.
I see, thank you. Resolved with 60865050954.
-------------
PR: https://git.openjdk.org/jdk/pull/9880
More information about the hotspot-runtime-dev
mailing list