提交 ac44d354 编写于 作者: B Balbir Singh 提交者: Linus Torvalds

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: NBalbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 217bc319
......@@ -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;
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册