]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
oomd: fix off-by-one when dumping kill candidates 23764/head
authorNick Rosbrook <nick.rosbrook@canonical.com>
Wed, 20 Jul 2022 15:16:37 +0000 (11:16 -0400)
committerNick Rosbrook <nick.rosbrook@canonical.com>
Fri, 26 Aug 2022 16:40:58 +0000 (12:40 -0400)
When we kill a cgroup that is towards the end of the sorted candidate
list (i.e. when we have to resort to killing a candidate with
ManagedOOMPreference=avoid), this cgroup is not logged in the candidate
list. This is due to an off-by-one error when assigning dump_until.

src/oom/oomd-util.c

index 8a3fb09e37efa417d3cb96a1b72f5ae4934779e7..d31d5ca62353dc9999716b65b35708b79f6cd44b 100644 (file)
@@ -323,7 +323,7 @@ int oomd_kill_by_pgscan_rate(Hashmap *h, const char *prefix, bool dry_run, char
                         continue; /* Try to find something else to kill */
                 }
 
-                dump_until = MAX(dump_until, i);
+                dump_until = MAX(dump_until, i + 1);
                 char *selected = strdup(sorted[i]->path);
                 if (!selected)
                         return -ENOMEM;
@@ -367,7 +367,7 @@ int oomd_kill_by_swap_usage(Hashmap *h, uint64_t threshold_usage, bool dry_run,
                         continue; /* Try to find something else to kill */
                 }
 
-                dump_until = MAX(dump_until, i);
+                dump_until = MAX(dump_until, i + 1);
                 char *selected = strdup(sorted[i]->path);
                 if (!selected)
                         return -ENOMEM;