[PATCH v6 09/13] mm: Begin creating device private migration entries

Jordan Niethe
2026-02-02T11:38:12Z

Update the migration entry creation helpers to automatically create
device private migration entries when invoked on device private pages.

The corresponding softleaf predicates have already been updated to
expect both migration and device private migration entries.

Signed-off-by: Jordan Niethe <jniethe@nvidia.com>
---
v3:
- Provided as an individual patch
---
include/linux/swapops.h | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 220627cb7fff..8b39983792ea 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -206,6 +206,10 @@ static inline swp_entry_t make_readable_migration_entry(pgoff_t offset)
static inline swp_entry_t make_readable_migration_entry_from_page(struct page *page,
pgoff_t flags)
{
+ if (is_device_private_page(page))
+ return make_readable_migration_device_private_entry(
+ page_to_pfn(page) | flags);
+
return swp_entry(SWP_MIGRATION_READ, page_to_pfn(page) | flags);
}

@@ -217,6 +221,10 @@ static inline swp_entry_t make_readable_exclusive_migration_entry(pgoff_t offset
static inline swp_entry_t make_readable_exclusive_migration_entry_from_page(struct page *page,
pgoff_t flags)
{
+ if (is_device_private_page(page))
+ return make_readable_exclusive_migration_device_private_entry(
+ page_to_pfn(page) | flags);
+
return swp_entry(SWP_MIGRATION_READ_EXCLUSIVE, page_to_pfn(page) | flags);
}

@@ -228,6 +236,10 @@ static inline swp_entry_t make_writable_migration_entry(pgoff_t offset)
static inline swp_entry_t make_writable_migration_entry_from_page(struct page *page,
pgoff_t flags)
{
+ if (is_device_private_page(page))
+ return make_writable_migration_device_private_entry(
+ page_to_pfn(page) | flags);
+
return swp_entry(SWP_MIGRATION_WRITE, page_to_pfn(page) | flags);
}

--
2.34.1