mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8299858: [Metrics] Swap memory limit reported incorrectly when too large
Reviewed-by: stuefe
This commit is contained in:
parent
28545dcf2b
commit
64ddf9536f
3 changed files with 67 additions and 3 deletions
|
@ -122,9 +122,11 @@ public class CgroupMetrics implements Metrics {
|
|||
@Override
|
||||
public long getMemoryLimit() {
|
||||
long subsMem = subsystem.getMemoryLimit();
|
||||
long systemTotal = getTotalMemorySize0();
|
||||
assert(systemTotal > 0);
|
||||
// Catch the cgroup memory limit exceeding host physical memory.
|
||||
// Treat this as unlimited.
|
||||
if (subsMem >= getTotalMemorySize0()) {
|
||||
if (subsMem >= systemTotal) {
|
||||
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
|
||||
}
|
||||
return subsMem;
|
||||
|
@ -142,7 +144,15 @@ public class CgroupMetrics implements Metrics {
|
|||
|
||||
@Override
|
||||
public long getMemoryAndSwapLimit() {
|
||||
return subsystem.getMemoryAndSwapLimit();
|
||||
long totalSystemMemSwap = getTotalMemorySize0() + getTotalSwapSize0();
|
||||
assert(totalSystemMemSwap > 0);
|
||||
// Catch the cgroup memory and swap limit exceeding host physical swap
|
||||
// and memory. Treat this case as unlimited.
|
||||
long subsSwapMem = subsystem.getMemoryAndSwapLimit();
|
||||
if (subsSwapMem >= totalSystemMemSwap) {
|
||||
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
|
||||
}
|
||||
return subsSwapMem;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -185,5 +195,6 @@ public class CgroupMetrics implements Metrics {
|
|||
|
||||
private static native boolean isUseContainerSupport();
|
||||
private static native long getTotalMemorySize0();
|
||||
private static native long getTotalSwapSize0();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue