aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalasubramani Vivekanandan <balu252@gmail.com>2015-04-14 18:48:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:05 -0400
commit2415b9f5cb048a803b30b790af994ba71ff0bd4c (patch)
tree616a11b2a493045bee0c5e963ccdfc00c9d64d7c
parent2a8e70026435ad97570a1e0a0c4c941e0f700a3e (diff)
memcg: print cgroup information when system panics due to panic_on_oom
If kernel panics due to oom, caused by a cgroup reaching its limit, when 'compulsory panic_on_oom' is enabled, then we will only see that the OOM happened because of "compulsory panic_on_oom is enabled" but this doesn't tell the difference between mempolicy and memcg. And dumping system wide information is plain wrong and more confusing. This patch provides the information of the cgroup whose limit triggerred panic Signed-off-by: Balasubramani Vivekanandan <balasubramani_vivekanandan@mentor.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/oom.h3
-rw-r--r--mm/memcontrol.c16
-rw-r--r--mm/oom_kill.c7
3 files changed, 15 insertions, 11 deletions
diff --git a/include/linux/oom.h b/include/linux/oom.h
index d5771bed59c9..44b2f6f7bbd8 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -66,7 +66,8 @@ extern bool oom_zonelist_trylock(struct zonelist *zonelist, gfp_t gfp_flags);
66extern void oom_zonelist_unlock(struct zonelist *zonelist, gfp_t gfp_flags); 66extern void oom_zonelist_unlock(struct zonelist *zonelist, gfp_t gfp_flags);
67 67
68extern void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask, 68extern void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask,
69 int order, const nodemask_t *nodemask); 69 int order, const nodemask_t *nodemask,
70 struct mem_cgroup *memcg);
70 71
71extern enum oom_scan_t oom_scan_process_thread(struct task_struct *task, 72extern enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
72 unsigned long totalpages, const nodemask_t *nodemask, 73 unsigned long totalpages, const nodemask_t *nodemask,
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f227786e73db..c3f09b2dda5f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1442,15 +1442,17 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
1442 struct mem_cgroup *iter; 1442 struct mem_cgroup *iter;
1443 unsigned int i; 1443 unsigned int i;
1444 1444
1445 if (!p)
1446 return;
1447
1448 mutex_lock(&oom_info_lock); 1445 mutex_lock(&oom_info_lock);
1449 rcu_read_lock(); 1446 rcu_read_lock();
1450 1447
1451 pr_info("Task in "); 1448 if (p) {
1452 pr_cont_cgroup_path(task_cgroup(p, memory_cgrp_id)); 1449 pr_info("Task in ");
1453 pr_cont(" killed as a result of limit of "); 1450 pr_cont_cgroup_path(task_cgroup(p, memory_cgrp_id));
1451 pr_cont(" killed as a result of limit of ");
1452 } else {
1453 pr_info("Memory limit reached of cgroup ");
1454 }
1455
1454 pr_cont_cgroup_path(memcg->css.cgroup); 1456 pr_cont_cgroup_path(memcg->css.cgroup);
1455 pr_cont("\n"); 1457 pr_cont("\n");
1456 1458
@@ -1537,7 +1539,7 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
1537 return; 1539 return;
1538 } 1540 }
1539 1541
1540 check_panic_on_oom(CONSTRAINT_MEMCG, gfp_mask, order, NULL); 1542 check_panic_on_oom(CONSTRAINT_MEMCG, gfp_mask, order, NULL, memcg);
1541 totalpages = mem_cgroup_get_limit(memcg) ? : 1; 1543 totalpages = mem_cgroup_get_limit(memcg) ? : 1;
1542 for_each_mem_cgroup_tree(iter, memcg) { 1544 for_each_mem_cgroup_tree(iter, memcg) {
1543 struct css_task_iter it; 1545 struct css_task_iter it;
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 642f38cb175a..52628c819bf7 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -612,7 +612,8 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
612 * Determines whether the kernel must panic because of the panic_on_oom sysctl. 612 * Determines whether the kernel must panic because of the panic_on_oom sysctl.
613 */ 613 */
614void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask, 614void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask,
615 int order, const nodemask_t *nodemask) 615 int order, const nodemask_t *nodemask,
616 struct mem_cgroup *memcg)
616{ 617{
617 if (likely(!sysctl_panic_on_oom)) 618 if (likely(!sysctl_panic_on_oom))
618 return; 619 return;
@@ -625,7 +626,7 @@ void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask,
625 if (constraint != CONSTRAINT_NONE) 626 if (constraint != CONSTRAINT_NONE)
626 return; 627 return;
627 } 628 }
628 dump_header(NULL, gfp_mask, order, NULL, nodemask); 629 dump_header(NULL, gfp_mask, order, memcg, nodemask);
629 panic("Out of memory: %s panic_on_oom is enabled\n", 630 panic("Out of memory: %s panic_on_oom is enabled\n",
630 sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide"); 631 sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide");
631} 632}
@@ -740,7 +741,7 @@ static void __out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
740 constraint = constrained_alloc(zonelist, gfp_mask, nodemask, 741 constraint = constrained_alloc(zonelist, gfp_mask, nodemask,
741 &totalpages); 742 &totalpages);
742 mpol_mask = (constraint == CONSTRAINT_MEMORY_POLICY) ? nodemask : NULL; 743 mpol_mask = (constraint == CONSTRAINT_MEMORY_POLICY) ? nodemask : NULL;
743 check_panic_on_oom(constraint, gfp_mask, order, mpol_mask); 744 check_panic_on_oom(constraint, gfp_mask, order, mpol_mask, NULL);
744 745
745 if (sysctl_oom_kill_allocating_task && current->mm && 746 if (sysctl_oom_kill_allocating_task && current->mm &&
746 !oom_unkillable_task(current, NULL, nodemask) && 747 !oom_unkillable_task(current, NULL, nodemask) &&