Commit 7d188958bb64708577aa77e6b1ad68abbf0480f5
Committed by
Linus Torvalds
1 parent
0c59b89c81
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
mm: memcg: only check for PageSwapCache when uncharging anon
Only anon pages that are uncharged at the time of the last page table mapping vanishing may be in swapcache. When shmem pages, file pages, swap-freed anon pages, or just migrated pages are uncharged, they are known for sure to be not in swapcache. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: David Rientjes <rientjes@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Wanpeng Li <liwp.linux@gmail.com> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 4 additions and 9 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -3093,8 +3093,6 @@ |
3093 | 3093 | { |
3094 | 3094 | VM_BUG_ON(page_mapped(page)); |
3095 | 3095 | VM_BUG_ON(page->mapping); |
3096 | - if (PageSwapCache(page)) | |
3097 | - return; | |
3098 | 3096 | __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false); |
3099 | 3097 | } |
3100 | 3098 | |
... | ... | @@ -3159,8 +3157,6 @@ |
3159 | 3157 | if (!swapout) /* this was a swap cache but the swap is unused ! */ |
3160 | 3158 | ctype = MEM_CGROUP_CHARGE_TYPE_DROP; |
3161 | 3159 | |
3162 | - if (PageSwapCache(page)) | |
3163 | - return; | |
3164 | 3160 | memcg = __mem_cgroup_uncharge_common(page, ctype, false); |
3165 | 3161 | |
3166 | 3162 | /* |
... | ... | @@ -3350,11 +3346,10 @@ |
3350 | 3346 | unused = oldpage; |
3351 | 3347 | } |
3352 | 3348 | anon = PageAnon(used); |
3353 | - if (!PageSwapCache(unused)) | |
3354 | - __mem_cgroup_uncharge_common(unused, | |
3355 | - anon ? MEM_CGROUP_CHARGE_TYPE_ANON | |
3356 | - : MEM_CGROUP_CHARGE_TYPE_CACHE, | |
3357 | - true); | |
3349 | + __mem_cgroup_uncharge_common(unused, | |
3350 | + anon ? MEM_CGROUP_CHARGE_TYPE_ANON | |
3351 | + : MEM_CGROUP_CHARGE_TYPE_CACHE, | |
3352 | + true); | |
3358 | 3353 | css_put(&memcg->css); |
3359 | 3354 | /* |
3360 | 3355 | * We disallowed uncharge of pages under migration because mapcount |