aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorPaul Menage <menage@google.com>2009-01-07 21:08:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:10 -0500
commit2cb378c862777d050c20db903b119a029845fdcb (patch)
tree5512511acf9d66338039f9698e456f1e3254970b /mm
parent999cd8a450f8f93701669a61cac4d3b19eca07e8 (diff)
cgroups: use hierarchy_mutex in memory controller
Update the memory controller to use its hierarchy_mutex rather than calling cgroup_lock() to protected against cgroup_mkdir()/cgroup_rmdir() from occurring in its hierarchy. Signed-off-by: Paul Menage <menage@google.com> Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Balbir Singh <balbir@in.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 93a792871804..e2996b80601f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -154,7 +154,7 @@ struct mem_cgroup {
154 154
155 /* 155 /*
156 * While reclaiming in a hiearchy, we cache the last child we 156 * While reclaiming in a hiearchy, we cache the last child we
157 * reclaimed from. Protected by cgroup_lock() 157 * reclaimed from. Protected by hierarchy_mutex
158 */ 158 */
159 struct mem_cgroup *last_scanned_child; 159 struct mem_cgroup *last_scanned_child;
160 /* 160 /*
@@ -615,7 +615,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
615 615
616/* 616/*
617 * This routine finds the DFS walk successor. This routine should be 617 * This routine finds the DFS walk successor. This routine should be
618 * called with cgroup_mutex held 618 * called with hierarchy_mutex held
619 */ 619 */
620static struct mem_cgroup * 620static struct mem_cgroup *
621mem_cgroup_get_next_node(struct mem_cgroup *curr, struct mem_cgroup *root_mem) 621mem_cgroup_get_next_node(struct mem_cgroup *curr, struct mem_cgroup *root_mem)
@@ -685,7 +685,7 @@ mem_cgroup_get_first_node(struct mem_cgroup *root_mem)
685 /* 685 /*
686 * Scan all children under the mem_cgroup mem 686 * Scan all children under the mem_cgroup mem
687 */ 687 */
688 cgroup_lock(); 688 mutex_lock(&mem_cgroup_subsys.hierarchy_mutex);
689 if (list_empty(&root_mem->css.cgroup->children)) { 689 if (list_empty(&root_mem->css.cgroup->children)) {
690 ret = root_mem; 690 ret = root_mem;
691 goto done; 691 goto done;
@@ -706,7 +706,7 @@ mem_cgroup_get_first_node(struct mem_cgroup *root_mem)
706 706
707done: 707done:
708 root_mem->last_scanned_child = ret; 708 root_mem->last_scanned_child = ret;
709 cgroup_unlock(); 709 mutex_unlock(&mem_cgroup_subsys.hierarchy_mutex);
710 return ret; 710 return ret;
711} 711}
712 712
@@ -770,18 +770,16 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
770 while (next_mem != root_mem) { 770 while (next_mem != root_mem) {
771 if (mem_cgroup_is_obsolete(next_mem)) { 771 if (mem_cgroup_is_obsolete(next_mem)) {
772 mem_cgroup_put(next_mem); 772 mem_cgroup_put(next_mem);
773 cgroup_lock();
774 next_mem = mem_cgroup_get_first_node(root_mem); 773 next_mem = mem_cgroup_get_first_node(root_mem);
775 cgroup_unlock();
776 continue; 774 continue;
777 } 775 }
778 ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap, 776 ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap,
779 get_swappiness(next_mem)); 777 get_swappiness(next_mem));
780 if (mem_cgroup_check_under_limit(root_mem)) 778 if (mem_cgroup_check_under_limit(root_mem))
781 return 0; 779 return 0;
782 cgroup_lock(); 780 mutex_lock(&mem_cgroup_subsys.hierarchy_mutex);
783 next_mem = mem_cgroup_get_next_node(next_mem, root_mem); 781 next_mem = mem_cgroup_get_next_node(next_mem, root_mem);
784 cgroup_unlock(); 782 mutex_unlock(&mem_cgroup_subsys.hierarchy_mutex);
785 } 783 }
786 return ret; 784 return ret;
787} 785}