]> git.ipfire.org Git - thirdparty/systemd.git/commit
oom: implement avoid/omit xattr support
authorAnita Zhang <the.anitazha@gmail.com>
Tue, 9 Feb 2021 09:47:34 +0000 (01:47 -0800)
committerAnita Zhang <the.anitazha@gmail.com>
Tue, 9 Feb 2021 10:27:40 +0000 (02:27 -0800)
commit59331b8e292a93bc7a03a51fe54cb65a4257e894
tree3b420e7a81168b54d8a6578fd3ea52b593c2a4af
parent242d75bdaaa6f222a47148f8a83cc425d6ceefb3
oom: implement avoid/omit xattr support

There may be situations where a cgroup should be protected from killing
or deprioritized as a candidate. In FB oomd xattrs are used to bias oomd
away from supervisor cgroups and towards worker cgroups in container
tasks. On desktops this can be used to protect important units with
unpredictable resource consumption.

The patch allows systemd-oomd to understand 2 xattrs:
"user.oomd_avoid" and "user.oomd_omit". If systemd-oomd sees these
xattrs set to 1 on a candidate cgroup (i.e. while attempting to kill something)
AND the cgroup is owned by root, it will either deprioritize the cgroup as
a candidate (avoid) or remove it completely as a candidate (omit).

Usage is restricted to root owned cgroups to prevent situations where an
unprivileged user can set their own cgroups lower in the kill priority than
another user's (and prevent them from omitting their units from
systemd-oomd killing).
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/oom/oomd-util.c
src/oom/oomd-util.h
src/oom/test-oomd-util.c
test/test-functions
test/units/testsuite-56-testmunch.service [new file with mode: 0644]
test/units/testsuite-56.sh