[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100927185447.64ed0aec.kamezawa.hiroyu@jp.fujitsu.com>
Date: Mon, 27 Sep 2010 18:54:47 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: "linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
"nishimura@....nes.nec.co.jp" <nishimura@....nes.nec.co.jp>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: [RFC][PATCH 4/4] memcg: per node info node hotplug support
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Support node hot plug (experimental).
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
---
mm/memcontrol.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
Index: mmotm-0922/mm/memcontrol.c
===================================================================
--- mmotm-0922.orig/mm/memcontrol.c
+++ mmotm-0922/mm/memcontrol.c
@@ -48,6 +48,7 @@
#include <linux/page_cgroup.h>
#include <linux/cpu.h>
#include <linux/oom.h>
+#include <linux/memory.h>
#include "internal.h"
#include <asm/uaccess.h>
@@ -4212,8 +4213,12 @@ static int alloc_mem_cgroup_per_zone_inf
id = node_zone_idx(css_id(&mem->css), node, zone);
ret = radix_tree_insert(&memcg_lrus, id, mz);
spin_unlock_irq(&memcg_lrutable_lock);
- if (ret)
- break;
+ if (ret) {
+ if (ret != -EEXIST)
+ break;
+ kfree(mz);
+ continue;
+ }
for_each_lru(l)
INIT_LIST_HEAD(&mz->lists[l]);
mz->on_tree = false;
@@ -4372,6 +4377,40 @@ static int mem_cgroup_soft_limit_tree_in
return 0;
}
+static int __meminit memcg_memory_hotplug_callback(struct notifier_block *self,
+ unsigned long action, void *arg)
+{
+ struct memory_notify *mn = arg;
+ struct mem_cgroup *mem;
+ int nid = mn->status_change_nid;
+ int ret = 0;
+
+ /* We just take care of node hotplug */
+ if (nid == -1)
+ return NOTIFY_OK;
+ switch(action) {
+ case MEM_GOING_ONLINE:
+ for_each_mem_cgroup_all(mem)
+ ret = alloc_mem_cgroup_per_zone_info(mem, nid);
+ break;
+ case MEM_OFFLINE:
+ for_each_mem_cgroup_all(mem)
+ free_mem_cgroup_per_zone_info(mem, nid);
+ break;
+ default:
+ break;
+ }
+
+ if (ret)
+ ret = notifier_from_errno(ret);
+ else
+ ret = NOTIFY_OK;
+
+ return ret;
+}
+
+
+
static struct cgroup_subsys_state * __ref
mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
{
@@ -4387,7 +4426,7 @@ mem_cgroup_create(struct cgroup_subsys *
if (error)
goto free_out;
- for_each_node_state(node, N_POSSIBLE)
+ for_each_node_state(node, N_HIGH_MEMORY)
if (alloc_mem_cgroup_per_zone_info(mem, node))
goto free_out;
@@ -4407,6 +4446,7 @@ mem_cgroup_create(struct cgroup_subsys *
INIT_WORK(&stock->work, drain_local_stock);
}
hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
+ hotplug_memory_notifier(memcg_memory_hotplug_callback, 0);
} else {
parent = mem_cgroup_from_cont(cont->parent);
mem->use_hierarchy = parent->use_hierarchy;
--
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