Skip to content

Commit

Permalink
memcg: fix try_get_mem_cgroup_from_swapcache()
Browse files Browse the repository at this point in the history
This is a bugfix for commit 3c776e6
("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 <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Daisuke Nishimura authored and torvalds committed May 2, 2009
1 parent 1e50cc9 commit c0bd3f6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
return NULL;

pc = lookup_page_cgroup(page);
/*
* Used bit of swapcache is solid under page lock.
*/
lock_page_cgroup(pc);
if (PageCgroupUsed(pc)) {
mem = pc->mem_cgroup;
if (mem && !css_tryget(&mem->css))
Expand All @@ -1040,6 +1038,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
mem = NULL;
rcu_read_unlock();
}
unlock_page_cgroup(pc);
return mem;
}

Expand Down

0 comments on commit c0bd3f6

Please sign in to comment.