summaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-09-23 15:56:33 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-24 07:20:58 -0700
commit261fb61a8bf6d3bd964ae6f1e6af49585d30db51 (patch)
tree417cebd2e18bc2457b5b09d8359ad71ba6afd56d /mm/memcontrol.c
parent4b3bde4c983de36c59e6c1a24701f6fe816f9f55 (diff)
downloadlinux-261fb61a8bf6d3bd964ae6f1e6af49585d30db51.tar.gz
linux-261fb61a8bf6d3bd964ae6f1e6af49585d30db51.tar.bz2
linux-261fb61a8bf6d3bd964ae6f1e6af49585d30db51.zip
memcg: add comments explaining memory barriers
Add comments for the reason of smp_wmb() in mem_cgroup_commit_charge(). [akpm@linux-foundation.org: coding-style fixes] Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b0757660663f..eb9571815f0c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1134,6 +1134,13 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem,
}
pc->mem_cgroup = mem;
+ /*
+ * We access a page_cgroup asynchronously without lock_page_cgroup().
+ * Especially when a page_cgroup is taken from a page, pc->mem_cgroup
+ * is accessed after testing USED bit. To make pc->mem_cgroup visible
+ * before USED bit, we need memory barrier here.
+ * See mem_cgroup_add_lru_list(), etc.
+ */
smp_wmb();
switch (ctype) {
case MEM_CGROUP_CHARGE_TYPE_CACHE: