提交 7a0524cf 编写于 作者: J Johannes Weiner 提交者: Linus Torvalds

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: NJohannes Weiner <jweiner@redhat.com>
Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: NMichal 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 00c54c0b
...@@ -2748,19 +2748,11 @@ int mem_cgroup_newpage_charge(struct page *page, ...@@ -2748,19 +2748,11 @@ int mem_cgroup_newpage_charge(struct page *page,
{ {
if (mem_cgroup_disabled()) if (mem_cgroup_disabled())
return 0; return 0;
/* VM_BUG_ON(page_mapped(page));
* If already mapped, we don't have to account. VM_BUG_ON(page->mapping && !PageAnon(page));
* If page cache, page->mapping has address_space. VM_BUG_ON(!mm);
* But page->mapping may have out-of-use anon_vma pointer,
* detecit it by PageAnon() check. newly-mapped-anon's page->mapping
* is NULL.
*/
if (page_mapped(page) || (page->mapping && !PageAnon(page)))
return 0;
if (unlikely(!mm))
mm = &init_mm;
return mem_cgroup_charge_common(page, mm, gfp_mask, return mem_cgroup_charge_common(page, mm, gfp_mask,
MEM_CGROUP_CHARGE_TYPE_MAPPED); MEM_CGROUP_CHARGE_TYPE_MAPPED);
} }
static void static void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册