aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2009-12-14 20:57:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:10 -0500
commit1b604d75bbb6e28628c5a95a433432973c33d581 (patch)
treef5022972180a0dab66744eb6278ea57b869447e4
parent5ce45962b26ae867e98e60177f62f9695b49a936 (diff)
oom: dump stack and VM state when oom killer panics
The oom killer header, including information such as the allocation order and gfp mask, current's cpuset and memory controller, call trace, and VM state information is currently only shown when the oom killer has selected a task to kill. This information is omitted, however, when the oom killer panics either because of panic_on_oom sysctl settings or when no killable task was found. It is still relevant to know crucial pieces of information such as the allocation order and VM state when diagnosing such issues, especially at boot. This patch displays the oom killer header whenever it panics so that bug reports can include pertinent information to debug the issue, if possible. Signed-off-by: David Rientjes <rientjes@google.com> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/oom_kill.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index ea2147dabba6..492c98624fc1 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -337,6 +337,21 @@ static void dump_tasks(const struct mem_cgroup *mem)
337 } while_each_thread(g, p); 337 } while_each_thread(g, p);
338} 338}
339 339
340static void dump_header(gfp_t gfp_mask, int order, struct mem_cgroup *mem)
341{
342 pr_warning("%s invoked oom-killer: gfp_mask=0x%x, order=%d, "
343 "oom_adj=%d\n",
344 current->comm, gfp_mask, order, current->signal->oom_adj);
345 task_lock(current);
346 cpuset_print_task_mems_allowed(current);
347 task_unlock(current);
348 dump_stack();
349 mem_cgroup_print_oom_info(mem, current);
350 show_mem();
351 if (sysctl_oom_dump_tasks)
352 dump_tasks(mem);
353}
354
340/* 355/*
341 * Send SIGKILL to the selected process irrespective of CAP_SYS_RAW_IO 356 * Send SIGKILL to the selected process irrespective of CAP_SYS_RAW_IO
342 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO 357 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO
@@ -395,20 +410,8 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
395{ 410{
396 struct task_struct *c; 411 struct task_struct *c;
397 412
398 if (printk_ratelimit()) { 413 if (printk_ratelimit())
399 printk(KERN_WARNING "%s invoked oom-killer: " 414 dump_header(gfp_mask, order, mem);
400 "gfp_mask=0x%x, order=%d, oom_adj=%d\n",
401 current->comm, gfp_mask, order,
402 current->signal->oom_adj);
403 task_lock(current);
404 cpuset_print_task_mems_allowed(current);
405 task_unlock(current);
406 dump_stack();
407 mem_cgroup_print_oom_info(mem, current);
408 show_mem();
409 if (sysctl_oom_dump_tasks)
410 dump_tasks(mem);
411 }
412 415
413 /* 416 /*
414 * If the task is already exiting, don't alarm the sysadmin or kill 417 * If the task is already exiting, don't alarm the sysadmin or kill
@@ -544,6 +547,7 @@ retry:
544 /* Found nothing?!?! Either we hang forever, or we panic. */ 547 /* Found nothing?!?! Either we hang forever, or we panic. */
545 if (!p) { 548 if (!p) {
546 read_unlock(&tasklist_lock); 549 read_unlock(&tasklist_lock);
550 dump_header(gfp_mask, order, NULL);
547 panic("Out of memory and no killable processes...\n"); 551 panic("Out of memory and no killable processes...\n");
548 } 552 }
549 553
@@ -609,8 +613,10 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
609 /* Got some memory back in the last second. */ 613 /* Got some memory back in the last second. */
610 return; 614 return;
611 615
612 if (sysctl_panic_on_oom == 2) 616 if (sysctl_panic_on_oom == 2) {
617 dump_header(gfp_mask, order, NULL);
613 panic("out of memory. Compulsory panic_on_oom is selected.\n"); 618 panic("out of memory. Compulsory panic_on_oom is selected.\n");
619 }
614 620
615 /* 621 /*
616 * Check if there were limitations on the allocation (only relevant for 622 * Check if there were limitations on the allocation (only relevant for
@@ -626,8 +632,10 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
626 break; 632 break;
627 633
628 case CONSTRAINT_NONE: 634 case CONSTRAINT_NONE:
629 if (sysctl_panic_on_oom) 635 if (sysctl_panic_on_oom) {
636 dump_header(gfp_mask, order, NULL);
630 panic("out of memory. panic_on_oom is selected\n"); 637 panic("out of memory. panic_on_oom is selected\n");
638 }
631 /* Fall-through */ 639 /* Fall-through */
632 case CONSTRAINT_CPUSET: 640 case CONSTRAINT_CPUSET:
633 __out_of_memory(gfp_mask, order); 641 __out_of_memory(gfp_mask, order);