mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
oomd: fix iteration over candidates to kill
This commit is contained in:
parent
37a7e15968
commit
f94a80ab59
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user