* [PATCH 1/2] memcg, oom: Provide more info while memcg oom happening
@ 2012-07-24 16:09 Sha Zhengju
2012-07-24 16:12 ` [PATCH 2/2] memcg, oom: Clarify some oom dump messages Sha Zhengju
0 siblings, 1 reply; 3+ messages in thread
From: Sha Zhengju @ 2012-07-24 16:09 UTC (permalink / raw)
To: linux-mm, cgroups
Cc: Sha Zhengju, kamezawa.hiroyu, akpm, mhocko, gthelen, hannes, rientjes
While memcg oom happening, the current memcg related dump information
is limited for debugging. This patch provides more detailed memcg page
statistics together with the total one while hierarchy is enabled.
Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
Cc: kamezawa.hiroyu@jp.fujitsu.com
Cc: akpm@linux-foundation.org
Cc: mhocko@suse.cz
Cc: gthelen@google.com
Cc: hannes@cmpxchg.org
Cc: rientjes@google.com
---
mm/memcontrol.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b8a347a..a3037af 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -113,6 +113,14 @@ static const char * const mem_cgroup_events_names[] = {
"pgmajfault",
};
+static const char * const mem_cgroup_lru_names[] = {
+ "inactive_anon",
+ "active_anon",
+ "inactive_file",
+ "active_file",
+ "unevictable",
+};
+
/*
* Per memcg event counter is incremented at every pagein/pageout. With THP,
* it will be incremated by the number of pages. This counter is used for
@@ -1372,6 +1380,59 @@ static void move_unlock_mem_cgroup(struct mem_cgroup *memcg,
spin_unlock_irqrestore(&memcg->move_lock, *flags);
}
+#define K(x) ((x) << (PAGE_SHIFT-10))
+static void mem_cgroup_print_oom_stat(struct mem_cgroup *memcg)
+{
+ int i;
+ struct mem_cgroup *mi;
+
+ printk(KERN_INFO "Memory cgroup stat:\n");
+ for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
+ if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
+ continue;
+ printk(KERN_CONT "%s:%ldKB ", mem_cgroup_stat_names[i],
+ K(mem_cgroup_read_stat(memcg, i)));
+ }
+
+ for (i = 0; i < MEM_CGROUP_EVENTS_NSTATS; i++)
+ printk(KERN_CONT "%s:%lu ", mem_cgroup_events_names[i],
+ mem_cgroup_read_events(memcg, i));
+
+ for (i = 0; i < NR_LRU_LISTS; i++)
+ printk(KERN_CONT "%s:%luKB ", mem_cgroup_lru_names[i],
+ K(mem_cgroup_nr_lru_pages(memcg, BIT(i))));
+
+ /* Dump the total statistics if hierarchy is enabled. */
+ for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
+ long long val = 0;
+
+ if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
+ continue;
+ for_each_mem_cgroup_tree(mi, memcg)
+ val += mem_cgroup_read_stat(mi, i);
+ printk(KERN_CONT "total_%s:%lldKB ", mem_cgroup_stat_names[i], K(val));
+ }
+
+ for (i = 0; i < MEM_CGROUP_EVENTS_NSTATS; i++) {
+ unsigned long long val = 0;
+
+ for_each_mem_cgroup_tree(mi, memcg)
+ val += mem_cgroup_read_events(mi, i);
+ printk(KERN_CONT "total_%s:%llu ", mem_cgroup_events_names[i], val);
+ }
+
+ for (i = 0; i < NR_LRU_LISTS; i++) {
+ unsigned long long val = 0;
+
+ for_each_mem_cgroup_tree(mi, memcg)
+ val += mem_cgroup_nr_lru_pages(mi, BIT(i));
+ printk(KERN_CONT "total_%s:%lluKB ", mem_cgroup_lru_names[i], K(val));
+ }
+
+ printk(KERN_CONT "\n");
+
+}
+
/**
* mem_cgroup_print_oom_info: Called from OOM with tasklist_lock held in read mode.
* @memcg: The memory cgroup that went over limit
@@ -1436,6 +1497,8 @@ done:
res_counter_read_u64(&memcg->memsw, RES_USAGE) >> 10,
res_counter_read_u64(&memcg->memsw, RES_LIMIT) >> 10,
res_counter_read_u64(&memcg->memsw, RES_FAILCNT));
+
+ mem_cgroup_print_oom_stat(memcg);
}
/*
@@ -4129,14 +4192,6 @@ static int memcg_numa_stat_show(struct cgroup *cont, struct cftype *cft,
}
#endif /* CONFIG_NUMA */
-static const char * const mem_cgroup_lru_names[] = {
- "inactive_anon",
- "active_anon",
- "inactive_file",
- "active_file",
- "unevictable",
-};
-
static inline void mem_cgroup_lru_names_not_uptodate(void)
{
BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] memcg, oom: Clarify some oom dump messages
2012-07-24 16:09 [PATCH 1/2] memcg, oom: Provide more info while memcg oom happening Sha Zhengju
@ 2012-07-24 16:12 ` Sha Zhengju
2012-08-01 3:55 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Sha Zhengju @ 2012-07-24 16:12 UTC (permalink / raw)
To: linux-mm, cgroups
Cc: Sha Zhengju, kamezawa.hiroyu, akpm, mhocko, gthelen, hannes, rientjes
From: Sha Zhengju <handai.szj@taobao.com>
Revise some oom dump messages to avoid misleading admin.
Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
Cc: kamezawa.hiroyu@jp.fujitsu.com
Cc: akpm@linux-foundation.org
Cc: mhocko@suse.cz
Cc: gthelen@google.com
Cc: hannes@cmpxchg.org
Cc: rientjes@google.com
---
mm/memcontrol.c | 2 +-
mm/oom_kill.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a3037af..7ce605c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1472,7 +1472,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
}
rcu_read_unlock();
- printk(KERN_INFO "Task in %s killed", memcg_name);
+ printk(KERN_INFO "Task in %s will be killed", memcg_name);
rcu_read_lock();
ret = cgroup_path(mem_cgrp, memcg_name, PATH_MAX);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index b47ed97..3fc9f99 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -471,7 +471,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
dump_header(p, gfp_mask, order, memcg, nodemask);
task_lock(p);
- pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
+ pr_err("%s: Will kill process %d (%s) score %d or sacrifice child\n",
message, task_pid_nr(p), p->comm, points);
task_unlock(p);
@@ -508,6 +508,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
if (!p) {
rcu_read_unlock();
put_task_struct(victim);
+ pr_err("No process has been killed!\n");
return;
} else if (victim != p) {
get_task_struct(p);
@@ -539,7 +540,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
continue;
task_lock(p); /* Protect ->comm from prctl() */
- pr_err("Kill process %d (%s) sharing same memory\n",
+ pr_err("Killed process %d (%s) sharing same memory\n",
task_pid_nr(p), p->comm);
task_unlock(p);
do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] memcg, oom: Clarify some oom dump messages
2012-07-24 16:12 ` [PATCH 2/2] memcg, oom: Clarify some oom dump messages Sha Zhengju
@ 2012-08-01 3:55 ` David Rientjes
0 siblings, 0 replies; 3+ messages in thread
From: David Rientjes @ 2012-08-01 3:55 UTC (permalink / raw)
To: Sha Zhengju
Cc: linux-mm, cgroups, Sha Zhengju, kamezawa.hiroyu, akpm, mhocko,
gthelen, hannes
On Wed, 25 Jul 2012, Sha Zhengju wrote:
> From: Sha Zhengju <handai.szj@taobao.com>
>
> Revise some oom dump messages to avoid misleading admin.
>
The only place the oom killer emits information on what it does via the
kernel log so changing this has the potential for messing up a number of
scripts that people are using for parsing it (this would break some of our
log scraping code, for instance).
This adds nothing except a bogus message that is emitted when
select_bad_process() races with oom_kill_process() and no kill occurs
because all threads of the selected process have detached their mm.
Nack.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-01 3:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24 16:09 [PATCH 1/2] memcg, oom: Provide more info while memcg oom happening Sha Zhengju
2012-07-24 16:12 ` [PATCH 2/2] memcg, oom: Clarify some oom dump messages Sha Zhengju
2012-08-01 3:55 ` David Rientjes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox