Skip to content

Commit 633acfa

Browse files
author
Jonathan Dowland
committedDec 7, 2022
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: andrew Backport-of: ff6843ca4842498791061f924c545fa9469cc1dc
1 parent 40e7b68 commit 633acfa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed
 

‎hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() {
161161
}
162162

163163
char* CgroupV2Subsystem::mem_soft_limit_val() {
164-
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.high",
164+
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low",
165165
"Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024);
166166
if (mem_soft_limit_str == NULL) {
167167
return NULL;

‎jdk/src/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public long getMemoryAndSwapUsage() {
292292

293293
@Override
294294
public long getMemorySoftLimit() {
295-
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.high");
295+
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.low");
296296
return limitFromString(softLimitStr);
297297
}
298298

‎jdk/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ public void testMemorySubsystem() {
245245
}
246246

247247
oldVal = metrics.getMemorySoftLimit();
248-
newVal = getLongLimitValueFromFile("memory.high");
248+
newVal = getLongLimitValueFromFile("memory.low");
249249
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
250-
fail("memory.high", oldVal, newVal);
250+
fail("memory.low", oldVal, newVal);
251251
}
252252

253253
}

0 commit comments

Comments
 (0)
Please sign in to comment.