[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100223140435.GA31131@localhost>
Date: Tue, 23 Feb 2010 22:04:35 +0800
From: Wu Fengguang <fengguang.wu@...el.com>
To: Balbir Singh <balbir@...ux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Ingo Molnar <mingo@...e.hu>, Chris Frost <frost@...ucla.edu>,
Steven Rostedt <rostedt@...dmis.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Frederic Weisbecker <fweisbec@...il.com>,
Keiichi KII <k-keiichi@...jp.nec.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jason Baron <jbaron@...hat.com>,
Hitoshi Mitake <mitake@....info.waseda.ac.jp>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lwoodman@...hat.com" <lwoodman@...hat.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Tom Zanussi <tzanussi@...il.com>,
"riel@...hat.com" <riel@...hat.com>,
Munehiro Ikeda <m-ikeda@...jp.nec.com>,
Atsushi Tsuji <a-tsuji@...jp.nec.com>
Subject: Re: [RFC PATCH -tip 0/2 v3] pagecache tracepoints proposal
On Thu, Feb 18, 2010 at 05:58:50PM +0800, Balbir Singh wrote:
> * KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com> [2010-02-18 14:34:29]:
> > Can we dump page's cgroup ? If so, I'm happy.
> > Maybe
> > ==
> > struct page_cgroup *pc = lookup_page_cgroup(page);
> > struct mem_cgroup *mem = pc->mem_cgroup;
> > shodt mem_cgroup_id = mem->css.css_id;
> >
> > And statistics can be counted per css_id.
> >
>
> Good idea, all of this needs to happen with a check to see if memcg is
> enabled/disabled at boot as well. pc can be NULL if
> CONFIG_CGROUP_MEM_RES_CTLR is not enabled.
Not sure if this is the one in your mind, but I defined a function in
memcontrol.c for the trace code. Compile tested.
It'll be used like this:
TP_fast_assign(
__entry->memcg = page_memcg_id(page);
)
TP_printk("index=%lu len=%lu flags=%lx count=%u mapcount=%u memcg=%d",
Thanks,
Fengguang
---
memcg: introduce page_memcg_id()
This will be used to dump the memcg id associated with a pagecache page.
CC: Balbir Singh <balbir@...ux.vnet.ibm.com>
CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Signed-off-by: Wu Fengguang <fengguang.wu@...el.com>
---
include/linux/memcontrol.h | 6 ++++++
mm/memcontrol.c | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
--- linux-mm.orig/include/linux/memcontrol.h 2010-02-23 21:49:39.000000000 +0800
+++ linux-mm/include/linux/memcontrol.h 2010-02-23 21:50:14.000000000 +0800
@@ -69,6 +69,7 @@ extern void mem_cgroup_out_of_memory(str
int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
+extern unsigned short page_memcg_id(struct page *page);
extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
static inline
@@ -142,6 +143,11 @@ static inline int mem_cgroup_try_charge_
return 0;
}
+static inline unsigned short page_memcg_id(struct page *page)
+{
+ return 0;
+}
+
static inline void mem_cgroup_commit_charge_swapin(struct page *page,
struct mem_cgroup *ptr)
{
--- linux-mm.orig/mm/memcontrol.c 2010-02-23 21:48:23.000000000 +0800
+++ linux-mm/mm/memcontrol.c 2010-02-23 21:49:33.000000000 +0800
@@ -324,6 +324,22 @@ static struct mem_cgroup *try_get_mem_cg
return mem;
}
+unsigned short page_memcg_id(struct page *page)
+{
+ struct mem_cgroup *mem;
+ struct cgroup_subsys_state *css;
+ unsigned short id = 0;
+
+ mem = try_get_mem_cgroup_from_page(page);
+ if (mem) {
+ css = mem_cgroup_css(mem);
+ id = css_id(css);
+ css_put(css);
+ }
+
+ return id;
+}
+
/*
* Call callback function against all cgroup under hierarchy tree.
*/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists