lkml.org 
[lkml]   [2010]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 4/4] memcg: per node info node hotplug support
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Support node hot plug (experimental).

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.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;


\
 
 \ /
  Last update: 2010-09-27 20:11    [from the cache]
©2003-2011 Jasper Spaans