Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ac44d354d5c9ced49b1165d6496f134501134219
Commit:     ac44d354d5c9ced49b1165d6496f134501134219
Parent:     217bc3194d57150549e9234e6ddfee30de28cc78
Author:     Balbir Singh <[EMAIL PROTECTED]>
AuthorDate: Thu Feb 7 00:14:18 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Feb 7 08:42:20 2008 -0800

    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 <[EMAIL PROTECTED]>
    Acked-by: KAMEZAWA Hiroyuki <[EMAIL PROTECTED]>
    Cc: Hugh Dickins <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/memcontrol.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 975e899..160101a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -456,16 +456,20 @@ int mem_cgroup_charge(struct page *page, struct mm_struct 
*mm,
 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;
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to