Skip to content

Commit ff6843c

Browse files
committed
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
1 parent d5be829 commit ff6843c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() {
149149
}
150150

151151
char* CgroupV2Subsystem::mem_soft_limit_val() {
152-
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.high",
152+
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low",
153153
"Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024);
154154
if (mem_soft_limit_str == NULL) {
155155
return NULL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public long getMemoryAndSwapUsage() {
287287

288288
@Override
289289
public long getMemorySoftLimit() {
290-
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.high");
290+
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.low");
291291
return limitFromString(softLimitStr);
292292
}
293293

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ public void testMemorySubsystem() {
252252
}
253253

254254
oldVal = metrics.getMemorySoftLimit();
255-
newVal = getLongLimitValueFromFile("memory.high");
255+
newVal = getLongLimitValueFromFile("memory.low");
256256
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
257-
fail("memory.high", oldVal, newVal);
257+
fail("memory.low", oldVal, newVal);
258258
}
259259

260260
}

0 commit comments

Comments
 (0)