From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"menage@google.com" <menage@google.com>,
nishimura@mxp.nes.nec.co.jp
Subject: Re: [RFC][PATCH 5/6] memcg: mem+swap controller
Date: Fri, 7 Nov 2008 22:30:32 +0900 [thread overview]
Message-ID: <20081107223032.7f5cd698.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20081107181932.94e6f307.kamezawa.hiroyu@jp.fujitsu.com>
> > > static struct cftype mem_cgroup_files[] = {
> > > {
> > > .name = "usage_in_bytes",
> > > - .private = RES_USAGE,
> > > + .private = MEMFILE_PRIVATE(_MEM, RES_USAGE),
> > > .read_u64 = mem_cgroup_read,
> > > },
> > > {
> > > .name = "max_usage_in_bytes",
> > > - .private = RES_MAX_USAGE,
> > > + .private = MEMFILE_PRIVATE(_MEM, RES_MAX_USAGE),
> > > .trigger = mem_cgroup_reset,
> > > .read_u64 = mem_cgroup_read,
> > > },
> > > {
> > > .name = "limit_in_bytes",
> > > - .private = RES_LIMIT,
> > > + .private = MEMFILE_PRIVATE(_MEM, RES_LIMIT),
> > > .write_string = mem_cgroup_write,
> > > .read_u64 = mem_cgroup_read,
> > > },
> > > {
> > > .name = "failcnt",
> > > - .private = RES_FAILCNT,
> > > + .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT),
> > > .trigger = mem_cgroup_reset,
> > > .read_u64 = mem_cgroup_read,
> > > },
> > > @@ -1317,6 +1541,31 @@ static struct cftype mem_cgroup_files[]
> > > .name = "stat",
> > > .read_map = mem_control_stat_show,
> > > },
> > > +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
> > > + {
> > > + .name = "memsw.usage_in_bytes",
> > > + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_USAGE),
> > > + .read_u64 = mem_cgroup_read,
> > > + },
> > > + {
> > > + .name = "memsw.max_usage_in_bytes",
> > > + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE),
> > > + .trigger = mem_cgroup_reset,
> > > + .read_u64 = mem_cgroup_read,
> > > + },
> > > + {
> > > + .name = "memsw.limit_in_bytes",
> > > + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT),
> > > + .write_string = mem_cgroup_write,
> > > + .read_u64 = mem_cgroup_read,
> > > + },
> > > + {
> > > + .name = "memsw.failcnt",
> > > + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT),
> > > + .trigger = mem_cgroup_reset,
> > > + .read_u64 = mem_cgroup_read,
> > > + },
> > > +#endif
> > > };
> > >
> > IMHO, it would be better to define those "memsw.*" files as memsw_cgroup_files[],
> > and change mem_cgroup_populate() like:
> >
> > static int mem_cgroup_populate(struct cgroup_subsys *ss,
> > struct cgroup *cont)
> > {
> > int ret;
> >
> > ret = cgroup_add_files(cont, ss, mem_cgroup_files,
> > ARRAY_SIZE(mem_cgroup_files));
> > if (!ret && do_swap_account)
> > ret = cgroup_add_files(cont, ss, memsw_cgroup_files,
> > ARRAY_SIZE(memsw_cgroup_files));
> >
> > return ret;
> > }
> >
> > so that those files appear only when swap accounting is enabled.
> >
>
> Nice idea. I'll try that.
>
I made a patch for this.
please merge this if it looks good to you.
I've confirmed that memsw.* files doesn't created with noswapaccount,
and this can be compiled with !CONFIG_CGROUP_MEM_RES_CTLR_SWAP.
Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
---
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 27f1772..03dfc46 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1542,6 +1542,9 @@ static struct cftype mem_cgroup_files[] = {
.name = "stat",
.read_map = mem_control_stat_show,
},
+};
+
+static struct cftype swap_cgroup_files[] = {
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
{
.name = "memsw.usage_in_bytes",
@@ -1724,8 +1727,14 @@ static void mem_cgroup_destroy(struct cgroup_subsys *ss,
static int mem_cgroup_populate(struct cgroup_subsys *ss,
struct cgroup *cont)
{
- return cgroup_add_files(cont, ss, mem_cgroup_files,
+ int ret;
+ ret = cgroup_add_files(cont, ss, mem_cgroup_files,
ARRAY_SIZE(mem_cgroup_files));
+ if (!ret && do_swap_account)
+ ret = cgroup_add_files(cont, ss, swap_cgroup_files,
+ ARRAY_SIZE(swap_cgroup_files));
+
+ return ret;
}
static void mem_cgroup_move_task(struct cgroup_subsys *ss,
--
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>
next prev parent reply other threads:[~2008-11-07 13:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 8:16 [RFC][PATCH 0/6] memcg updates (05/Nov) KAMEZAWA Hiroyuki
2008-11-05 8:18 ` [RFC][PATCH 1/6] memcg: move all accounts to parent at rmdir() KAMEZAWA Hiroyuki
2008-11-05 8:20 ` [RFC][PATCH 2/6] memcg: handle swap cache KAMEZAWA Hiroyuki
2008-11-07 8:53 ` Daisuke Nishimura
2008-11-07 9:13 ` KAMEZAWA Hiroyuki
2008-11-05 8:20 ` [RFC][PATCH 3/6] memcg : mem+swap controller kconfig KAMEZAWA Hiroyuki
2008-11-06 11:07 ` Daisuke Nishimura
2008-11-05 8:21 ` [RFC][PATCH 4/6] memcg : swap cgroup KAMEZAWA Hiroyuki
2008-11-06 11:25 ` Daisuke Nishimura
2008-11-06 12:44 ` KAMEZAWA Hiroyuki
2008-11-07 1:19 ` Daisuke Nishimura
2008-11-05 8:23 ` [RFC][PATCH 5/6] memcg: mem+swap controller KAMEZAWA Hiroyuki
2008-11-07 9:02 ` Daisuke Nishimura
2008-11-07 9:19 ` KAMEZAWA Hiroyuki
2008-11-07 13:30 ` Daisuke Nishimura [this message]
2008-11-07 13:21 ` Daisuke Nishimura
2008-11-10 4:30 ` Daisuke Nishimura
2008-11-10 7:03 ` KAMEZAWA Hiroyuki
2008-11-05 8:24 ` [RFC][PATCH 6/6] memcg: synchronized LRU KAMEZAWA Hiroyuki
2008-11-06 6:54 ` [RFC][PATCH 0/6] memcg updates (05/Nov) Balbir Singh
2008-11-06 7:03 ` KAMEZAWA Hiroyuki
2008-11-06 10:41 ` [RFC][PATCH 7/6] memcg: add atribute (for change bahavior of rmdir) KAMEZAWA Hiroyuki
2008-11-06 11:59 ` Hugh Dickins
2008-11-06 12:47 ` [RFC][PATCH 7/6] memcg: add atribute (for change bahavior ofrmdir) KAMEZAWA Hiroyuki
2008-11-06 13:46 ` [RFC][PATCH 7/6] memcg: add atribute (for change bahavior of rmdir) Balbir Singh
2008-11-06 14:30 ` [RFC][PATCH 7/6] memcg: add atribute (for change bahavior ofrmdir) KAMEZAWA Hiroyuki
2008-11-07 1:12 ` KAMEZAWA Hiroyuki
2008-11-12 3:26 [RFC][PATCH 0/6] memcg updates (12/Nov/2008) KAMEZAWA Hiroyuki
2008-11-12 3:30 ` [RFC][PATCH 5/6] memcg: mem+swap controller KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081107223032.7f5cd698.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=menage@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox