Commit c0bd3f63ce01a1757dbce6373122a05fbf99ced7
Committed by
Linus Torvalds
1 parent
1e50cc9022
Exists in
master
and in
4 other branches
memcg: fix try_get_mem_cgroup_from_swapcache()
This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df ("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>
Showing 1 changed file with 2 additions and 3 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -1024,9 +1024,7 @@ |
1024 | 1024 | return NULL; |
1025 | 1025 | |
1026 | 1026 | pc = lookup_page_cgroup(page); |
1027 | - /* | |
1028 | - * Used bit of swapcache is solid under page lock. | |
1029 | - */ | |
1027 | + lock_page_cgroup(pc); | |
1030 | 1028 | if (PageCgroupUsed(pc)) { |
1031 | 1029 | mem = pc->mem_cgroup; |
1032 | 1030 | if (mem && !css_tryget(&mem->css)) |
... | ... | @@ -1040,6 +1038,7 @@ |
1040 | 1038 | mem = NULL; |
1041 | 1039 | rcu_read_unlock(); |
1042 | 1040 | } |
1041 | + unlock_page_cgroup(pc); | |
1043 | 1042 | return mem; |
1044 | 1043 | } |
1045 | 1044 |