-
Notifications
You must be signed in to change notification settings - Fork 935
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
Container: Do not set "soft" limit when hard limit is set for cgroupv2 #13192
Container: Do not set "soft" limit when hard limit is set for cgroupv2 #13192
Conversation
…is set In cgroup-v1 memcg implementation we have a concept of "soft" memory limit (`memory.soft_limit_in_bytes`). In cgroup-v2 memcg we don't have an explicit analog of it. Originally, when hard memory limit is set, we set it value to `memory.limit_in_bytes` and set 90% of its value to `memory.soft_limit_in_bytes`. And it was working quite well. But in cgroup-v2 we tried to treat `memory.high` as analogy to `memory.soft_limit_in_bytes` which is not fully correct. Yes, reaching `memory.high` limit does not invoke OOM-killer, at the same time it forces process to go into memory reclaim on each page fault that want's to charge pages in memcg which makes its execution terribly slow. Let's stop doing that. If hard limit is set, let's set only `memory.max` value and do nothing with `memory.high`. But if soft limit is set, then we have not so many options and let's stick with setting `memory.high` value. Fixes: canonical#13147 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
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.
LGTM, thanks!
@mihalicyn how hard would it be to add tests for that? Our GHA runners are all cgroup2 ready. |
yeah we should add a test |
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Test is ready canonical/lxd-ci#107 ;-) |
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.
Thanks!
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
canonical/lxd#13192 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
In cgroup-v1 memcg implementation we have a concept of "soft" memory limit (
memory.soft_limit_in_bytes
). In cgroup-v2 memcg we don't have an explicit analog of it. Originally, when hard memory limit is set, we set it value tomemory.limit_in_bytes
and set 90% of its value tomemory.soft_limit_in_bytes
. And it was working quite well. But in cgroup-v2 we tried to treatmemory.high
as analogy tomemory.soft_limit_in_bytes
which is not fully correct. Yes, reachingmemory.high
limit does not invoke OOM-killer, at the same time it forces process to go into memory reclaim on each page fault that want's to charge pages in memcg which makes its execution terribly slow. Let's stop doing that. If hard limit is set, let's set onlymemory.max
value and do nothing withmemory.high
. But if soft limit is set, then we have not so many options and let's stick with settingmemory.high
value.Fixes: #13147