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

Severin Gehwolf sgehwolf at openjdk.org
Fri Jan 13 13:03:41 UTC 2023


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

>> This is a backport of JDK-8292541 to jdk8u-dev as part of cgroups v2 support.
>> 
>> It's not clean: two separate fix ups were needed for 8u which are broken out in separate commits: add the new JNI method name to a mapfile; fully qualify the use of a method name in the test.
>> 
>> the edited test passes for me.
>
> 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).

Not 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.

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

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


More information about the jdk8u-dev mailing list