aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2009-12-15 19:45:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 10:19:57 -0500
commit3b4798cbc13dd8d1150aa6377f97f0e11450a67d (patch)
tree3a805cae1557098ddd4386fd6117f4f0fde5123f /mm/oom_kill.c
parent8bea8672edfca7ec5f661cafb218f1205863b343 (diff)
oom-kill: show virtual size and rss information of the killed process
In a typical oom analysis scenario, we frequently want to know whether the killed process has a memory leak or not at the first step. This patch adds vsz and rss information to the oom log to help this analysis. To save time for the debugging. example: =================================================================== rsyslogd invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0 Pid: 1308, comm: rsyslogd Not tainted 2.6.32-rc6 #24 Call Trace: [<ffffffff8132e35b>] ?_spin_unlock+0x2b/0x40 [<ffffffff810f186e>] oom_kill_process+0xbe/0x2b0 (snip) 492283 pages non-shared Out of memory: kill process 2341 (memhog) score 527276 or a child Killed process 2341 (memhog) vsz:1054552kB, anon-rss:970588kB, file-rss:4kB =========================================================================== ^ | here [rientjes@google.com: fix race, add pid & comm to message] Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 492c98624fc1..6bb8a7a7ec9a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -352,6 +352,8 @@ static void dump_header(gfp_t gfp_mask, int order, struct mem_cgroup *mem)
352 dump_tasks(mem); 352 dump_tasks(mem);
353} 353}
354 354
355#define K(x) ((x) << (PAGE_SHIFT-10))
356
355/* 357/*
356 * Send SIGKILL to the selected process irrespective of CAP_SYS_RAW_IO 358 * Send SIGKILL to the selected process irrespective of CAP_SYS_RAW_IO
357 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO 359 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO
@@ -365,15 +367,23 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
365 return; 367 return;
366 } 368 }
367 369
370 task_lock(p);
368 if (!p->mm) { 371 if (!p->mm) {
369 WARN_ON(1); 372 WARN_ON(1);
370 printk(KERN_WARNING "tried to kill an mm-less task!\n"); 373 printk(KERN_WARNING "tried to kill an mm-less task %d (%s)!\n",
374 task_pid_nr(p), p->comm);
375 task_unlock(p);
371 return; 376 return;
372 } 377 }
373 378
374 if (verbose) 379 if (verbose)
375 printk(KERN_ERR "Killed process %d (%s)\n", 380 printk(KERN_ERR "Killed process %d (%s) "
376 task_pid_nr(p), p->comm); 381 "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
382 task_pid_nr(p), p->comm,
383 K(p->mm->total_vm),
384 K(get_mm_counter(p->mm, anon_rss)),
385 K(get_mm_counter(p->mm, file_rss)));
386 task_unlock(p);
377 387
378 /* 388 /*
379 * We give our sacrificial lamb high priority and access to 389 * We give our sacrificial lamb high priority and access to