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>
Showing the changes to include/linux (1 of 9 files). Show all
Unified · Split
| @@ -501,7 +501,6 @@ struct vm_fault { · 500 unmodified lines | ||
| 501 | 501 | pte_t orig_pte; /* Value of PTE at the time of fault */ |
| 502 | 502 | |
| 503 | 503 | struct page *cow_page; /* Page handler may use for COW fault */ |
| 504 | − struct mem_cgroup *memcg; /* Cgroup cow_page belongs to */ | |
| 505 | 504 | struct page *page; /* ->fault handlers should return a |
| 506 | 505 | * page here, unless VM_FAULT_NOPAGE |
| 507 | 506 | * 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 | 945 | return pte; |
| 947 | 946 | } |
| 948 | 947 | |
| 949 | −vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg, | |
| 950 | − struct page *page); | |
| 948 | +vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct page *page); | |
| 951 | 949 | vm_fault_t finish_fault(struct vm_fault *vmf); |
| 952 | 950 | vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf); |
| 953 | 951 | #endif |