Skip to content

Commit

Permalink
is_larger: move get_oom_score after kernel thread check
Browse files Browse the repository at this point in the history
This allows us to skip get_oom_score for all kernel threads.
  • Loading branch information
rfjakob committed Apr 8, 2024
1 parent 7d8a5af commit 4c90316
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,6 @@ bool is_larger(const poll_loop_args_t* args, const procinfo_t* victim, procinfo_
}
}

{
int res = get_oom_score(cur->pid);
if (res < 0) {
debug("%s: pid %d: error reading oom_score: %s\n", __func__, cur->pid, strerror(-res));
return false;
}
cur->badness = res;
}

{
bool res = parse_proc_pid_stat(&cur->stat, cur->pid);
if (!res) {
Expand All @@ -314,6 +305,15 @@ bool is_larger(const poll_loop_args_t* args, const procinfo_t* victim, procinfo_
return false;
}

{
int res = get_oom_score(cur->pid);
if (res < 0) {
debug("%s: pid %d: error reading oom_score: %s\n", __func__, cur->pid, strerror(-res));
return false;
}
cur->badness = res;
}

if ((args->prefer_regex || args->avoid_regex || args->ignore_regex)) {
int res = get_comm(cur->pid, cur->name, sizeof(cur->name));
if (res < 0) {
Expand Down

0 comments on commit 4c90316

Please sign in to comment.