aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-02-07 03:14:18 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:20 -0500
commitac44d354d5c9ced49b1165d6496f134501134219 (patch)
treebe054e8e2d37739a33d94cc78db3fd65e73c3aff /mm/memcontrol.c
parent217bc3194d57150549e9234e6ddfee30de28cc78 (diff)
Memory controller use rcu_read_lock() in mem_cgroup_cache_charge()
Hugh Dickins noticed that we were using rcu_dereference() without rcu_read_lock() in the cache charging routine. The patch below fixes this problem Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 975e89935d52..160101a05b4d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -456,16 +456,20 @@ int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
456int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, 456int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
457 gfp_t gfp_mask) 457 gfp_t gfp_mask)
458{ 458{
459 int ret = 0;
459 struct mem_cgroup *mem; 460 struct mem_cgroup *mem;
460 if (!mm) 461 if (!mm)
461 mm = &init_mm; 462 mm = &init_mm;
462 463
464 rcu_read_lock();
463 mem = rcu_dereference(mm->mem_cgroup); 465 mem = rcu_dereference(mm->mem_cgroup);
466 css_get(&mem->css);
467 rcu_read_unlock();
464 if (mem->control_type == MEM_CGROUP_TYPE_ALL) 468 if (mem->control_type == MEM_CGROUP_TYPE_ALL)
465 return mem_cgroup_charge_common(page, mm, gfp_mask, 469 ret = mem_cgroup_charge_common(page, mm, gfp_mask,
466 MEM_CGROUP_CHARGE_TYPE_CACHE); 470 MEM_CGROUP_CHARGE_TYPE_CACHE);
467 else 471 css_put(&mem->css);
468 return 0; 472 return ret;
469} 473}
470 474
471/* 475/*