]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Use a folio in hugepage_add_anon_rmap() and hugepage_add_new_anon_rmap()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 30 Dec 2022 19:52:48 +0000 (14:52 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 3 Jan 2023 04:00:55 +0000 (23:00 -0500)
Remove uses of compound_mapcount_ptr()

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/rmap.c

index c7e04747742f905d346c9bc192fa0826442aeb88..947a216583ffe76ffea8056832e6787b19f65484 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -2545,13 +2545,14 @@ void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc)
 void hugepage_add_anon_rmap(struct page *page, struct vm_area_struct *vma,
                            unsigned long address, rmap_t flags)
 {
+       struct folio *folio = page_folio(page);
        struct anon_vma *anon_vma = vma->anon_vma;
        int first;
 
-       BUG_ON(!PageLocked(page));
+       BUG_ON(!folio_test_locked(folio));
        BUG_ON(!anon_vma);
        /* address might be in next vma when migration races vma_adjust */
-       first = atomic_inc_and_test(compound_mapcount_ptr(page));
+       first = atomic_inc_and_test(&folio->_entire_mapcount);
        VM_BUG_ON_PAGE(!first && (flags & RMAP_EXCLUSIVE), page);
        VM_BUG_ON_PAGE(!first && PageAnonExclusive(page), page);
        if (first)
@@ -2562,10 +2563,12 @@ void hugepage_add_anon_rmap(struct page *page, struct vm_area_struct *vma,
 void hugepage_add_new_anon_rmap(struct page *page,
                        struct vm_area_struct *vma, unsigned long address)
 {
+       struct folio *folio = page_folio(page);
+
        BUG_ON(address < vma->vm_start || address >= vma->vm_end);
        /* increment count (starts at -1) */
-       atomic_set(compound_mapcount_ptr(page), 0);
-       ClearHPageRestoreReserve(page);
+       atomic_set(&folio->_entire_mapcount, 0);
+       folio_clear_hugetlb_restore_reserve(folio);
        __page_set_anon_rmap(page, vma, address, 1);
 }
 #endif /* CONFIG_HUGETLB_PAGE */