Skip to content

Commit

Permalink
is_larger: --sort-by-rss: handle zombie main thread
Browse files Browse the repository at this point in the history
Estimate rss in this case.
  • Loading branch information
rfjakob committed Mar 20, 2024
1 parent d6185b6 commit d4f8c74
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ bool is_larger(const poll_loop_args_t* args, const meminfo_t* m, const procinfo_

if (args->sort_by_rss) {
/* find process with the largest rss */

// Zombie main thread or other shenanigans?
if (cur->VmRSSkiB == 0 && cur->badness > 0) {
// Acc. to https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/proc/base.c?h=v6.8#n561
// oom_score goes from 0 to 2000.
cur->VmRSSkiB = (m->MemTotalKiB + m->SwapTotalKiB) * cur->badness / 2000;
warn("%s pid %d: rss=0 but oom_score=%d. Zombie main thread? Estimating rss=%lld\n",
__func__, cur->pid, cur->badness, cur->VmRSSkiB);
}

if (cur->VmRSSkiB < victim->VmRSSkiB) {
return false;
}
Expand Down

0 comments on commit d4f8c74

Please sign in to comment.