RFR: 8292541: [Metrics] Reported memory limit may exceed physical machine memory [v6]
Jonathan Dowland
jdowland at openjdk.org
Fri Aug 26 13:20:58 UTC 2022
> 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.
-------------
Changes: https://git.openjdk.org/jdk/pull/10017/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10017&range=05
Stats: 60 lines in 3 files changed: 46 ins; 9 del; 5 mod
Patch: https://git.openjdk.org/jdk/pull/10017.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10017/head:pull/10017
PR: https://git.openjdk.org/jdk/pull/10017
More information about the core-libs-dev
mailing list