From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>, "balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>, "nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>, "akpm@linux-foundation.org" <akpm@linux-foundation.org>, mingo@elte.hu, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: [PATCH 1/3] add check for mem cgroup is activated Date: Tue, 12 May 2009 10:45:04 +0900 [thread overview] Message-ID: <20090512104504.4e722ccc.kamezawa.hiroyu@jp.fujitsu.com> (raw) In-Reply-To: <20090512104401.28edc0a8.kamezawa.hiroyu@jp.fujitsu.com> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> There is a function "mem_cgroup_disabled()" which returns - memcg is configured ? - disabled by boot option ? This is check is useful to confirm whether we have to call memcg's hook or not. But, even when memcg is configured (and not disabled), it's not really used until mounted. This patch adds mem_cgroup_activated() to check memcg is mounted or not at least once. (Will be used in later patch.) IIUC, only very careful users set boot option of memcg to be disabled and most of people will not be aware of that memcg is enabled at default. So, if memcg wants to affect to global VM behavior or to add some overheads, there is cases that this check is better than mem_cgroup_disabled(). Acked-by: Balbir Singh <balbir@linux.vnet.bim.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> --- Index: mmotm-2.6.30-May07/include/linux/memcontrol.h =================================================================== --- mmotm-2.6.30-May07.orig/include/linux/memcontrol.h +++ mmotm-2.6.30-May07/include/linux/memcontrol.h @@ -115,6 +115,8 @@ static inline bool mem_cgroup_disabled(v return true; return false; } +/* Returns strue if mem_cgroup is enabled and really used (mounted). */ +bool mem_cgroup_activated(void); extern bool mem_cgroup_oom_called(struct task_struct *task); void mem_cgroup_update_mapped_file_stat(struct page *page, int val); @@ -229,6 +231,11 @@ static inline bool mem_cgroup_disabled(v return true; } +static inline bool mem_cgroup_activated(void) +{ + return false; +} + static inline bool mem_cgroup_oom_called(struct task_struct *task) { return false; Index: mmotm-2.6.30-May07/mm/memcontrol.c =================================================================== --- mmotm-2.6.30-May07.orig/mm/memcontrol.c +++ mmotm-2.6.30-May07/mm/memcontrol.c @@ -2577,6 +2577,17 @@ static void mem_cgroup_move_task(struct mutex_unlock(&memcg_tasklist); } +static bool __mem_cgroup_activated = false; +bool mem_cgroup_activated(void) +{ + return __mem_cgroup_activated; +} + +static void mem_cgroup_bind(struct cgroup_subsys *ss, struct cgroup *root) +{ + __mem_cgroup_activated = true; +} + struct cgroup_subsys mem_cgroup_subsys = { .name = "memory", .subsys_id = mem_cgroup_subsys_id, @@ -2585,6 +2596,7 @@ struct cgroup_subsys mem_cgroup_subsys = .destroy = mem_cgroup_destroy, .populate = mem_cgroup_populate, .attach = mem_cgroup_move_task, + .bind = mem_cgroup_bind, .early_init = 0, .use_id = 1, };
WARNING: multiple messages have this Message-ID (diff)
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>, "balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>, "nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>, "akpm@linux-foundation.org" <akpm@linux-foundation.org>, mingo@elte.hu, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: [PATCH 1/3] add check for mem cgroup is activated Date: Tue, 12 May 2009 10:45:04 +0900 [thread overview] Message-ID: <20090512104504.4e722ccc.kamezawa.hiroyu@jp.fujitsu.com> (raw) In-Reply-To: <20090512104401.28edc0a8.kamezawa.hiroyu@jp.fujitsu.com> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> There is a function "mem_cgroup_disabled()" which returns - memcg is configured ? - disabled by boot option ? This is check is useful to confirm whether we have to call memcg's hook or not. But, even when memcg is configured (and not disabled), it's not really used until mounted. This patch adds mem_cgroup_activated() to check memcg is mounted or not at least once. (Will be used in later patch.) IIUC, only very careful users set boot option of memcg to be disabled and most of people will not be aware of that memcg is enabled at default. So, if memcg wants to affect to global VM behavior or to add some overheads, there is cases that this check is better than mem_cgroup_disabled(). Acked-by: Balbir Singh <balbir@linux.vnet.bim.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> --- Index: mmotm-2.6.30-May07/include/linux/memcontrol.h =================================================================== --- mmotm-2.6.30-May07.orig/include/linux/memcontrol.h +++ mmotm-2.6.30-May07/include/linux/memcontrol.h @@ -115,6 +115,8 @@ static inline bool mem_cgroup_disabled(v return true; return false; } +/* Returns strue if mem_cgroup is enabled and really used (mounted). */ +bool mem_cgroup_activated(void); extern bool mem_cgroup_oom_called(struct task_struct *task); void mem_cgroup_update_mapped_file_stat(struct page *page, int val); @@ -229,6 +231,11 @@ static inline bool mem_cgroup_disabled(v return true; } +static inline bool mem_cgroup_activated(void) +{ + return false; +} + static inline bool mem_cgroup_oom_called(struct task_struct *task) { return false; Index: mmotm-2.6.30-May07/mm/memcontrol.c =================================================================== --- mmotm-2.6.30-May07.orig/mm/memcontrol.c +++ mmotm-2.6.30-May07/mm/memcontrol.c @@ -2577,6 +2577,17 @@ static void mem_cgroup_move_task(struct mutex_unlock(&memcg_tasklist); } +static bool __mem_cgroup_activated = false; +bool mem_cgroup_activated(void) +{ + return __mem_cgroup_activated; +} + +static void mem_cgroup_bind(struct cgroup_subsys *ss, struct cgroup *root) +{ + __mem_cgroup_activated = true; +} + struct cgroup_subsys mem_cgroup_subsys = { .name = "memory", .subsys_id = mem_cgroup_subsys_id, @@ -2585,6 +2596,7 @@ struct cgroup_subsys mem_cgroup_subsys = .destroy = mem_cgroup_destroy, .populate = mem_cgroup_populate, .attach = mem_cgroup_move_task, + .bind = mem_cgroup_bind, .early_init = 0, .use_id = 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>
next prev parent reply other threads:[~2009-05-12 1:46 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-05-12 1:44 [PATCH 0/3] fix stale swap cache account leak in memcg v7 KAMEZAWA Hiroyuki 2009-05-12 1:44 ` KAMEZAWA Hiroyuki 2009-05-12 1:45 ` KAMEZAWA Hiroyuki [this message] 2009-05-12 1:45 ` [PATCH 1/3] add check for mem cgroup is activated KAMEZAWA Hiroyuki 2009-05-12 1:46 ` [PATCH 2/3] fix swap cache account leak at swapin-readahead KAMEZAWA Hiroyuki 2009-05-12 1:46 ` KAMEZAWA Hiroyuki 2009-05-12 4:32 ` Daisuke Nishimura 2009-05-12 4:32 ` Daisuke Nishimura 2009-05-12 11:24 ` Johannes Weiner 2009-05-12 11:24 ` Johannes Weiner 2009-05-12 23:58 ` KAMEZAWA Hiroyuki 2009-05-12 23:58 ` KAMEZAWA Hiroyuki 2009-05-13 11:18 ` Johannes Weiner 2009-05-13 11:18 ` Johannes Weiner 2009-05-13 18:03 ` Hugh Dickins 2009-05-13 18:03 ` Hugh Dickins 2009-05-14 0:05 ` KAMEZAWA Hiroyuki 2009-05-14 0:05 ` KAMEZAWA Hiroyuki 2009-05-12 1:47 ` [PATCH 3/3] fix stale swap cache at writeback KAMEZAWA Hiroyuki 2009-05-12 1:47 ` KAMEZAWA Hiroyuki 2009-05-12 5:06 ` [PATCH 4/3] memcg: call uncharge_swapcache outside of tree_lock (Re: [PATCH 0/3] fix stale swap cache account leak in memcg v7) Daisuke Nishimura 2009-05-12 5:06 ` Daisuke Nishimura 2009-05-12 7:09 ` KAMEZAWA Hiroyuki 2009-05-12 7:09 ` KAMEZAWA Hiroyuki 2009-05-12 8:00 ` Daisuke Nishimura 2009-05-12 8:00 ` Daisuke Nishimura 2009-05-12 8:13 ` [PATCH][BUGFIX] memcg: fix for deadlock between lock_page_cgroup and mapping tree_lock KAMEZAWA Hiroyuki 2009-05-12 8:13 ` KAMEZAWA Hiroyuki 2009-05-12 10:58 ` Daisuke Nishimura 2009-05-12 10:58 ` Daisuke Nishimura 2009-05-12 23:59 ` KAMEZAWA Hiroyuki 2009-05-12 23:59 ` KAMEZAWA Hiroyuki 2009-05-13 0:28 ` Daisuke Nishimura 2009-05-13 0:28 ` Daisuke Nishimura 2009-05-13 0:32 ` KAMEZAWA Hiroyuki 2009-05-13 0:32 ` KAMEZAWA Hiroyuki 2009-05-13 3:55 ` KAMEZAWA Hiroyuki 2009-05-13 3:55 ` KAMEZAWA Hiroyuki 2009-05-13 4:11 ` nishimura 2009-05-13 4:11 ` nishimura 2009-05-12 9:51 ` [PATCH 0/3] fix stale swap cache account leak in memcg v7 Balbir Singh 2009-05-12 9:51 ` Balbir Singh 2009-05-13 0:31 ` KAMEZAWA Hiroyuki 2009-05-13 0:31 ` KAMEZAWA Hiroyuki 2009-05-14 23:47 ` KAMEZAWA Hiroyuki 2009-05-14 23:47 ` KAMEZAWA Hiroyuki 2009-05-15 0:38 ` Daisuke Nishimura 2009-05-15 0:38 ` Daisuke Nishimura 2009-05-15 0:54 ` KAMEZAWA Hiroyuki 2009-05-15 0:54 ` KAMEZAWA Hiroyuki 2009-05-15 1:12 ` Daisuke Nishimura 2009-05-15 1:12 ` Daisuke Nishimura
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=20090512104504.4e722ccc.kamezawa.hiroyu@jp.fujitsu.com \ --to=kamezawa.hiroyu@jp.fujitsu.com \ --cc=akpm@linux-foundation.org \ --cc=balbir@linux.vnet.ibm.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mingo@elte.hu \ --cc=nishimura@mxp.nes.nec.co.jp \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.