diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-03-30 14:45:22 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-03-30 14:45:22 +0200 |
commit | f94a80ab59a30330ac1409fac030c9d41d5158b8 (patch) | |
tree | eea230db7f3f31c98577424dad6d075e50638104 /src/oom | |
parent | oomd: make it more clear when a kill happens (diff) | |
download | systemd-f94a80ab59a30330ac1409fac030c9d41d5158b8.tar.xz systemd-f94a80ab59a30330ac1409fac030c9d41d5158b8.zip |
oomd: fix iteration over candidates to kill
Diffstat (limited to 'src/oom')
-rw-r--r-- | src/oom/oomd-util.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c index da994848ae..894d23a83a 100644 --- a/src/oom/oomd-util.c +++ b/src/oom/oomd-util.c @@ -210,16 +210,16 @@ int oomd_cgroup_kill(const char *path, bool recurse, bool dry_run) { int oomd_kill_by_pgscan_rate(Hashmap *h, const char *prefix, bool dry_run, char **ret_selected) { _cleanup_free_ OomdCGroupContext **sorted = NULL; - int r, ret = 0; + int n, r, ret = 0; assert(h); assert(ret_selected); - r = oomd_sort_cgroup_contexts(h, compare_pgscan_rate_and_memory_usage, prefix, &sorted); - if (r < 0) - return r; + n = oomd_sort_cgroup_contexts(h, compare_pgscan_rate_and_memory_usage, prefix, &sorted); + if (n < 0) + return n; - for (int i = 0; i < r; i++) { + for (int i = 0; i < n; i++) { /* Skip cgroups with no reclaim and memory usage; it won't alleviate pressure. * Continue since there might be "avoid" cgroups at the end. */ if (sorted[i]->pgscan == 0 && sorted[i]->current_memory_usage == 0) @@ -248,18 +248,18 @@ int oomd_kill_by_pgscan_rate(Hashmap *h, const char *prefix, bool dry_run, char int oomd_kill_by_swap_usage(Hashmap *h, bool dry_run, char **ret_selected) { _cleanup_free_ OomdCGroupContext **sorted = NULL; - int r, ret = 0; + int n, r, ret = 0; assert(h); assert(ret_selected); - r = oomd_sort_cgroup_contexts(h, compare_swap_usage, NULL, &sorted); - if (r < 0) - return r; + n = oomd_sort_cgroup_contexts(h, compare_swap_usage, NULL, &sorted); + if (n < 0) + return n; /* Try to kill cgroups with non-zero swap usage until we either succeed in * killing or we get to a cgroup with no swap usage. */ - for (int i = 0; i < r; i++) { + for (int i = 0; i < n; i++) { /* Skip over cgroups with no resource usage. * Continue break since there might be "avoid" cgroups at the end. */ if (sorted[i]->swap_usage == 0) |