From 38c41427c7ee9a6209b84e7b17b1df5774d8f1ed Mon Sep 17 00:00:00 2001 From: Nishal Kulkarni Date: Mon, 14 Mar 2022 00:35:18 +0530 Subject: 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 --- src/oom/oomd-util.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/oom') 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 -- cgit v1.2.1