Commit 7a0524cfc8f9f585471a31b1282a9ce4a1a7d444

Authored by Johannes Weiner
Committed by Linus Torvalds
1 parent 00c54c0bac

mm: memcg: remove unneeded checks from newpage_charge()

All callsites pass in freshly allocated pages and a valid mm.  As a
result, all checks pertaining to the page's mapcount, page->mapping or the
fallback to init_mm are unneeded.

Signed-off-by: Johannes Weiner <jweiner@redhat.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
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 12 deletions Side-by-side Diff

... ... @@ -2748,19 +2748,11 @@
2748 2748 {
2749 2749 if (mem_cgroup_disabled())
2750 2750 return 0;
2751   - /*
2752   - * If already mapped, we don't have to account.
2753   - * If page cache, page->mapping has address_space.
2754   - * But page->mapping may have out-of-use anon_vma pointer,
2755   - * detecit it by PageAnon() check. newly-mapped-anon's page->mapping
2756   - * is NULL.
2757   - */
2758   - if (page_mapped(page) || (page->mapping && !PageAnon(page)))
2759   - return 0;
2760   - if (unlikely(!mm))
2761   - mm = &init_mm;
  2751 + VM_BUG_ON(page_mapped(page));
  2752 + VM_BUG_ON(page->mapping && !PageAnon(page));
  2753 + VM_BUG_ON(!mm);
2762 2754 return mem_cgroup_charge_common(page, mm, gfp_mask,
2763   - MEM_CGROUP_CHARGE_TYPE_MAPPED);
  2755 + MEM_CGROUP_CHARGE_TYPE_MAPPED);
2764 2756 }
2765 2757  
2766 2758 static void