]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/service.c
core: implement OOMPolicy= and watch cgroups for OOM killings
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Mar 2019 18:05:19 +0000 (19:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Apr 2019 09:17:58 +0000 (11:17 +0200)
commitafcfaa695cd00b713e7d57e1829da90b692ac6f8
tree0f0394e7d37d4fbcdcc792cb00d22a2de1df0fc3
parenta5b5aece01f677ba59ca43001c85b722388fd67f
core: implement OOMPolicy= and watch cgroups for OOM killings

This adds a new per-service OOMPolicy= (along with a global
DefaultOOMPolicy=) that controls what to do if a process of the service
is killed by the kernel's OOM killer. It has three different values:
"continue" (old behaviour), "stop" (terminate the service), "kill" (let
the kernel kill all the service's processes).

On top of that, track OOM killer events per unit: generate a per-unit
structured, recognizable log message when we see an OOM killer event,
and put the service in a failure state if an OOM killer event was seen
and the selected policy was not "continue". A new "result" is defined
for this case: "oom-kill".

All of this relies on new cgroupv2 kernel functionality: the
"memory.events" notification interface and the "memory.oom.group"
attribute (which makes the kernel kill all cgroup processes
automatically).
17 files changed:
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-manager.c
src/core/dbus-manager.h
src/core/dbus-service.c
src/core/load-fragment-gperf.gperf.m4
src/core/load-fragment.c
src/core/load-fragment.h
src/core/main.c
src/core/manager.c
src/core/manager.h
src/core/service.c
src/core/service.h
src/core/unit.c
src/core/unit.h
src/shared/bus-unit-util.c
src/systemd/sd-messages.h