On Fri, 26 Aug 2022 13:20:58 GMT, Jonathan Dowland <jdowl...@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 with a new target base due to a 
> merge or a rebase. The pull request now contains ten commits:
> 
>  - Rework testContainerMemExceedsPhysical to use common hostMaxMem
>    
>    For 8292541, I wrote two further tests that used the same technique
>    as testContainerMemExceedsPhysical to establish baseline physical
>    RAM. Rework testContainerMemExceedsPhysical to use the shared
>    variable hostMaxMem rather than recalculate the value itself.
>  - Merge remote-tracking branch 'origin/master' into 8292541-cgroup-metrics
>  - Add a log-line for total physical memory
>    
>    This is relied upon for tests in
>    test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java
>  - use pre-defined constant over magic number
>  - Address style nits
>  - Address nit
>    
>    Thanks Thomas Stuefe
>  - avoid calling subsystem.getMemoryLimit twice
>  - catch CgroupMetrics.getMemoryLimit exceeding physical RAM
>    
>    Detect when the subsystem limit exceeds physical RAM and treat
>    that situation as "unlimited".
>    
>    Add a private native method to establish physical RAM size.
>    
>    This presently is only likely to work on POSIX systems, but
>    CgroupMetrics are Linux-specific. None the less the precise guards etc.
>    may need adjusting.
>  - Add two tests to catch deriving invalid max memory limit from cgroups
>    
>    One test for OperatingSystemMXBean and another for
>    -XshowSettings:system, which exercises the Metrics sub-system.
>    
>    extend TestMemoryAwareness to cover OperatingSystemMXBean with bad cgroup 
> memory limit
>    
>    add testMetricsIgnoresMemLimitExceedingPhysicalMemory and refactor
>    
>    Pull the code that establishes host physical max RAM out into a helper
>    function.

test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java line 93:

> 91:             
> testOperatingSystemMXBeanIgnoresMemLimitExceedingPhysicalMemory();
> 92:             testMetricsIgnoresMemLimitExceedingPhysicalMemory();
> 93:             testContainerMemExceedsPhysical();

Could we pass `hostMaxMem` to the relevant test functions as a parameter, 
instead of relying on a static variable magically being set, please? It would 
be a good symmetry to other tests.

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

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

Reply via email to