From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH] Memory controller use rcu_read_lock() in mem_cgroup_cache_charge()
Date: Thu, 20 Dec 2007 14:31:52 +0530 [thread overview]
Message-ID: <20071220090152.19793.46738.sendpatchset@balbir-laptop> (raw)
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
next reply other threads:[~2007-12-20 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-20 9:01 Balbir Singh [this message]
2007-12-20 10:21 ` [PATCH] Memory controller use rcu_read_lock() in mem_cgroup_cache_charge() KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071220090152.19793.46738.sendpatchset@balbir-laptop \
--to=balbir@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=hugh@veritas.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox