8253714: [cgroups v2] Soft memory limit incorrectly using memory.high

The early implementation of cgroups v2 support was done with
crun 0.8 and it contained a bug which set memory.high over
memory.low when --memory-reservation was being used as a CLI
option.

This bug has been fixed in later crun versions, starting with
crun 0.11. Use memory.low in OpenJDK as well.

Reviewed-by: bobv, adinn
This commit is contained in:
Severin Gehwolf 2020-09-29 15:15:50 +00:00
parent d5be82948b
commit ff6843ca48
3 changed files with 4 additions and 4 deletions
src
hotspot/os/linux
java.base/linux/classes/jdk/internal/platform/cgroupv2
test/lib/jdk/test/lib/containers/cgroup

@ -149,7 +149,7 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() {
}
char* CgroupV2Subsystem::mem_soft_limit_val() {
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.high",
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low",
"Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024);
if (mem_soft_limit_str == NULL) {
return NULL;

@ -287,7 +287,7 @@ public class CgroupV2Subsystem implements CgroupSubsystem {
@Override
public long getMemorySoftLimit() {
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.high");
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.low");
return limitFromString(softLimitStr);
}

@ -252,9 +252,9 @@ public class MetricsTesterCgroupV2 implements CgroupMetricsTester {
}
oldVal = metrics.getMemorySoftLimit();
newVal = getLongLimitValueFromFile("memory.high");
newVal = getLongLimitValueFromFile("memory.low");
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
fail("memory.high", oldVal, newVal);
fail("memory.low", oldVal, newVal);
}
}