RFR: 8292541: [Metrics] Reported memory limit may exceed physical machine memory [v3]

Severin Gehwolf sgehwolf at openjdk.org
Thu Aug 25 14:03:51 UTC 2022


On Thu, 25 Aug 2022 12:35:13 GMT, Jonathan Dowland <jdowland at openjdk.org> wrote:

>> When the container memory exceeds the physical host's memory, the Java metrics reporting is wrong.
>> 
>> https://bugs.openjdk.org/browse/JDK-8292541
>> 
>> This is the equivalent core-libs fix for Hotspot's [JDK-8292083](https://bugs.openjdk.org/browse/JDK-8292083)
>> (https://github.com/openjdk/jdk/pull/9880)
>
> Jonathan Dowland has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address nit
>   
>   Thanks Thomas Stuefe

src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java line 124:

> 122:     @Override
> 123:     public long getMemoryLimit() {
> 124:         long subs_mem = subsystem.getMemoryLimit();

Style nit: `subsMem` camelcase ;-)

src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java line 126:

> 124:         long subs_mem = subsystem.getMemoryLimit();
> 125:         // Catch the cgroup memory limit exceeding host physical memory.
> 126:         // treat this as unlimited.

Nit: capital `T`.

src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java line 128:

> 126:         // treat this as unlimited.
> 127:         if (subs_mem >= getTotalMemorySize0()) {
> 128:             return -1;

Please use `CgroupSubsystem.LONG_RETVAL_UNLIMITED` instead of this magic number.

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

PR: https://git.openjdk.org/jdk/pull/10017


More information about the core-libs-dev mailing list