memcg: fix try_get_mem_cgroup_from_swapcache()
This is a bugfix for commit 3c776e6466
("memcg: charge swapcache to proper memcg").
Used bit of swapcache is solid under page lock, but considering
move_account, pc->mem_cgroup is not.
We need lock_page_cgroup() anyway.
Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1e50cc9022
commit
c0bd3f63ce
|
@ -1024,9 +1024,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pc = lookup_page_cgroup(page);
|
pc = lookup_page_cgroup(page);
|
||||||
/*
|
lock_page_cgroup(pc);
|
||||||
* Used bit of swapcache is solid under page lock.
|
|
||||||
*/
|
|
||||||
if (PageCgroupUsed(pc)) {
|
if (PageCgroupUsed(pc)) {
|
||||||
mem = pc->mem_cgroup;
|
mem = pc->mem_cgroup;
|
||||||
if (mem && !css_tryget(&mem->css))
|
if (mem && !css_tryget(&mem->css))
|
||||||
|
@ -1040,6 +1038,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
|
||||||
mem = NULL;
|
mem = NULL;
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
unlock_page_cgroup(pc);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue