ALSA: usb-audio: Use snd_ctl_rename() to rename a control
[platform/kernel/linux-starfive.git] / mm / migrate.c
index 1ea149f..1379e19 100644 (file)
@@ -625,6 +625,25 @@ EXPORT_SYMBOL(folio_migrate_copy);
  *                    Migration functions
  ***********************************************************/
 
+int migrate_folio_extra(struct address_space *mapping, struct folio *dst,
+               struct folio *src, enum migrate_mode mode, int extra_count)
+{
+       int rc;
+
+       BUG_ON(folio_test_writeback(src));      /* Writeback must be complete */
+
+       rc = folio_migrate_mapping(mapping, dst, src, extra_count);
+
+       if (rc != MIGRATEPAGE_SUCCESS)
+               return rc;
+
+       if (mode != MIGRATE_SYNC_NO_COPY)
+               folio_migrate_copy(dst, src);
+       else
+               folio_migrate_flags(dst, src);
+       return MIGRATEPAGE_SUCCESS;
+}
+
 /**
  * migrate_folio() - Simple folio migration.
  * @mapping: The address_space containing the folio.
@@ -640,20 +659,7 @@ EXPORT_SYMBOL(folio_migrate_copy);
 int migrate_folio(struct address_space *mapping, struct folio *dst,
                struct folio *src, enum migrate_mode mode)
 {
-       int rc;
-
-       BUG_ON(folio_test_writeback(src));      /* Writeback must be complete */
-
-       rc = folio_migrate_mapping(mapping, dst, src, 0);
-
-       if (rc != MIGRATEPAGE_SUCCESS)
-               return rc;
-
-       if (mode != MIGRATE_SYNC_NO_COPY)
-               folio_migrate_copy(dst, src);
-       else
-               folio_migrate_flags(dst, src);
-       return MIGRATEPAGE_SUCCESS;
+       return migrate_folio_extra(mapping, dst, src, mode, 0);
 }
 EXPORT_SYMBOL(migrate_folio);
 
@@ -1052,14 +1058,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
@@ -1263,7 +1269,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
        if (!hugepage_migration_supported(page_hstate(hpage)))
                return -ENOSYS;
 
-       if (page_count(hpage) == 1) {
+       if (folio_ref_count(src) == 1) {
                /* page was freed from under us. So we are done. */
                putback_active_hugepage(hpage);
                return MIGRATEPAGE_SUCCESS;
@@ -1274,7 +1280,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
                return -ENOMEM;
        dst = page_folio(new_hpage);
 
-       if (!trylock_page(hpage)) {
+       if (!folio_trylock(src)) {
                if (!force)
                        goto out;
                switch (mode) {
@@ -1284,29 +1290,29 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
                default:
                        goto out;
                }
-               lock_page(hpage);
+               folio_lock(src);
        }
 
        /*
         * Check for pages which are in the process of being freed.  Without
-        * page_mapping() set, hugetlbfs specific move page routine will not
+        * folio_mapping() set, hugetlbfs specific move page routine will not
         * be called and we could leak usage counts for subpools.
         */
-       if (hugetlb_page_subpool(hpage) && !page_mapping(hpage)) {
+       if (hugetlb_page_subpool(hpage) && !folio_mapping(src)) {
                rc = -EBUSY;
                goto out_unlock;
        }
 
-       if (PageAnon(hpage))
-               anon_vma = page_get_anon_vma(hpage);
+       if (folio_test_anon(src))
+               anon_vma = folio_get_anon_vma(src);
 
-       if (unlikely(!trylock_page(new_hpage)))
+       if (unlikely(!folio_trylock(dst)))
                goto put_anon;
 
-       if (page_mapped(hpage)) {
+       if (folio_mapped(src)) {
                enum ttu_flags ttu = 0;
 
-               if (!PageAnon(hpage)) {
+               if (!folio_test_anon(src)) {
                        /*
                         * In shared mappings, try_to_unmap could potentially
                         * call huge_pmd_unshare.  Because of this, take
@@ -1327,7 +1333,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
                        i_mmap_unlock_write(mapping);
        }
 
-       if (!page_mapped(hpage))
+       if (!folio_mapped(src))
                rc = move_to_new_folio(dst, src, mode);
 
        if (page_was_mapped)
@@ -1335,7 +1341,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
                        rc == MIGRATEPAGE_SUCCESS ? dst : src, false);
 
 unlock_put_anon:
-       unlock_page(new_hpage);
+       folio_unlock(dst);
 
 put_anon:
        if (anon_vma)
@@ -1347,12 +1353,12 @@ put_anon:
        }
 
 out_unlock:
-       unlock_page(hpage);
+       folio_unlock(src);
 out:
        if (rc == MIGRATEPAGE_SUCCESS)
                putback_active_hugepage(hpage);
        else if (rc != -EAGAIN)
-               list_move_tail(&hpage->lru, ret);
+               list_move_tail(&src->lru, ret);
 
        /*
         * If migration was not successful and there's a freeing callback, use