Skip to content

Commit

Permalink
8253714: [cgroups v2] Soft memory limit incorrectly using memory.high
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jonathan Dowland committed Dec 7, 2022
1 parent 40e7b68 commit 633acfa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public long getMemoryAndSwapUsage() {

@Override
public long getMemorySoftLimit() {
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.high");
String softLimitStr = CgroupSubsystemController.getStringValue(unified, "memory.low");
return limitFromString(softLimitStr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ public void testMemorySubsystem() {
}

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);
}

}
Expand Down

1 comment on commit 633acfa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.