]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
oomd: Return tristate status from oomd_cgroup_kill_mark() 40690/head
authorChris Down <chris@chrisdown.name>
Sun, 15 Feb 2026 17:31:12 +0000 (01:31 +0800)
committerChris Down <chris@chrisdown.name>
Sun, 15 Feb 2026 17:39:21 +0000 (01:39 +0800)
oomd_cgroup_kill_mark() currently returns 0 on all non-error paths. But
the manager only logs that it marked for killing on `if (r > 0)`, which
is thus unreachable.

Changing it to `r >= 0` would also be wrong, because then we would log
on no-op paths.

So let's fix this by making the return value express what actually
happened:

- < 0: failure to queue the kill state
-   0: no new mark was created (already queued or dry-run)
- > 0: a new kill state was queued

src/oom/oomd-manager.c
src/oom/oomd-util.c

index 3898ab707c3e1ba8b0e055cb7cc2f5d6bd645853..1ab7099d2ec0ef060ace6923b4aa51a4d03ca975 100644 (file)
@@ -541,9 +541,8 @@ static int monitor_memory_pressure_contexts_handler(sd_event_source *s, uint64_t
                                 log_error_errno(r, "Failed to select any cgroups under %s based on pressure, ignoring: %m", t->path);
                         else {
                                 /* Don't act on all the high pressure cgroups at once; return as soon as we kill one.
-                                 * If r == 0 then it means there were not eligible candidates, the candidate cgroup
-                                 * disappeared, or the candidate cgroup has no processes by the time we tried to kill
-                                 * it. In either case, go through the event loop again and select a new candidate if
+                                 * If r == 0 then the cgroup is already queued for kill by an earlier iteration.
+                                 * In either case, go through the event loop again and select a new candidate if
                                  * pressure is still high. */
                                 m->mem_pressure_post_action_delay_start = usec_now;
                                 if (selected && r > 0) {
index 97803a842840ebb0cac5abb7ed0e6fb49ffbba89..b044989ab3b741b7f78e5daeb95229712e1368d5 100644 (file)
@@ -507,7 +507,7 @@ int oomd_cgroup_kill_mark(Manager *m, OomdCGroupContext *ctx) {
         if (r < 0)
                 log_warning_errno(r, "oomd prekill hook failed for %s, ignoring: %m", ctx->path);
 
-        return 0;
+        return 1;
 }
 
 typedef void (*dump_candidate_func)(const OomdCGroupContext *ctx, FILE *f, const char *prefix);