-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cgroupv2: set mem+swap to max if memory is set to max #2285
Conversation
In cgroupv1, command `runc update $ID --memory -1` sets both memory and memory+swap to -1 (aka unlimited). This was introduced by commit 18ebc51 (Reset Swap when memory is set to unlimited, Oct 19 2016). This is not the case for cgroupv2. Fix it. References: - opencontainers#1127 - moby/moby#22578 Signed-off-by: Kir Kolyshkin <[email protected]>
The motivation for this PR is to make cgroupv2 behavior in this regard compatible with v1. Whether this v1 behavior is good or not I can't yet assess. Even after reading all the discussions linked above, I still do not understand whether it is useful to have unlimited RAM but limited RAM+swap. Probably not, but I'm not quite sure. |
Do we need this for systemd driver as well? |
cc @giuseppe |
@AkihiroSuda well, systemd driver
I found both of these items today, and they both probably need to be taken care of (and I will file issues and try to fix this), but as of now, this PR fixes the issue for both fs2 and systemd drivers. |
} | ||
|
||
if memSwap != "" { | ||
if err := fscommon.WriteFile(dirPath, "memory.swap.max", memSwap); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to keep the same cgroup v1 behaviour (as the config.json file is configured for), we need to set the memory swap to requested_memory_limit - requested_swap_limit
. Since on cgroup v1 the swap limit accounts also for the memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, in this case maybe we don't need to touch swap at all, and this PR should be closed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes setting the memory.max
should be enough on cgroup v2 as the swap max should not have any effect on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but since the PR is open, I think we could use it for setting the swap limit as it is expected to work on cgroup v1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2288
This PR is wrong. Closed in favor of #2288 |
In cgroupv1, command
runc update $ID --memory -1
sets bothmemory and memory+swap to -1 (aka unlimited). This was introduced
by commit 18ebc51 (Reset Swap when memory is set to unlimited,
Oct 19 2016).
This is not the case for cgroupv2. Fix it.
References: