linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] mm: remove MIGRATEPAGE_*
@ 2025-08-11 14:39 David Hildenbrand
  2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: David Hildenbrand @ 2025-08-11 14:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linuxppc-dev, virtualization, linux-fsdevel, linux-aio,
	linux-btrfs, jfs-discussion, David Hildenbrand, Andrew Morton,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Jerrin Shaji George, Arnd Bergmann,
	Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Alexander Viro, Christian Brauner, Jan Kara,
	Benjamin LaHaise, Chris Mason, Josef Bacik, David Sterba,
	Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan, Matthew Brost,
	Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
	Alistair Popple, Minchan Kim, Sergey Senozhatsky

This is against mm/mm-new.

This series gets rid of MIGRATEPAGE_UNMAP, to then convert the remaining
MIGRATEPAGE_SUCCESS usage to simply use 0 instead.

Not sure if it makes sense to split the second patch up, a treewide
cleanup felt more reasonable for this simple change in an area where
I don't expect a lot of churn.

Briefly tested with virtio-mem in a VM, making sure that basic
page migration keeps working.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: "Eugenio Pérez" <eperezma@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Dave Kleikamp <shaggy@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>

David Hildenbrand (2):
  mm/migrate: remove MIGRATEPAGE_UNMAP
  treewide: remove MIGRATEPAGE_SUCCESS

 arch/powerpc/platforms/pseries/cmm.c |  2 +-
 drivers/misc/vmw_balloon.c           |  4 +-
 drivers/virtio/virtio_balloon.c      |  2 +-
 fs/aio.c                             |  2 +-
 fs/btrfs/inode.c                     |  4 +-
 fs/hugetlbfs/inode.c                 |  4 +-
 fs/jfs/jfs_metapage.c                |  8 +--
 include/linux/migrate.h              | 11 +---
 mm/migrate.c                         | 80 ++++++++++++++--------------
 mm/migrate_device.c                  |  2 +-
 mm/zsmalloc.c                        |  4 +-
 11 files changed, 56 insertions(+), 67 deletions(-)


base-commit: 53c448023185717d0ed56b5546dc2be405da92ff
-- 
2.50.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP
  2025-08-11 14:39 [PATCH v1 0/2] mm: remove MIGRATEPAGE_* David Hildenbrand
@ 2025-08-11 14:39 ` David Hildenbrand
  2025-08-11 18:13   ` Zi Yan
  2025-08-13  5:05   ` Lance Yang
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
  2025-08-12  1:29 ` [PATCH v1 0/2] mm: remove MIGRATEPAGE_* Huang, Ying
  2 siblings, 2 replies; 13+ messages in thread
From: David Hildenbrand @ 2025-08-11 14:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linuxppc-dev, virtualization, linux-fsdevel, linux-aio,
	linux-btrfs, jfs-discussion, David Hildenbrand, Andrew Morton,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Jerrin Shaji George, Arnd Bergmann,
	Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Alexander Viro, Christian Brauner, Jan Kara,
	Benjamin LaHaise, Chris Mason, Josef Bacik, David Sterba,
	Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan, Matthew Brost,
	Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
	Alistair Popple, Minchan Kim, Sergey Senozhatsky

migrate_folio_unmap() is the only user of MIGRATEPAGE_UNMAP. We want to
remove MIGRATEPAGE_* completely.

It's rather weird to have a generic MIGRATEPAGE_UNMAP, documented to be
returned from address-space callbacks, when it's only used for an
internal helper.

Let's start by having only a single "success" return value for
migrate_folio_unmap() -- 0 -- by moving the "folio was already freed"
check into the single caller.

There is a remaining comment for PG_isolated, which we renamed to
PG_movable_ops_isolated recently and forgot to update.

While we might still run into that case with zsmalloc, it's something we
want to get rid of soon. So let's just focus that optimization on real
folios only for now by excluding movable_ops pages. Note that concurrent
freeing can happen at any time and this "already freed" check is not
relevant for correctness.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 include/linux/migrate.h |  1 -
 mm/migrate.c            | 40 ++++++++++++++++++++--------------------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index acadd41e0b5cf..40f2b5a37efbb 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -18,7 +18,6 @@ struct migration_target_control;
  * - zero on page migration success;
  */
 #define MIGRATEPAGE_SUCCESS		0
-#define MIGRATEPAGE_UNMAP		1
 
 /**
  * struct movable_operations - Driver page migration
diff --git a/mm/migrate.c b/mm/migrate.c
index 425401b2d4e14..e9dacf1028dc7 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1176,16 +1176,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
 	bool locked = false;
 	bool dst_locked = false;
 
-	if (folio_ref_count(src) == 1) {
-		/* Folio was freed from under us. So we are done. */
-		folio_clear_active(src);
-		folio_clear_unevictable(src);
-		/* free_pages_prepare() will clear PG_isolated. */
-		list_del(&src->lru);
-		migrate_folio_done(src, reason);
-		return MIGRATEPAGE_SUCCESS;
-	}
-
 	dst = get_new_folio(src, private);
 	if (!dst)
 		return -ENOMEM;
@@ -1275,7 +1265,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
 
 	if (unlikely(page_has_movable_ops(&src->page))) {
 		__migrate_folio_record(dst, old_page_state, anon_vma);
-		return MIGRATEPAGE_UNMAP;
+		return 0;
 	}
 
 	/*
@@ -1305,7 +1295,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
 
 	if (!folio_mapped(src)) {
 		__migrate_folio_record(dst, old_page_state, anon_vma);
-		return MIGRATEPAGE_UNMAP;
+		return 0;
 	}
 
 out:
@@ -1848,14 +1838,28 @@ static int migrate_pages_batch(struct list_head *from,
 				continue;
 			}
 
+			/*
+			 * If we are holding the last folio reference, the folio
+			 * was freed from under us, so just drop our reference.
+			 */
+			if (likely(!page_has_movable_ops(&folio->page)) &&
+			    folio_ref_count(folio) == 1) {
+				folio_clear_active(folio);
+				folio_clear_unevictable(folio);
+				list_del(&folio->lru);
+				migrate_folio_done(folio, reason);
+				stats->nr_succeeded += nr_pages;
+				stats->nr_thp_succeeded += is_thp;
+				continue;
+			}
+
 			rc = migrate_folio_unmap(get_new_folio, put_new_folio,
 					private, folio, &dst, mode, reason,
 					ret_folios);
 			/*
 			 * The rules are:
-			 *	Success: folio will be freed
-			 *	Unmap: folio will be put on unmap_folios list,
-			 *	       dst folio put on dst_folios list
+			 *	0: folio will be put on unmap_folios list,
+			 *	   dst folio put on dst_folios list
 			 *	-EAGAIN: stay on the from list
 			 *	-ENOMEM: stay on the from list
 			 *	Other errno: put on ret_folios list
@@ -1905,11 +1909,7 @@ static int migrate_pages_batch(struct list_head *from,
 				thp_retry += is_thp;
 				nr_retry_pages += nr_pages;
 				break;
-			case MIGRATEPAGE_SUCCESS:
-				stats->nr_succeeded += nr_pages;
-				stats->nr_thp_succeeded += is_thp;
-				break;
-			case MIGRATEPAGE_UNMAP:
+			case 0:
 				list_move_tail(&folio->lru, &unmap_folios);
 				list_add_tail(&dst->lru, &dst_folios);
 				break;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 [PATCH v1 0/2] mm: remove MIGRATEPAGE_* David Hildenbrand
  2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
@ 2025-08-11 14:39 ` David Hildenbrand
  2025-08-11 14:47   ` Dave Kleikamp
                     ` (5 more replies)
  2025-08-12  1:29 ` [PATCH v1 0/2] mm: remove MIGRATEPAGE_* Huang, Ying
  2 siblings, 6 replies; 13+ messages in thread
From: David Hildenbrand @ 2025-08-11 14:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linuxppc-dev, virtualization, linux-fsdevel, linux-aio,
	linux-btrfs, jfs-discussion, David Hildenbrand, Andrew Morton,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Jerrin Shaji George, Arnd Bergmann,
	Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Alexander Viro, Christian Brauner, Jan Kara,
	Benjamin LaHaise, Chris Mason, Josef Bacik, David Sterba,
	Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan, Matthew Brost,
	Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
	Alistair Popple, Minchan Kim, Sergey Senozhatsky

At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
return value that the code uses and expects.

Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
for success.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/powerpc/platforms/pseries/cmm.c |  2 +-
 drivers/misc/vmw_balloon.c           |  4 +--
 drivers/virtio/virtio_balloon.c      |  2 +-
 fs/aio.c                             |  2 +-
 fs/btrfs/inode.c                     |  4 +--
 fs/hugetlbfs/inode.c                 |  4 +--
 fs/jfs/jfs_metapage.c                |  8 +++---
 include/linux/migrate.h              | 10 +------
 mm/migrate.c                         | 40 +++++++++++++---------------
 mm/migrate_device.c                  |  2 +-
 mm/zsmalloc.c                        |  4 +--
 11 files changed, 36 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index 5e0a718d1be7b..0823fa2da1516 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -545,7 +545,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
 	/* balloon page list reference */
 	put_page(page);
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 
 static void cmm_balloon_compaction_init(void)
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 6653fc53c951c..6df51ee8db621 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -1806,7 +1806,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
 		 * the list after acquiring the lock.
 		 */
 		get_page(newpage);
-		ret = MIGRATEPAGE_SUCCESS;
+		ret = 0;
 	}
 
 	/* Update the balloon list under the @pages_lock */
@@ -1817,7 +1817,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
 	 * If we succeed just insert it to the list and update the statistics
 	 * under the lock.
 	 */
-	if (ret == MIGRATEPAGE_SUCCESS) {
+	if (!ret) {
 		balloon_page_insert(&b->b_dev_info, newpage);
 		__count_vm_event(BALLOON_MIGRATE);
 	}
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index e299e18346a30..eae65136cdfb5 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -875,7 +875,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
 	balloon_page_finalize(page);
 	put_page(page); /* balloon reference */
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 #endif /* CONFIG_BALLOON_COMPACTION */
 
diff --git a/fs/aio.c b/fs/aio.c
index 7fc7b6221312c..059e03cfa088c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -445,7 +445,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
 	folio_get(dst);
 
 	rc = folio_migrate_mapping(mapping, dst, src, 1);
-	if (rc != MIGRATEPAGE_SUCCESS) {
+	if (rc) {
 		folio_put(dst);
 		goto out_unlock;
 	}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b77dd22b8cdbe..1d64fee6f59e6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7411,7 +7411,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
 {
 	int ret = filemap_migrate_folio(mapping, dst, src, mode);
 
-	if (ret != MIGRATEPAGE_SUCCESS)
+	if (ret)
 		return ret;
 
 	if (folio_test_ordered(src)) {
@@ -7419,7 +7419,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
 		folio_set_ordered(dst);
 	}
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 #else
 #define btrfs_migrate_folio NULL
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 09d4baef29cf9..34d496a2b7de6 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1052,7 +1052,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
 	int rc;
 
 	rc = migrate_huge_page_move_mapping(mapping, dst, src);
-	if (rc != MIGRATEPAGE_SUCCESS)
+	if (rc)
 		return rc;
 
 	if (hugetlb_folio_subpool(src)) {
@@ -1063,7 +1063,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
 
 	folio_migrate_flags(dst, src);
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 #else
 #define hugetlbfs_migrate_folio NULL
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index b98cf3bb6c1fe..871cf4fb36366 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -169,7 +169,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
 	}
 
 	rc = filemap_migrate_folio(mapping, dst, src, mode);
-	if (rc != MIGRATEPAGE_SUCCESS)
+	if (rc)
 		return rc;
 
 	for (i = 0; i < MPS_PER_PAGE; i++) {
@@ -199,7 +199,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
 		}
 	}
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 #endif	/* CONFIG_MIGRATION */
 
@@ -242,7 +242,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
 		return -EAGAIN;
 
 	rc = filemap_migrate_folio(mapping, dst, src, mode);
-	if (rc != MIGRATEPAGE_SUCCESS)
+	if (rc)
 		return rc;
 
 	if (unlikely(insert_metapage(dst, mp)))
@@ -253,7 +253,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
 	mp->folio = dst;
 	remove_metapage(src, mp);
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 #endif	/* CONFIG_MIGRATION */
 
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 40f2b5a37efbb..02f11704fb686 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -12,13 +12,6 @@ typedef void free_folio_t(struct folio *folio, unsigned long private);
 
 struct migration_target_control;
 
-/*
- * Return values from addresss_space_operations.migratepage():
- * - negative errno on page migration failure;
- * - zero on page migration success;
- */
-#define MIGRATEPAGE_SUCCESS		0
-
 /**
  * struct movable_operations - Driver page migration
  * @isolate_page:
@@ -34,8 +27,7 @@ struct migration_target_control;
  * @src page.  The driver should copy the contents of the
  * @src page to the @dst page and set up the fields of @dst page.
  * Both pages are locked.
- * If page migration is successful, the driver should
- * return MIGRATEPAGE_SUCCESS.
+ * If page migration is successful, the driver should return 0.
  * If the driver cannot migrate the page at the moment, it can return
  * -EAGAIN.  The VM interprets this as a temporary migration failure and
  * will retry it later.  Any other error value is a permanent migration
diff --git a/mm/migrate.c b/mm/migrate.c
index e9dacf1028dc7..2db4974178e6a 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -209,18 +209,17 @@ static void putback_movable_ops_page(struct page *page)
  * src and dst are also released by migration core. These pages will not be
  * folios in the future, so that must be reworked.
  *
- * Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error
- * code.
+ * Returns 0 on success, otherwise a negative error code.
  */
 static int migrate_movable_ops_page(struct page *dst, struct page *src,
 		enum migrate_mode mode)
 {
-	int rc = MIGRATEPAGE_SUCCESS;
+	int rc;
 
 	VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src);
 	VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src);
 	rc = page_movable_ops(src)->migrate_page(dst, src, mode);
-	if (rc == MIGRATEPAGE_SUCCESS)
+	if (!rc)
 		ClearPageMovableOpsIsolated(src);
 	return rc;
 }
@@ -565,7 +564,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
 		if (folio_test_swapbacked(folio))
 			__folio_set_swapbacked(newfolio);
 
-		return MIGRATEPAGE_SUCCESS;
+		return 0;
 	}
 
 	oldzone = folio_zone(folio);
@@ -666,7 +665,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
 	}
 	local_irq_enable();
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 
 int folio_migrate_mapping(struct address_space *mapping,
@@ -715,7 +714,7 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
 
 	xas_unlock_irq(&xas);
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 
 /*
@@ -831,14 +830,14 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
 		return rc;
 
 	rc = __folio_migrate_mapping(mapping, dst, src, expected_count);
-	if (rc != MIGRATEPAGE_SUCCESS)
+	if (rc)
 		return rc;
 
 	if (src_private)
 		folio_attach_private(dst, folio_detach_private(src));
 
 	folio_migrate_flags(dst, src);
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 
 /**
@@ -945,7 +944,7 @@ static int __buffer_migrate_folio(struct address_space *mapping,
 	}
 
 	rc = filemap_migrate_folio(mapping, dst, src, mode);
-	if (rc != MIGRATEPAGE_SUCCESS)
+	if (rc)
 		goto unlock_buffers;
 
 	bh = head;
@@ -1049,7 +1048,7 @@ static int fallback_migrate_folio(struct address_space *mapping,
  *
  * Return value:
  *   < 0 - error code
- *  MIGRATEPAGE_SUCCESS - success
+ *     0 - success
  */
 static int move_to_new_folio(struct folio *dst, struct folio *src,
 				enum migrate_mode mode)
@@ -1077,7 +1076,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
 	else
 		rc = fallback_migrate_folio(mapping, dst, src, mode);
 
-	if (rc == MIGRATEPAGE_SUCCESS) {
+	if (!rc) {
 		/*
 		 * For pagecache folios, src->mapping must be cleared before src
 		 * is freed. Anonymous folios must stay anonymous until freed.
@@ -1427,7 +1426,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
 	if (folio_ref_count(src) == 1) {
 		/* page was freed from under us. So we are done. */
 		folio_putback_hugetlb(src);
-		return MIGRATEPAGE_SUCCESS;
+		return 0;
 	}
 
 	dst = get_new_folio(src, private);
@@ -1490,8 +1489,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
 		rc = move_to_new_folio(dst, src, mode);
 
 	if (page_was_mapped)
-		remove_migration_ptes(src,
-			rc == MIGRATEPAGE_SUCCESS ? dst : src, 0);
+		remove_migration_ptes(src, !rc ? dst : src, 0);
 
 unlock_put_anon:
 	folio_unlock(dst);
@@ -1500,7 +1498,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
 	if (anon_vma)
 		put_anon_vma(anon_vma);
 
-	if (rc == MIGRATEPAGE_SUCCESS) {
+	if (!rc) {
 		move_hugetlb_state(src, dst, reason);
 		put_new_folio = NULL;
 	}
@@ -1508,7 +1506,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
 out_unlock:
 	folio_unlock(src);
 out:
-	if (rc == MIGRATEPAGE_SUCCESS)
+	if (!rc)
 		folio_putback_hugetlb(src);
 	else if (rc != -EAGAIN)
 		list_move_tail(&src->lru, ret);
@@ -1618,7 +1616,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
 						      reason, ret_folios);
 			/*
 			 * The rules are:
-			 *	Success: hugetlb folio will be put back
+			 *	0: hugetlb folio will be put back
 			 *	-EAGAIN: stay on the from list
 			 *	-ENOMEM: stay on the from list
 			 *	Other errno: put on ret_folios list
@@ -1635,7 +1633,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
 				retry++;
 				nr_retry_pages += nr_pages;
 				break;
-			case MIGRATEPAGE_SUCCESS:
+			case 0:
 				stats->nr_succeeded += nr_pages;
 				break;
 			default:
@@ -1689,7 +1687,7 @@ static void migrate_folios_move(struct list_head *src_folios,
 				reason, ret_folios);
 		/*
 		 * The rules are:
-		 *	Success: folio will be freed
+		 *	0: folio will be freed
 		 *	-EAGAIN: stay on the unmap_folios list
 		 *	Other errno: put on ret_folios list
 		 */
@@ -1699,7 +1697,7 @@ static void migrate_folios_move(struct list_head *src_folios,
 			*thp_retry += is_thp;
 			*nr_retry_pages += nr_pages;
 			break;
-		case MIGRATEPAGE_SUCCESS:
+		case 0:
 			stats->nr_succeeded += nr_pages;
 			stats->nr_thp_succeeded += is_thp;
 			break;
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index e05e14d6eacdb..abd9f6850db65 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -778,7 +778,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
 		if (migrate && migrate->fault_page == page)
 			extra_cnt = 1;
 		r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
-		if (r != MIGRATEPAGE_SUCCESS)
+		if (r)
 			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
 		else
 			folio_migrate_flags(newfolio, folio);
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2c5e56a653544..84eb91d47a226 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1746,7 +1746,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
 	 * instead.
 	 */
 	if (!zpdesc->zspage)
-		return MIGRATEPAGE_SUCCESS;
+		return 0;
 
 	/* The page is locked, so this pointer must remain valid */
 	zspage = get_zspage(zpdesc);
@@ -1813,7 +1813,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
 	reset_zpdesc(zpdesc);
 	zpdesc_put(zpdesc);
 
-	return MIGRATEPAGE_SUCCESS;
+	return 0;
 }
 
 static void zs_page_putback(struct page *page)
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
@ 2025-08-11 14:47   ` Dave Kleikamp
  2025-08-11 18:18   ` Zi Yan
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Dave Kleikamp @ 2025-08-11 14:47 UTC (permalink / raw)
  To: David Hildenbrand, linux-kernel
  Cc: linux-mm, linuxppc-dev, virtualization, linux-fsdevel, linux-aio,
	linux-btrfs, jfs-discussion, Andrew Morton, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Jerrin Shaji George, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Jason Wang, Xuan Zhuo, Eugenio Pérez,
	Alexander Viro, Christian Brauner, Jan Kara, Benjamin LaHaise,
	Chris Mason, Josef Bacik, David Sterba, Muchun Song,
	Oscar Salvador, Zi Yan, Matthew Brost, Joshua Hahn, Rakie Kim,
	Byungchul Park, Gregory Price, Ying Huang, Alistair Popple,
	Minchan Kim, Sergey Senozhatsky

On 8/11/25 9:39AM, David Hildenbrand wrote:
> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
> 
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

For jfs:

Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
> ---
>   arch/powerpc/platforms/pseries/cmm.c |  2 +-
>   drivers/misc/vmw_balloon.c           |  4 +--
>   drivers/virtio/virtio_balloon.c      |  2 +-
>   fs/aio.c                             |  2 +-
>   fs/btrfs/inode.c                     |  4 +--
>   fs/hugetlbfs/inode.c                 |  4 +--
>   fs/jfs/jfs_metapage.c                |  8 +++---
>   include/linux/migrate.h              | 10 +------
>   mm/migrate.c                         | 40 +++++++++++++---------------
>   mm/migrate_device.c                  |  2 +-
>   mm/zsmalloc.c                        |  4 +--
>   11 files changed, 36 insertions(+), 46 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
> index 5e0a718d1be7b..0823fa2da1516 100644
> --- a/arch/powerpc/platforms/pseries/cmm.c
> +++ b/arch/powerpc/platforms/pseries/cmm.c
> @@ -545,7 +545,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
>   	/* balloon page list reference */
>   	put_page(page);
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   
>   static void cmm_balloon_compaction_init(void)
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index 6653fc53c951c..6df51ee8db621 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -1806,7 +1806,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
>   		 * the list after acquiring the lock.
>   		 */
>   		get_page(newpage);
> -		ret = MIGRATEPAGE_SUCCESS;
> +		ret = 0;
>   	}
>   
>   	/* Update the balloon list under the @pages_lock */
> @@ -1817,7 +1817,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
>   	 * If we succeed just insert it to the list and update the statistics
>   	 * under the lock.
>   	 */
> -	if (ret == MIGRATEPAGE_SUCCESS) {
> +	if (!ret) {
>   		balloon_page_insert(&b->b_dev_info, newpage);
>   		__count_vm_event(BALLOON_MIGRATE);
>   	}
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index e299e18346a30..eae65136cdfb5 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -875,7 +875,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
>   	balloon_page_finalize(page);
>   	put_page(page); /* balloon reference */
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   #endif /* CONFIG_BALLOON_COMPACTION */
>   
> diff --git a/fs/aio.c b/fs/aio.c
> index 7fc7b6221312c..059e03cfa088c 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -445,7 +445,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
>   	folio_get(dst);
>   
>   	rc = folio_migrate_mapping(mapping, dst, src, 1);
> -	if (rc != MIGRATEPAGE_SUCCESS) {
> +	if (rc) {
>   		folio_put(dst);
>   		goto out_unlock;
>   	}
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index b77dd22b8cdbe..1d64fee6f59e6 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7411,7 +7411,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
>   {
>   	int ret = filemap_migrate_folio(mapping, dst, src, mode);
>   
> -	if (ret != MIGRATEPAGE_SUCCESS)
> +	if (ret)
>   		return ret;
>   
>   	if (folio_test_ordered(src)) {
> @@ -7419,7 +7419,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
>   		folio_set_ordered(dst);
>   	}
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   #else
>   #define btrfs_migrate_folio NULL
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 09d4baef29cf9..34d496a2b7de6 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1052,7 +1052,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
>   	int rc;
>   
>   	rc = migrate_huge_page_move_mapping(mapping, dst, src);
> -	if (rc != MIGRATEPAGE_SUCCESS)
> +	if (rc)
>   		return rc;
>   
>   	if (hugetlb_folio_subpool(src)) {
> @@ -1063,7 +1063,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
>   
>   	folio_migrate_flags(dst, src);
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   #else
>   #define hugetlbfs_migrate_folio NULL
> diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
> index b98cf3bb6c1fe..871cf4fb36366 100644
> --- a/fs/jfs/jfs_metapage.c
> +++ b/fs/jfs/jfs_metapage.c
> @@ -169,7 +169,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>   	}
>   
>   	rc = filemap_migrate_folio(mapping, dst, src, mode);
> -	if (rc != MIGRATEPAGE_SUCCESS)
> +	if (rc)
>   		return rc;
>   
>   	for (i = 0; i < MPS_PER_PAGE; i++) {
> @@ -199,7 +199,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>   		}
>   	}
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   #endif	/* CONFIG_MIGRATION */
>   
> @@ -242,7 +242,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>   		return -EAGAIN;
>   
>   	rc = filemap_migrate_folio(mapping, dst, src, mode);
> -	if (rc != MIGRATEPAGE_SUCCESS)
> +	if (rc)
>   		return rc;
>   
>   	if (unlikely(insert_metapage(dst, mp)))
> @@ -253,7 +253,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>   	mp->folio = dst;
>   	remove_metapage(src, mp);
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   #endif	/* CONFIG_MIGRATION */
>   
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index 40f2b5a37efbb..02f11704fb686 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -12,13 +12,6 @@ typedef void free_folio_t(struct folio *folio, unsigned long private);
>   
>   struct migration_target_control;
>   
> -/*
> - * Return values from addresss_space_operations.migratepage():
> - * - negative errno on page migration failure;
> - * - zero on page migration success;
> - */
> -#define MIGRATEPAGE_SUCCESS		0
> -
>   /**
>    * struct movable_operations - Driver page migration
>    * @isolate_page:
> @@ -34,8 +27,7 @@ struct migration_target_control;
>    * @src page.  The driver should copy the contents of the
>    * @src page to the @dst page and set up the fields of @dst page.
>    * Both pages are locked.
> - * If page migration is successful, the driver should
> - * return MIGRATEPAGE_SUCCESS.
> + * If page migration is successful, the driver should return 0.
>    * If the driver cannot migrate the page at the moment, it can return
>    * -EAGAIN.  The VM interprets this as a temporary migration failure and
>    * will retry it later.  Any other error value is a permanent migration
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e9dacf1028dc7..2db4974178e6a 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -209,18 +209,17 @@ static void putback_movable_ops_page(struct page *page)
>    * src and dst are also released by migration core. These pages will not be
>    * folios in the future, so that must be reworked.
>    *
> - * Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error
> - * code.
> + * Returns 0 on success, otherwise a negative error code.
>    */
>   static int migrate_movable_ops_page(struct page *dst, struct page *src,
>   		enum migrate_mode mode)
>   {
> -	int rc = MIGRATEPAGE_SUCCESS;
> +	int rc;
>   
>   	VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src);
>   	VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src);
>   	rc = page_movable_ops(src)->migrate_page(dst, src, mode);
> -	if (rc == MIGRATEPAGE_SUCCESS)
> +	if (!rc)
>   		ClearPageMovableOpsIsolated(src);
>   	return rc;
>   }
> @@ -565,7 +564,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
>   		if (folio_test_swapbacked(folio))
>   			__folio_set_swapbacked(newfolio);
>   
> -		return MIGRATEPAGE_SUCCESS;
> +		return 0;
>   	}
>   
>   	oldzone = folio_zone(folio);
> @@ -666,7 +665,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
>   	}
>   	local_irq_enable();
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   
>   int folio_migrate_mapping(struct address_space *mapping,
> @@ -715,7 +714,7 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
>   
>   	xas_unlock_irq(&xas);
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   
>   /*
> @@ -831,14 +830,14 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
>   		return rc;
>   
>   	rc = __folio_migrate_mapping(mapping, dst, src, expected_count);
> -	if (rc != MIGRATEPAGE_SUCCESS)
> +	if (rc)
>   		return rc;
>   
>   	if (src_private)
>   		folio_attach_private(dst, folio_detach_private(src));
>   
>   	folio_migrate_flags(dst, src);
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   
>   /**
> @@ -945,7 +944,7 @@ static int __buffer_migrate_folio(struct address_space *mapping,
>   	}
>   
>   	rc = filemap_migrate_folio(mapping, dst, src, mode);
> -	if (rc != MIGRATEPAGE_SUCCESS)
> +	if (rc)
>   		goto unlock_buffers;
>   
>   	bh = head;
> @@ -1049,7 +1048,7 @@ static int fallback_migrate_folio(struct address_space *mapping,
>    *
>    * Return value:
>    *   < 0 - error code
> - *  MIGRATEPAGE_SUCCESS - success
> + *     0 - success
>    */
>   static int move_to_new_folio(struct folio *dst, struct folio *src,
>   				enum migrate_mode mode)
> @@ -1077,7 +1076,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
>   	else
>   		rc = fallback_migrate_folio(mapping, dst, src, mode);
>   
> -	if (rc == MIGRATEPAGE_SUCCESS) {
> +	if (!rc) {
>   		/*
>   		 * For pagecache folios, src->mapping must be cleared before src
>   		 * is freed. Anonymous folios must stay anonymous until freed.
> @@ -1427,7 +1426,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>   	if (folio_ref_count(src) == 1) {
>   		/* page was freed from under us. So we are done. */
>   		folio_putback_hugetlb(src);
> -		return MIGRATEPAGE_SUCCESS;
> +		return 0;
>   	}
>   
>   	dst = get_new_folio(src, private);
> @@ -1490,8 +1489,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>   		rc = move_to_new_folio(dst, src, mode);
>   
>   	if (page_was_mapped)
> -		remove_migration_ptes(src,
> -			rc == MIGRATEPAGE_SUCCESS ? dst : src, 0);
> +		remove_migration_ptes(src, !rc ? dst : src, 0);
>   
>   unlock_put_anon:
>   	folio_unlock(dst);
> @@ -1500,7 +1498,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>   	if (anon_vma)
>   		put_anon_vma(anon_vma);
>   
> -	if (rc == MIGRATEPAGE_SUCCESS) {
> +	if (!rc) {
>   		move_hugetlb_state(src, dst, reason);
>   		put_new_folio = NULL;
>   	}
> @@ -1508,7 +1506,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>   out_unlock:
>   	folio_unlock(src);
>   out:
> -	if (rc == MIGRATEPAGE_SUCCESS)
> +	if (!rc)
>   		folio_putback_hugetlb(src);
>   	else if (rc != -EAGAIN)
>   		list_move_tail(&src->lru, ret);
> @@ -1618,7 +1616,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
>   						      reason, ret_folios);
>   			/*
>   			 * The rules are:
> -			 *	Success: hugetlb folio will be put back
> +			 *	0: hugetlb folio will be put back
>   			 *	-EAGAIN: stay on the from list
>   			 *	-ENOMEM: stay on the from list
>   			 *	Other errno: put on ret_folios list
> @@ -1635,7 +1633,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
>   				retry++;
>   				nr_retry_pages += nr_pages;
>   				break;
> -			case MIGRATEPAGE_SUCCESS:
> +			case 0:
>   				stats->nr_succeeded += nr_pages;
>   				break;
>   			default:
> @@ -1689,7 +1687,7 @@ static void migrate_folios_move(struct list_head *src_folios,
>   				reason, ret_folios);
>   		/*
>   		 * The rules are:
> -		 *	Success: folio will be freed
> +		 *	0: folio will be freed
>   		 *	-EAGAIN: stay on the unmap_folios list
>   		 *	Other errno: put on ret_folios list
>   		 */
> @@ -1699,7 +1697,7 @@ static void migrate_folios_move(struct list_head *src_folios,
>   			*thp_retry += is_thp;
>   			*nr_retry_pages += nr_pages;
>   			break;
> -		case MIGRATEPAGE_SUCCESS:
> +		case 0:
>   			stats->nr_succeeded += nr_pages;
>   			stats->nr_thp_succeeded += is_thp;
>   			break;
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index e05e14d6eacdb..abd9f6850db65 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -778,7 +778,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>   		if (migrate && migrate->fault_page == page)
>   			extra_cnt = 1;
>   		r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
> -		if (r != MIGRATEPAGE_SUCCESS)
> +		if (r)
>   			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
>   		else
>   			folio_migrate_flags(newfolio, folio);
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 2c5e56a653544..84eb91d47a226 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -1746,7 +1746,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
>   	 * instead.
>   	 */
>   	if (!zpdesc->zspage)
> -		return MIGRATEPAGE_SUCCESS;
> +		return 0;
>   
>   	/* The page is locked, so this pointer must remain valid */
>   	zspage = get_zspage(zpdesc);
> @@ -1813,7 +1813,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
>   	reset_zpdesc(zpdesc);
>   	zpdesc_put(zpdesc);
>   
> -	return MIGRATEPAGE_SUCCESS;
> +	return 0;
>   }
>   
>   static void zs_page_putback(struct page *page)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP
  2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
@ 2025-08-11 18:13   ` Zi Yan
  2025-08-13  5:05   ` Lance Yang
  1 sibling, 0 replies; 13+ messages in thread
From: Zi Yan @ 2025-08-11 18:13 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On 11 Aug 2025, at 10:39, David Hildenbrand wrote:

> migrate_folio_unmap() is the only user of MIGRATEPAGE_UNMAP. We want to
> remove MIGRATEPAGE_* completely.
>
> It's rather weird to have a generic MIGRATEPAGE_UNMAP, documented to be
> returned from address-space callbacks, when it's only used for an
> internal helper.
>
> Let's start by having only a single "success" return value for
> migrate_folio_unmap() -- 0 -- by moving the "folio was already freed"
> check into the single caller.
>
> There is a remaining comment for PG_isolated, which we renamed to
> PG_movable_ops_isolated recently and forgot to update.
>
> While we might still run into that case with zsmalloc, it's something we
> want to get rid of soon. So let's just focus that optimization on real
> folios only for now by excluding movable_ops pages. Note that concurrent
> freeing can happen at any time and this "already freed" check is not
> relevant for correctness.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  include/linux/migrate.h |  1 -
>  mm/migrate.c            | 40 ++++++++++++++++++++--------------------
>  2 files changed, 20 insertions(+), 21 deletions(-)
>
LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
  2025-08-11 14:47   ` Dave Kleikamp
@ 2025-08-11 18:18   ` Zi Yan
  2025-08-12  3:58   ` Sergey Senozhatsky
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Zi Yan @ 2025-08-11 18:18 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On 11 Aug 2025, at 10:39, David Hildenbrand wrote:

> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
>
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/powerpc/platforms/pseries/cmm.c |  2 +-
>  drivers/misc/vmw_balloon.c           |  4 +--
>  drivers/virtio/virtio_balloon.c      |  2 +-
>  fs/aio.c                             |  2 +-
>  fs/btrfs/inode.c                     |  4 +--
>  fs/hugetlbfs/inode.c                 |  4 +--
>  fs/jfs/jfs_metapage.c                |  8 +++---



>  include/linux/migrate.h              | 10 +------
>  mm/migrate.c                         | 40 +++++++++++++---------------
>  mm/migrate_device.c                  |  2 +-
>  mm/zsmalloc.c                        |  4 +--
>  11 files changed, 36 insertions(+), 46 deletions(-)
>

For the mm part, LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 0/2] mm: remove MIGRATEPAGE_*
  2025-08-11 14:39 [PATCH v1 0/2] mm: remove MIGRATEPAGE_* David Hildenbrand
  2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
@ 2025-08-12  1:29 ` Huang, Ying
  2 siblings, 0 replies; 13+ messages in thread
From: Huang, Ying @ 2025-08-12  1:29 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Alistair Popple, Minchan Kim, Sergey Senozhatsky

Hi, David,

David Hildenbrand <david@redhat.com> writes:

> This is against mm/mm-new.
>
> This series gets rid of MIGRATEPAGE_UNMAP, to then convert the remaining
> MIGRATEPAGE_SUCCESS usage to simply use 0 instead.
>
> Not sure if it makes sense to split the second patch up, a treewide
> cleanup felt more reasonable for this simple change in an area where
> I don't expect a lot of churn.
>
> Briefly tested with virtio-mem in a VM, making sure that basic
> page migration keeps working.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Cc: "Eugenio Pérez" <eperezma@redhat.com>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Benjamin LaHaise <bcrl@kvack.org>
> Cc: Chris Mason <clm@fb.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Dave Kleikamp <shaggy@kernel.org>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
> Cc: Rakie Kim <rakie.kim@sk.com>
> Cc: Byungchul Park <byungchul@sk.com>
> Cc: Gregory Price <gourry@gourry.net>
> Cc: Ying Huang <ying.huang@linux.alibaba.com>
> Cc: Alistair Popple <apopple@nvidia.com>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
>
> David Hildenbrand (2):
>   mm/migrate: remove MIGRATEPAGE_UNMAP
>   treewide: remove MIGRATEPAGE_SUCCESS

LGTM.  Feel free to add my

Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>

for the whole series in the future versions.

>  arch/powerpc/platforms/pseries/cmm.c |  2 +-
>  drivers/misc/vmw_balloon.c           |  4 +-
>  drivers/virtio/virtio_balloon.c      |  2 +-
>  fs/aio.c                             |  2 +-
>  fs/btrfs/inode.c                     |  4 +-
>  fs/hugetlbfs/inode.c                 |  4 +-
>  fs/jfs/jfs_metapage.c                |  8 +--
>  include/linux/migrate.h              | 11 +---
>  mm/migrate.c                         | 80 ++++++++++++++--------------
>  mm/migrate_device.c                  |  2 +-
>  mm/zsmalloc.c                        |  4 +-
>  11 files changed, 56 insertions(+), 67 deletions(-)
>
>
> base-commit: 53c448023185717d0ed56b5546dc2be405da92ff

---
Best Regards,
Huang, Ying

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
  2025-08-11 14:47   ` Dave Kleikamp
  2025-08-11 18:18   ` Zi Yan
@ 2025-08-12  3:58   ` Sergey Senozhatsky
  2025-08-12  6:32   ` Greg Kroah-Hartman
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2025-08-12  3:58 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On (25/08/11 16:39), David Hildenbrand wrote:
> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
> 
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

FWIW,
Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org> [zsmalloc]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
                     ` (2 preceding siblings ...)
  2025-08-12  3:58   ` Sergey Senozhatsky
@ 2025-08-12  6:32   ` Greg Kroah-Hartman
  2025-08-12  8:13   ` David Sterba
  2025-08-13  1:32   ` Byungchul Park
  5 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2025-08-12  6:32 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Alexander Viro, Christian Brauner, Jan Kara,
	Benjamin LaHaise, Chris Mason, Josef Bacik, David Sterba,
	Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan, Matthew Brost,
	Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
	Alistair Popple, Minchan Kim, Sergey Senozhatsky

On Mon, Aug 11, 2025 at 04:39:48PM +0200, David Hildenbrand wrote:
> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
> 
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/powerpc/platforms/pseries/cmm.c |  2 +-
>  drivers/misc/vmw_balloon.c           |  4 +--
>  drivers/virtio/virtio_balloon.c      |  2 +-
>  fs/aio.c                             |  2 +-
>  fs/btrfs/inode.c                     |  4 +--
>  fs/hugetlbfs/inode.c                 |  4 +--
>  fs/jfs/jfs_metapage.c                |  8 +++---
>  include/linux/migrate.h              | 10 +------
>  mm/migrate.c                         | 40 +++++++++++++---------------
>  mm/migrate_device.c                  |  2 +-
>  mm/zsmalloc.c                        |  4 +--
>  11 files changed, 36 insertions(+), 46 deletions(-)

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
                     ` (3 preceding siblings ...)
  2025-08-12  6:32   ` Greg Kroah-Hartman
@ 2025-08-12  8:13   ` David Sterba
  2025-08-13  1:32   ` Byungchul Park
  5 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-08-12  8:13 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On Mon, Aug 11, 2025 at 04:39:48PM +0200, David Hildenbrand wrote:
> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
> 
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/powerpc/platforms/pseries/cmm.c |  2 +-
>  drivers/misc/vmw_balloon.c           |  4 +--
>  drivers/virtio/virtio_balloon.c      |  2 +-
>  fs/aio.c                             |  2 +-

For

>  fs/btrfs/inode.c                     |  4 +--

Acked-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS
  2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
                     ` (4 preceding siblings ...)
  2025-08-12  8:13   ` David Sterba
@ 2025-08-13  1:32   ` Byungchul Park
  5 siblings, 0 replies; 13+ messages in thread
From: Byungchul Park @ 2025-08-13  1:32 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Gregory Price, Ying Huang,
	Alistair Popple, Minchan Kim, Sergey Senozhatsky, kernel_team

On Mon, Aug 11, 2025 at 04:39:48PM +0200, David Hildenbrand wrote:
> At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users,
> and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success"
> return value that the code uses and expects.
> 
> Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0"
> for success.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/powerpc/platforms/pseries/cmm.c |  2 +-
>  drivers/misc/vmw_balloon.c           |  4 +--
>  drivers/virtio/virtio_balloon.c      |  2 +-
>  fs/aio.c                             |  2 +-
>  fs/btrfs/inode.c                     |  4 +--
>  fs/hugetlbfs/inode.c                 |  4 +--
>  fs/jfs/jfs_metapage.c                |  8 +++---
>  include/linux/migrate.h              | 10 +------
>  mm/migrate.c                         | 40 +++++++++++++---------------
>  mm/migrate_device.c                  |  2 +-
>  mm/zsmalloc.c                        |  4 +--
>  11 files changed, 36 insertions(+), 46 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
> index 5e0a718d1be7b..0823fa2da1516 100644
> --- a/arch/powerpc/platforms/pseries/cmm.c
> +++ b/arch/powerpc/platforms/pseries/cmm.c
> @@ -545,7 +545,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
>         /* balloon page list reference */
>         put_page(page);
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;

Yeah.  The unnecessary thing has been kept.  Looks better to me.

Reviewed-by: Byungchul Park <byungchul@sk.com>

	Byungchul

>  static void cmm_balloon_compaction_init(void)
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index 6653fc53c951c..6df51ee8db621 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -1806,7 +1806,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
>                  * the list after acquiring the lock.
>                  */
>                 get_page(newpage);
> -               ret = MIGRATEPAGE_SUCCESS;
> +               ret = 0;
>         }
> 
>         /* Update the balloon list under the @pages_lock */
> @@ -1817,7 +1817,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
>          * If we succeed just insert it to the list and update the statistics
>          * under the lock.
>          */
> -       if (ret == MIGRATEPAGE_SUCCESS) {
> +       if (!ret) {
>                 balloon_page_insert(&b->b_dev_info, newpage);
>                 __count_vm_event(BALLOON_MIGRATE);
>         }
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index e299e18346a30..eae65136cdfb5 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -875,7 +875,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
>         balloon_page_finalize(page);
>         put_page(page); /* balloon reference */
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
>  #endif /* CONFIG_BALLOON_COMPACTION */
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 7fc7b6221312c..059e03cfa088c 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -445,7 +445,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
>         folio_get(dst);
> 
>         rc = folio_migrate_mapping(mapping, dst, src, 1);
> -       if (rc != MIGRATEPAGE_SUCCESS) {
> +       if (rc) {
>                 folio_put(dst);
>                 goto out_unlock;
>         }
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index b77dd22b8cdbe..1d64fee6f59e6 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7411,7 +7411,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
>  {
>         int ret = filemap_migrate_folio(mapping, dst, src, mode);
> 
> -       if (ret != MIGRATEPAGE_SUCCESS)
> +       if (ret)
>                 return ret;
> 
>         if (folio_test_ordered(src)) {
> @@ -7419,7 +7419,7 @@ static int btrfs_migrate_folio(struct address_space *mapping,
>                 folio_set_ordered(dst);
>         }
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
>  #else
>  #define btrfs_migrate_folio NULL
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 09d4baef29cf9..34d496a2b7de6 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1052,7 +1052,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
>         int rc;
> 
>         rc = migrate_huge_page_move_mapping(mapping, dst, src);
> -       if (rc != MIGRATEPAGE_SUCCESS)
> +       if (rc)
>                 return rc;
> 
>         if (hugetlb_folio_subpool(src)) {
> @@ -1063,7 +1063,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
> 
>         folio_migrate_flags(dst, src);
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
>  #else
>  #define hugetlbfs_migrate_folio NULL
> diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
> index b98cf3bb6c1fe..871cf4fb36366 100644
> --- a/fs/jfs/jfs_metapage.c
> +++ b/fs/jfs/jfs_metapage.c
> @@ -169,7 +169,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>         }
> 
>         rc = filemap_migrate_folio(mapping, dst, src, mode);
> -       if (rc != MIGRATEPAGE_SUCCESS)
> +       if (rc)
>                 return rc;
> 
>         for (i = 0; i < MPS_PER_PAGE; i++) {
> @@ -199,7 +199,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>                 }
>         }
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
>  #endif /* CONFIG_MIGRATION */
> 
> @@ -242,7 +242,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>                 return -EAGAIN;
> 
>         rc = filemap_migrate_folio(mapping, dst, src, mode);
> -       if (rc != MIGRATEPAGE_SUCCESS)
> +       if (rc)
>                 return rc;
> 
>         if (unlikely(insert_metapage(dst, mp)))
> @@ -253,7 +253,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
>         mp->folio = dst;
>         remove_metapage(src, mp);
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
>  #endif /* CONFIG_MIGRATION */
> 
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index 40f2b5a37efbb..02f11704fb686 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -12,13 +12,6 @@ typedef void free_folio_t(struct folio *folio, unsigned long private);
> 
>  struct migration_target_control;
> 
> -/*
> - * Return values from addresss_space_operations.migratepage():
> - * - negative errno on page migration failure;
> - * - zero on page migration success;
> - */
> -#define MIGRATEPAGE_SUCCESS            0
> -
>  /**
>   * struct movable_operations - Driver page migration
>   * @isolate_page:
> @@ -34,8 +27,7 @@ struct migration_target_control;
>   * @src page.  The driver should copy the contents of the
>   * @src page to the @dst page and set up the fields of @dst page.
>   * Both pages are locked.
> - * If page migration is successful, the driver should
> - * return MIGRATEPAGE_SUCCESS.
> + * If page migration is successful, the driver should return 0.
>   * If the driver cannot migrate the page at the moment, it can return
>   * -EAGAIN.  The VM interprets this as a temporary migration failure and
>   * will retry it later.  Any other error value is a permanent migration
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e9dacf1028dc7..2db4974178e6a 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -209,18 +209,17 @@ static void putback_movable_ops_page(struct page *page)
>   * src and dst are also released by migration core. These pages will not be
>   * folios in the future, so that must be reworked.
>   *
> - * Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error
> - * code.
> + * Returns 0 on success, otherwise a negative error code.
>   */
>  static int migrate_movable_ops_page(struct page *dst, struct page *src,
>                 enum migrate_mode mode)
>  {
> -       int rc = MIGRATEPAGE_SUCCESS;
> +       int rc;
> 
>         VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src);
>         VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src);
>         rc = page_movable_ops(src)->migrate_page(dst, src, mode);
> -       if (rc == MIGRATEPAGE_SUCCESS)
> +       if (!rc)
>                 ClearPageMovableOpsIsolated(src);
>         return rc;
>  }
> @@ -565,7 +564,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
>                 if (folio_test_swapbacked(folio))
>                         __folio_set_swapbacked(newfolio);
> 
> -               return MIGRATEPAGE_SUCCESS;
> +               return 0;
>         }
> 
>         oldzone = folio_zone(folio);
> @@ -666,7 +665,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
>         }
>         local_irq_enable();
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
> 
>  int folio_migrate_mapping(struct address_space *mapping,
> @@ -715,7 +714,7 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
> 
>         xas_unlock_irq(&xas);
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
> 
>  /*
> @@ -831,14 +830,14 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
>                 return rc;
> 
>         rc = __folio_migrate_mapping(mapping, dst, src, expected_count);
> -       if (rc != MIGRATEPAGE_SUCCESS)
> +       if (rc)
>                 return rc;
> 
>         if (src_private)
>                 folio_attach_private(dst, folio_detach_private(src));
> 
>         folio_migrate_flags(dst, src);
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
> 
>  /**
> @@ -945,7 +944,7 @@ static int __buffer_migrate_folio(struct address_space *mapping,
>         }
> 
>         rc = filemap_migrate_folio(mapping, dst, src, mode);
> -       if (rc != MIGRATEPAGE_SUCCESS)
> +       if (rc)
>                 goto unlock_buffers;
> 
>         bh = head;
> @@ -1049,7 +1048,7 @@ static int fallback_migrate_folio(struct address_space *mapping,
>   *
>   * Return value:
>   *   < 0 - error code
> - *  MIGRATEPAGE_SUCCESS - success
> + *     0 - success
>   */
>  static int move_to_new_folio(struct folio *dst, struct folio *src,
>                                 enum migrate_mode mode)
> @@ -1077,7 +1076,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
>         else
>                 rc = fallback_migrate_folio(mapping, dst, src, mode);
> 
> -       if (rc == MIGRATEPAGE_SUCCESS) {
> +       if (!rc) {
>                 /*
>                  * For pagecache folios, src->mapping must be cleared before src
>                  * is freed. Anonymous folios must stay anonymous until freed.
> @@ -1427,7 +1426,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>         if (folio_ref_count(src) == 1) {
>                 /* page was freed from under us. So we are done. */
>                 folio_putback_hugetlb(src);
> -               return MIGRATEPAGE_SUCCESS;
> +               return 0;
>         }
> 
>         dst = get_new_folio(src, private);
> @@ -1490,8 +1489,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>                 rc = move_to_new_folio(dst, src, mode);
> 
>         if (page_was_mapped)
> -               remove_migration_ptes(src,
> -                       rc == MIGRATEPAGE_SUCCESS ? dst : src, 0);
> +               remove_migration_ptes(src, !rc ? dst : src, 0);
> 
>  unlock_put_anon:
>         folio_unlock(dst);
> @@ -1500,7 +1498,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>         if (anon_vma)
>                 put_anon_vma(anon_vma);
> 
> -       if (rc == MIGRATEPAGE_SUCCESS) {
> +       if (!rc) {
>                 move_hugetlb_state(src, dst, reason);
>                 put_new_folio = NULL;
>         }
> @@ -1508,7 +1506,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
>  out_unlock:
>         folio_unlock(src);
>  out:
> -       if (rc == MIGRATEPAGE_SUCCESS)
> +       if (!rc)
>                 folio_putback_hugetlb(src);
>         else if (rc != -EAGAIN)
>                 list_move_tail(&src->lru, ret);
> @@ -1618,7 +1616,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
>                                                       reason, ret_folios);
>                         /*
>                          * The rules are:
> -                        *      Success: hugetlb folio will be put back
> +                        *      0: hugetlb folio will be put back
>                          *      -EAGAIN: stay on the from list
>                          *      -ENOMEM: stay on the from list
>                          *      Other errno: put on ret_folios list
> @@ -1635,7 +1633,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
>                                 retry++;
>                                 nr_retry_pages += nr_pages;
>                                 break;
> -                       case MIGRATEPAGE_SUCCESS:
> +                       case 0:
>                                 stats->nr_succeeded += nr_pages;
>                                 break;
>                         default:
> @@ -1689,7 +1687,7 @@ static void migrate_folios_move(struct list_head *src_folios,
>                                 reason, ret_folios);
>                 /*
>                  * The rules are:
> -                *      Success: folio will be freed
> +                *      0: folio will be freed
>                  *      -EAGAIN: stay on the unmap_folios list
>                  *      Other errno: put on ret_folios list
>                  */
> @@ -1699,7 +1697,7 @@ static void migrate_folios_move(struct list_head *src_folios,
>                         *thp_retry += is_thp;
>                         *nr_retry_pages += nr_pages;
>                         break;
> -               case MIGRATEPAGE_SUCCESS:
> +               case 0:
>                         stats->nr_succeeded += nr_pages;
>                         stats->nr_thp_succeeded += is_thp;
>                         break;
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index e05e14d6eacdb..abd9f6850db65 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -778,7 +778,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>                 if (migrate && migrate->fault_page == page)
>                         extra_cnt = 1;
>                 r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
> -               if (r != MIGRATEPAGE_SUCCESS)
> +               if (r)
>                         src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
>                 else
>                         folio_migrate_flags(newfolio, folio);
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 2c5e56a653544..84eb91d47a226 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -1746,7 +1746,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
>          * instead.
>          */
>         if (!zpdesc->zspage)
> -               return MIGRATEPAGE_SUCCESS;
> +               return 0;
> 
>         /* The page is locked, so this pointer must remain valid */
>         zspage = get_zspage(zpdesc);
> @@ -1813,7 +1813,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
>         reset_zpdesc(zpdesc);
>         zpdesc_put(zpdesc);
> 
> -       return MIGRATEPAGE_SUCCESS;
> +       return 0;
>  }
> 
>  static void zs_page_putback(struct page *page)
> --
> 2.50.1
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP
  2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
  2025-08-11 18:13   ` Zi Yan
@ 2025-08-13  5:05   ` Lance Yang
  2025-08-18 11:28     ` David Hildenbrand
  1 sibling, 1 reply; 13+ messages in thread
From: Lance Yang @ 2025-08-13  5:05 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On Mon, Aug 11, 2025 at 10:47 PM David Hildenbrand <david@redhat.com> wrote:
>
[...]
> +++ b/mm/migrate.c
> @@ -1176,16 +1176,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>         bool locked = false;
>         bool dst_locked = false;
>
> -       if (folio_ref_count(src) == 1) {
> -               /* Folio was freed from under us. So we are done. */
> -               folio_clear_active(src);
> -               folio_clear_unevictable(src);
> -               /* free_pages_prepare() will clear PG_isolated. */
> -               list_del(&src->lru);
> -               migrate_folio_done(src, reason);
> -               return MIGRATEPAGE_SUCCESS;
> -       }
> -
>         dst = get_new_folio(src, private);
>         if (!dst)
>                 return -ENOMEM;
> @@ -1275,7 +1265,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>
>         if (unlikely(page_has_movable_ops(&src->page))) {
>                 __migrate_folio_record(dst, old_page_state, anon_vma);
> -               return MIGRATEPAGE_UNMAP;
> +               return 0;
>         }
>
>         /*
> @@ -1305,7 +1295,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>
>         if (!folio_mapped(src)) {
>                 __migrate_folio_record(dst, old_page_state, anon_vma);
> -               return MIGRATEPAGE_UNMAP;
> +               return 0;
>         }
>
>  out:
> @@ -1848,14 +1838,28 @@ static int migrate_pages_batch(struct list_head *from,
>                                 continue;
>                         }
>
> +                       /*
> +                        * If we are holding the last folio reference, the folio
> +                        * was freed from under us, so just drop our reference.
> +                        */
> +                       if (likely(!page_has_movable_ops(&folio->page)) &&
> +                           folio_ref_count(folio) == 1) {
> +                               folio_clear_active(folio);
> +                               folio_clear_unevictable(folio);
> +                               list_del(&folio->lru);
> +                               migrate_folio_done(folio, reason);
> +                               stats->nr_succeeded += nr_pages;
> +                               stats->nr_thp_succeeded += is_thp;
> +                               continue;
> +                       }
> +

It seems the reason parameter is no longer used within migrate_folio_unmap()
after this patch.

Perhaps it could be removed from the function's signature ;)

>                         rc = migrate_folio_unmap(get_new_folio, put_new_folio,
>                                         private, folio, &dst, mode, reason,
>                                         ret_folios);

Anyway, just a small thought. Feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>

Thanks,
Lance

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP
  2025-08-13  5:05   ` Lance Yang
@ 2025-08-18 11:28     ` David Hildenbrand
  0 siblings, 0 replies; 13+ messages in thread
From: David Hildenbrand @ 2025-08-18 11:28 UTC (permalink / raw)
  To: Lance Yang
  Cc: linux-kernel, linux-mm, linuxppc-dev, virtualization,
	linux-fsdevel, linux-aio, linux-btrfs, jfs-discussion,
	Andrew Morton, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Jerrin Shaji George,
	Arnd Bergmann, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang,
	Xuan Zhuo, Eugenio Pérez, Alexander Viro, Christian Brauner,
	Jan Kara, Benjamin LaHaise, Chris Mason, Josef Bacik,
	David Sterba, Muchun Song, Oscar Salvador, Dave Kleikamp, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Minchan Kim,
	Sergey Senozhatsky

On 13.08.25 07:05, Lance Yang wrote:
> On Mon, Aug 11, 2025 at 10:47 PM David Hildenbrand <david@redhat.com> wrote:
>>
> [...]
>> +++ b/mm/migrate.c
>> @@ -1176,16 +1176,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>>          bool locked = false;
>>          bool dst_locked = false;
>>
>> -       if (folio_ref_count(src) == 1) {
>> -               /* Folio was freed from under us. So we are done. */
>> -               folio_clear_active(src);
>> -               folio_clear_unevictable(src);
>> -               /* free_pages_prepare() will clear PG_isolated. */
>> -               list_del(&src->lru);
>> -               migrate_folio_done(src, reason);
>> -               return MIGRATEPAGE_SUCCESS;
>> -       }
>> -
>>          dst = get_new_folio(src, private);
>>          if (!dst)
>>                  return -ENOMEM;
>> @@ -1275,7 +1265,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>>
>>          if (unlikely(page_has_movable_ops(&src->page))) {
>>                  __migrate_folio_record(dst, old_page_state, anon_vma);
>> -               return MIGRATEPAGE_UNMAP;
>> +               return 0;
>>          }
>>
>>          /*
>> @@ -1305,7 +1295,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>>
>>          if (!folio_mapped(src)) {
>>                  __migrate_folio_record(dst, old_page_state, anon_vma);
>> -               return MIGRATEPAGE_UNMAP;
>> +               return 0;
>>          }
>>
>>   out:
>> @@ -1848,14 +1838,28 @@ static int migrate_pages_batch(struct list_head *from,
>>                                  continue;
>>                          }
>>
>> +                       /*
>> +                        * If we are holding the last folio reference, the folio
>> +                        * was freed from under us, so just drop our reference.
>> +                        */
>> +                       if (likely(!page_has_movable_ops(&folio->page)) &&
>> +                           folio_ref_count(folio) == 1) {
>> +                               folio_clear_active(folio);
>> +                               folio_clear_unevictable(folio);
>> +                               list_del(&folio->lru);
>> +                               migrate_folio_done(folio, reason);
>> +                               stats->nr_succeeded += nr_pages;
>> +                               stats->nr_thp_succeeded += is_thp;
>> +                               continue;
>> +                       }
>> +
> 
> It seems the reason parameter is no longer used within migrate_folio_unmap()
> after this patch.
> 
> Perhaps it could be removed from the function's signature ;)

Thanks, well spotted, @Andrew can you squash the following?


 From 40938bb0de20e03250c813d5abc7286aea69d835 Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@redhat.com>
Date: Mon, 18 Aug 2025 13:26:05 +0200
Subject: [PATCH] fixup: mm/migrate: remove MIGRATEPAGE_UNMAP

No need to pass "reason" to migrate_folio_unmap().

Signed-off-by: David Hildenbrand <david@redhat.com>
---
  mm/migrate.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 2db4974178e6a..aabc736eec022 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1166,7 +1166,7 @@ static void migrate_folio_done(struct folio *src,
  static int migrate_folio_unmap(new_folio_t get_new_folio,
  		free_folio_t put_new_folio, unsigned long private,
  		struct folio *src, struct folio **dstp, enum migrate_mode mode,
-		enum migrate_reason reason, struct list_head *ret)
+		struct list_head *ret)
  {
  	struct folio *dst;
  	int rc = -EAGAIN;
@@ -1852,8 +1852,7 @@ static int migrate_pages_batch(struct list_head *from,
  			}
  
  			rc = migrate_folio_unmap(get_new_folio, put_new_folio,
-					private, folio, &dst, mode, reason,
-					ret_folios);
+					private, folio, &dst, mode, ret_folios);
  			/*
  			 * The rules are:
  			 *	0: folio will be put on unmap_folios list,
-- 
2.50.1


-- 
Cheers

David / dhildenb


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-08-18 11:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 14:39 [PATCH v1 0/2] mm: remove MIGRATEPAGE_* David Hildenbrand
2025-08-11 14:39 ` [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP David Hildenbrand
2025-08-11 18:13   ` Zi Yan
2025-08-13  5:05   ` Lance Yang
2025-08-18 11:28     ` David Hildenbrand
2025-08-11 14:39 ` [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS David Hildenbrand
2025-08-11 14:47   ` Dave Kleikamp
2025-08-11 18:18   ` Zi Yan
2025-08-12  3:58   ` Sergey Senozhatsky
2025-08-12  6:32   ` Greg Kroah-Hartman
2025-08-12  8:13   ` David Sterba
2025-08-13  1:32   ` Byungchul Park
2025-08-12  1:29 ` [PATCH v1 0/2] mm: remove MIGRATEPAGE_* Huang, Ying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).