mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8250984: Memory Docker tests fail on some Linux kernels w/o cgroupv1 …
Reviewed-by: bobv, sgehwolf
This commit is contained in:
parent
a75edc29c6
commit
0187567704
8 changed files with 103 additions and 58 deletions
|
@ -28,6 +28,7 @@ package jdk.internal.platform.cgroupv1;
|
|||
public class CgroupV1MemorySubSystemController extends CgroupV1SubsystemController {
|
||||
|
||||
private boolean hierarchical;
|
||||
private boolean swapenabled;
|
||||
|
||||
public CgroupV1MemorySubSystemController(String root, String mountPoint) {
|
||||
super(root, mountPoint);
|
||||
|
@ -41,4 +42,11 @@ public class CgroupV1MemorySubSystemController extends CgroupV1SubsystemControll
|
|||
this.hierarchical = hierarchical;
|
||||
}
|
||||
|
||||
}
|
||||
boolean isSwapEnabled() {
|
||||
return swapenabled;
|
||||
}
|
||||
|
||||
void setSwapEnabled(boolean swapenabled) {
|
||||
this.swapenabled = swapenabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,6 +199,8 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
|
|||
CgroupV1MemorySubSystemController memorySubSystem = (CgroupV1MemorySubSystemController)controller;
|
||||
boolean isHierarchial = getHierarchical(memorySubSystem);
|
||||
memorySubSystem.setHierarchical(isHierarchial);
|
||||
boolean isSwapEnabled = getSwapEnabled(memorySubSystem);
|
||||
memorySubSystem.setSwapEnabled(isSwapEnabled);
|
||||
}
|
||||
subsystem.setActiveSubSystems();
|
||||
}
|
||||
|
@ -208,6 +210,12 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
|
|||
}
|
||||
|
||||
|
||||
private static boolean getSwapEnabled(CgroupV1MemorySubSystemController controller) {
|
||||
long retval = getLongValue(controller, "memory.memsw.limit_in_bytes");
|
||||
return retval > 0;
|
||||
}
|
||||
|
||||
|
||||
private static boolean getHierarchical(CgroupV1MemorySubSystemController controller) {
|
||||
long hierarchical = getLongValue(controller, "memory.use_hierarchy");
|
||||
return hierarchical > 0;
|
||||
|
@ -438,10 +446,16 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
|
|||
}
|
||||
|
||||
public long getMemoryAndSwapFailCount() {
|
||||
if (!memory.isSwapEnabled()) {
|
||||
return getMemoryFailCount();
|
||||
}
|
||||
return getLongValue(memory, "memory.memsw.failcnt");
|
||||
}
|
||||
|
||||
public long getMemoryAndSwapLimit() {
|
||||
if (!memory.isSwapEnabled()) {
|
||||
return getMemoryLimit();
|
||||
}
|
||||
long retval = getLongValue(memory, "memory.memsw.limit_in_bytes");
|
||||
if (retval > CgroupV1SubsystemController.UNLIMITED_MIN) {
|
||||
if (memory.isHierarchical()) {
|
||||
|
@ -457,10 +471,16 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
|
|||
}
|
||||
|
||||
public long getMemoryAndSwapMaxUsage() {
|
||||
if (!memory.isSwapEnabled()) {
|
||||
return getMemoryMaxUsage();
|
||||
}
|
||||
return getLongValue(memory, "memory.memsw.max_usage_in_bytes");
|
||||
}
|
||||
|
||||
public long getMemoryAndSwapUsage() {
|
||||
if (!memory.isSwapEnabled()) {
|
||||
return getMemoryUsage();
|
||||
}
|
||||
return getLongValue(memory, "memory.memsw.usage_in_bytes");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue