lkml.org 
[lkml]   [2007]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] 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>
---

mm/memcontrol.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff -puN mm/memcontrol.c~memory-controller-use-rcu-lead-lock mm/memcontrol.c
--- linux-2.6.24-rc5/mm/memcontrol.c~memory-controller-use-rcu-lead-lock 2007-12-19 11:52:44.000000000 +0530
+++ linux-2.6.24-rc5-balbir/mm/memcontrol.c 2007-12-20 14:01:45.000000000 +0530
@@ -717,16 +717,20 @@ int mem_cgroup_charge(struct page *page,
int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask)
{
+ int ret = 0;
struct mem_cgroup *mem;
if (!mm)
mm = &init_mm;

+ rcu_read_lock();
mem = rcu_dereference(mm->mem_cgroup);
+ css_get(&mem->css);
+ rcu_read_unlock();
if (mem->control_type == MEM_CGROUP_TYPE_ALL)
- return mem_cgroup_charge_common(page, mm, gfp_mask,
+ ret = mem_cgroup_charge_common(page, mm, gfp_mask,
MEM_CGROUP_CHARGE_TYPE_CACHE);
- else
- return 0;
+ css_put(&mem->css);
+ return ret;
}

/*
_
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL


\
 
 \ /
  Last update: 2007-12-20 10:05    [W:0.039 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site