Skip to content

Commit 7a0524c

Browse files
Johannes Weinertorvalds
authored andcommitted
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 <[email protected]> Acked-by: KAMEZAWA Hiroyuki <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: David Rientjes <[email protected]> Cc: Balbir Singh <[email protected]> Cc: Hugh Dickins <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 00c54c0 commit 7a0524c

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

mm/memcontrol.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,19 +2748,11 @@ int mem_cgroup_newpage_charge(struct page *page,
27482748
{
27492749
if (mem_cgroup_disabled())
27502750
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);
27622754
return mem_cgroup_charge_common(page, mm, gfp_mask,
2763-
MEM_CGROUP_CHARGE_TYPE_MAPPED);
2755+
MEM_CGROUP_CHARGE_TYPE_MAPPED);
27642756
}
27652757

27662758
static void

0 commit comments

Comments
 (0)