[jdk8u-dev] RFR: 8292541: [Metrics] Reported memory limit may exceed physical machine memory

Jonathan Dowland jdowland at openjdk.org
Fri Jan 13 14:53:21 UTC 2023


On Fri, 13 Jan 2023 13:01:14 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:

>> jdk/src/linux/native/jdk/internal/platform/cgroupv1/CgroupMetrics.c line 42:
>> 
>>> 40:   (JNIEnv *env, jclass ignored)
>>> 41: {
>>> 42:     return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE);
>> 
>> According to my experiments changing this to:
>> 
>> 
>>     jlong page_size = sysconf(_SC_PAGESIZE);
>>     jlong pages = sysconf(_SC_PHYS_PAGES);
>>     return pages * page_size;
>> 
>> 
>> fixes the test issue on x86 (32 bit). As this is an issue with the upstream patch, I suggest to file an upstream bug to get it fixed as we'll likely have missed the issue on later JDKs (no testing happens on x86 AFAIK).
>
> Note that with an instrumented JDK I was able to observe the following (when the test fails):
> 
> 
> systemMemory == -1308622848
> containerMemory == 104857600
> Metrics.getMemoryLimit() == -1
> 
> 
> I.e. we were getting a negative host memory value.

Thanks for working on this! I guess without the explicit intermediate variables some kind of integer promotion/demotion is going on and there's an overflow on 32 bit?

I'll raise the upstream bug, thanks!

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

PR: https://git.openjdk.org/jdk8u-dev/pull/220


More information about the jdk8u-dev mailing list