Skip to content

Commit 7d18895

Browse files
hnaztorvalds
authored andcommitted
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>
1 parent 0c59b89 commit 7d18895

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

mm/memcontrol.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,8 +3093,6 @@ void mem_cgroup_uncharge_cache_page(struct page *page)
30933093
{
30943094
VM_BUG_ON(page_mapped(page));
30953095
VM_BUG_ON(page->mapping);
3096-
if (PageSwapCache(page))
3097-
return;
30983096
__mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false);
30993097
}
31003098

@@ -3159,8 +3157,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
31593157
if (!swapout) /* this was a swap cache but the swap is unused ! */
31603158
ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
31613159

3162-
if (PageSwapCache(page))
3163-
return;
31643160
memcg = __mem_cgroup_uncharge_common(page, ctype, false);
31653161

31663162
/*
@@ -3350,11 +3346,10 @@ void mem_cgroup_end_migration(struct mem_cgroup *memcg,
33503346
unused = oldpage;
33513347
}
33523348
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);
33583353
css_put(&memcg->css);
33593354
/*
33603355
* We disallowed uncharge of pages under migration because mapcount

0 commit comments

Comments
 (0)