summaryrefslogtreecommitdiff
path: root/src/oom
diff options
context:
space:
mode:
authorNishal Kulkarni <nishalkulkarni@gmail.com>2022-03-14 00:35:18 +0530
committerNishal Kulkarni <nishalkulkarni@gmail.com>2022-03-22 17:57:59 +0530
commit38c41427c7ee9a6209b84e7b17b1df5774d8f1ed (patch)
treed158d3034c88b278b10de3624b46d0ed794b268f /src/oom
parentf7829525be46ddeddcbac39d7f31b12fae52cb5e (diff)
downloadsystemd-38c41427c7ee9a6209b84e7b17b1df5774d8f1ed.tar.gz
core/oomd: Use oom-kill ServiceResult for oomd
To notify user of kill events from systemd-oomd we now use `SERVICE_FAILURE_OOM_KILL` as the failure result. `unit_check_oomd_kill` now calls `notify_cgroup_oom` to update the service result to `oom-kill`. We add a new xattr `user.oomd_ooms` to keep track of the OOM kills initiated by systemd-oomd, this helps us resolve a race between sending SIGKILL to processes and checking for OOM kill status from the xattr. Related to: #20649
Diffstat (limited to 'src/oom')
-rw-r--r--src/oom/oomd-util.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c
index 77718d9c9e..a135824c53 100644
--- a/src/oom/oomd-util.c
+++ b/src/oom/oomd-util.c
@@ -192,6 +192,10 @@ int oomd_cgroup_kill(const char *path, bool recurse, bool dry_run) {
if (!pids_killed)
return -ENOMEM;
+ r = increment_oomd_xattr(path, "user.oomd_ooms", 1);
+ if (r < 0)
+ log_debug_errno(r, "Failed to set user.oomd_ooms before kill: %m");
+
if (recurse)
r = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, path, SIGKILL, CGROUP_IGNORE_SELF, pids_killed, log_kill, NULL);
else