History

mm: memcontrol: convert anon and file-thp to new mem_cgroup_charge() API

With the page->mapping requirement gone from memcg, we can charge anon and file-thp pages in one single step, right after they're allocated. This removes two out of three API calls - especially the tricky commit step that needed to happen at just the right time between when the page is "set up" and when it's "published" - somewhat vague and fluid concepts that varied by page type. All we need is a freshly allocated page and a memcg context to charge. v2: prevent double charges on pre-allocated hugepages in khugepaged [hannes@cmpxchg.org: Fix crash - *hpage could be ERR_PTR instead of NULL] Link: http://lkml.kernel.org/r/20200512215813.GA487759@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Alex Shi <alex.shi@linux.alibaba.com> Cc: Hugh Dickins <hughd@google.com> Cc: "Kirill A. Shutemov" <kirill@shutemov.name> Cc: Michal Hocko <mhocko@suse.com> Cc: Roman Gushchin <guro@fb.com> Cc: Shakeel Butt <shakeelb@google.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Qian Cai <cai@lca.pw> Link: http://lkml.kernel.org/r/20200508183105.225460-13-hannes@cmpxchg.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Johannes Weiner committed 6 years ago

Commit 9d82c691 parent 468c3989 files · +31 −82Browse files

Showing the changes to include/linux (1 of 9 files). Show all

Unified · Split

include/linux/mm.h+1−3
@@ -501,7 +501,6 @@ struct vm_fault { · 500 unmodified lines
501 pte_t orig_pte; /* Value of PTE at the time of fault */501 pte_t orig_pte; /* Value of PTE at the time of fault */
502 502
503 struct page *cow_page; /* Page handler may use for COW fault */503 struct page *cow_page; /* Page handler may use for COW fault */
504 struct mem_cgroup *memcg; /* Cgroup cow_page belongs to */
505 struct page *page; /* ->fault handlers should return a504 struct page *page; /* ->fault handlers should return a
506 * page here, unless VM_FAULT_NOPAGE505 * page here, unless VM_FAULT_NOPAGE
507 * is set (which is also implied by506 * is set (which is also implied by
@@ -946,8 +945,7 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) · 438 unmodified lines
946 return pte;945 return pte;
947}946}
948 947
949vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,948vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct page *page);
950 struct page *page);
951vm_fault_t finish_fault(struct vm_fault *vmf);949vm_fault_t finish_fault(struct vm_fault *vmf);
952vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf);950vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf);
953#endif951#endif