mm: convert page_get_anon_vma() to folio_get_anon_vma()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 2 Sep 2022 19:46:50 +0000 (20:46 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:02:54 +0000 (14:02 -0700)
With all callers now passing in a folio, rename the function and convert
all callers.  Removes a couple of calls to compound_head() and a reference
to page->mapping.

Link: https://lkml.kernel.org/r/20220902194653.1739778-55-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/rmap.h
mm/huge_memory.c
mm/migrate.c
mm/rmap.c

index 72b2bcc37f73b3fa68eb1a6a6bcbf8bfc5fec7c3..3d56e3712bb2a2bb7c25d10c48db3ac9ac3ffbba 100644 (file)
@@ -163,7 +163,7 @@ static inline void anon_vma_merge(struct vm_area_struct *vma,
        unlink_anon_vmas(next);
 }
 
-struct anon_vma *page_get_anon_vma(struct page *page);
+struct anon_vma *folio_get_anon_vma(struct folio *folio);
 
 /* RMAP flags, currently only relevant for some anon rmap operations. */
 typedef int __bitwise rmap_t;
index 22949ff6df131ac1657c98e67822837400ce3005..36ef79b851958230f203b62cd45d42f630ed2d0d 100644 (file)
@@ -2649,7 +2649,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
                 * is taken to serialise against parallel split or collapse
                 * operations.
                 */
-               anon_vma = page_get_anon_vma(&folio->page);
+               anon_vma = folio_get_anon_vma(folio);
                if (!anon_vma) {
                        ret = -EBUSY;
                        goto out;
index c1c2d9d9032b9db3d30eecc6d2da7e0253d58ddc..c228afba0963d65e83d71d400a0bceadf0fd6ce3 100644 (file)
@@ -1052,14 +1052,14 @@ static int __unmap_and_move(struct folio *src, struct folio *dst,
         * File Caches may use write_page() or lock_page() in migration, then,
         * just care Anon page here.
         *
-        * Only page_get_anon_vma() understands the subtleties of
+        * Only folio_get_anon_vma() understands the subtleties of
         * getting a hold on an anon_vma from outside one of its mms.
         * But if we cannot get anon_vma, then we won't need it anyway,
         * because that implies that the anon page is no longer mapped
         * (and cannot be remapped so long as we hold the page lock).
         */
        if (folio_test_anon(src) && !folio_test_ksm(src))
-               anon_vma = page_get_anon_vma(&src->page);
+               anon_vma = folio_get_anon_vma(src);
 
        /*
         * Block others from accessing the new page when we get around to
@@ -1298,7 +1298,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
        }
 
        if (folio_test_anon(src))
-               anon_vma = page_get_anon_vma(&src->page);
+               anon_vma = folio_get_anon_vma(src);
 
        if (unlikely(!folio_trylock(dst)))
                goto put_anon;
index d44ff516a208932caba289484e02504ac57d61ab..86511e633fcdafadd041a03beaabf6b37b44195e 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -486,16 +486,16 @@ void __init anon_vma_init(void)
  * if there is a mapcount, we can dereference the anon_vma after observing
  * those.
  */
-struct anon_vma *page_get_anon_vma(struct page *page)
+struct anon_vma *folio_get_anon_vma(struct folio *folio)
 {
        struct anon_vma *anon_vma = NULL;
        unsigned long anon_mapping;
 
        rcu_read_lock();
-       anon_mapping = (unsigned long)READ_ONCE(page->mapping);
+       anon_mapping = (unsigned long)READ_ONCE(folio->mapping);
        if ((anon_mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON)
                goto out;
-       if (!page_mapped(page))
+       if (!folio_mapped(folio))
                goto out;
 
        anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
@@ -505,13 +505,13 @@ struct anon_vma *page_get_anon_vma(struct page *page)
        }
 
        /*
-        * If this page is still mapped, then its anon_vma cannot have been
+        * If this folio is still mapped, then its anon_vma cannot have been
         * freed.  But if it has been unmapped, we have no security against the
         * anon_vma structure being freed and reused (for another anon_vma:
         * SLAB_TYPESAFE_BY_RCU guarantees that - so the atomic_inc_not_zero()
         * above cannot corrupt).
         */
-       if (!page_mapped(page)) {
+       if (!folio_mapped(folio)) {
                rcu_read_unlock();
                put_anon_vma(anon_vma);
                return NULL;
@@ -523,11 +523,11 @@ out:
 }
 
 /*
- * Similar to page_get_anon_vma() except it locks the anon_vma.
+ * Similar to folio_get_anon_vma() except it locks the anon_vma.
  *
  * Its a little more complex as it tries to keep the fast path to a single
  * atomic op -- the trylock. If we fail the trylock, we fall back to getting a
- * reference like with page_get_anon_vma() and then block on the mutex
+ * reference like with folio_get_anon_vma() and then block on the mutex
  * on !rwc->try_lock case.
  */
 struct anon_vma *folio_lock_anon_vma_read(struct folio *folio,