From 7e252c105db5171eae451c7fefb228aeada4ea09 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 7 Apr 2024 22:42:06 +0200 Subject: [PATCH] debug output: declutter process table Before: startup_selftests: dry-running oom kill... pid 1: badness -1 VmRSS -1 uid -1 oom_score_adj -1 "systemd" pid 2: badness 0 VmRSS 0 uid 0 oom_score_adj -1 "kthreadd" pid 3: badness 0 VmRSS 0 uid 0 oom_score_adj -1 "pool_workqueue_release" pid 4: badness 0 VmRSS 0 uid 0 oom_score_adj -1 "kworker/R-rcu_g" pid 5: badness 0 VmRSS 0 uid 0 oom_score_adj -1 "kworker/R-rcu_p" pid 6: badness 0 VmRSS 0 uid 0 oom_score_adj -1 "kworker/R-slub_" After: startup_selftests: dry-running oom kill... PID OOM_SCORE RSSkiB UID OOM_SCORE_ADJ COMM 1 -1 -1 -1 -1 "systemd" 2 0 0 0 -1 "kthreadd" 3 0 0 0 -1 "pool_workqueue_release" 4 0 0 0 -1 "kworker/R-rcu_g" 5 0 0 0 -1 "kworker/R-rcu_p" 6 0 0 0 -1 "kworker/R-slub_" --- kill.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kill.c b/kill.c index c3dbe86..ce805cd 100644 --- a/kill.c +++ b/kill.c @@ -403,10 +403,15 @@ void debug_print_procinfo(procinfo_t* cur) return; } fill_informative_fields(cur); - debug("pid %5d: badness %3d VmRSS %7lld uid %4d oom_score_adj %4d \"%s\"", + debug("%5d %9d %7lld %5d %13d \"%s\"", cur->pid, cur->badness, cur->VmRSSkiB, cur->uid, cur->oom_score_adj, cur->name); } +void debug_print_procinfo_header() +{ + debug(" PID OOM_SCORE RSSkiB UID OOM_SCORE_ADJ COMM\n"); +} + /* * Find the process with the largest oom_score or rss(when flag --sort-by-rss is set). */ @@ -422,6 +427,8 @@ procinfo_t find_largest_process(const poll_loop_args_t* args) clock_gettime(CLOCK_MONOTONIC, &t0); } + debug_print_procinfo_header(); + procinfo_t victim = { 0 }; while (1) { errno = 0;