summaryrefslogtreecommitdiff
path: root/src/oom/oomd-util.c
diff options
context:
space:
mode:
authorNick Rosbrook <nick.rosbrook@canonical.com>2022-07-20 11:16:37 -0400
committerNick Rosbrook <nick.rosbrook@canonical.com>2022-08-26 12:40:58 -0400
commitb814de305445f59baa289ab926cbe6ca05ac26a4 (patch)
tree8d6a9a4c3a111e821bd4b99615c98871a8b1f7c4 /src/oom/oomd-util.c
parent58b2f0d1f578f4209e97f1f6c4bbe9c7c2aeb334 (diff)
downloadsystemd-b814de305445f59baa289ab926cbe6ca05ac26a4.tar.gz
oomd: fix off-by-one when dumping kill candidates
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.
Diffstat (limited to 'src/oom/oomd-util.c')
-rw-r--r--src/oom/oomd-util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c
index 8a3fb09e37..d31d5ca623 100644
--- a/src/oom/oomd-util.c
+++ b/src/oom/oomd-util.c
@@ -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;