From: Jordan Niethe <jniethe@nvidia.com>
To: linux-mm@kvack.org
Cc: balbirs@nvidia.com, matthew.brost@intel.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, david@redhat.com,
ziy@nvidia.com, apopple@nvidia.com, lorenzo.stoakes@oracle.com,
lyude@redhat.com, dakr@kernel.org, airlied@gmail.com,
simona@ffwll.ch, rcampbell@nvidia.com, mpenttil@redhat.com,
jgg@nvidia.com, willy@infradead.org
Subject: [RFC PATCH 2/6] mm/migrate_device: Add migrate PFN flag to track device private PFNs
Date: Fri, 28 Nov 2025 15:41:42 +1100 [thread overview]
Message-ID: <20251128044146.80050-3-jniethe@nvidia.com> (raw)
In-Reply-To: <20251128044146.80050-1-jniethe@nvidia.com>
A future change will remove device private pages from the physical
address space. This will mean that device private pages no longer have
normal PFN and must be handled separately.
Prepare for this by adding a MIGRATE_PFN_DEVICE flag to indicate
that a migrate pfn contains a PFN for a device private page.
Signed-off-by: Jordan Niethe <jniethe@nvidia.com>
Signed-off-by: Alistair Popple <apopple@nvidia.com>
---
Note: Existing drivers must also be updated in next revision.
---
include/linux/migrate.h | 1 +
lib/test_hmm.c | 3 ++-
mm/migrate_device.c | 5 +++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 1f0ac122c3bf..d8f520dca342 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -125,6 +125,7 @@ static inline int migrate_misplaced_folio(struct folio *folio, int node)
#define MIGRATE_PFN_VALID (1UL << 0)
#define MIGRATE_PFN_MIGRATE (1UL << 1)
#define MIGRATE_PFN_WRITE (1UL << 3)
+#define MIGRATE_PFN_DEVICE (1UL << 4)
#define MIGRATE_PFN_SHIFT 6
static inline struct page *migrate_pfn_to_page(unsigned long mpfn)
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 83e3d8208a54..0035e1b7beec 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -684,7 +684,8 @@ static void dmirror_migrate_alloc_and_copy(struct migrate_vma *args,
pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
page_to_pfn(spage), page_to_pfn(dpage));
- *dst = migrate_pfn(page_to_pfn(dpage));
+ *dst = migrate_pfn(page_to_pfn(dpage)) |
+ MIGRATE_PFN_DEVICE;
if ((*src & MIGRATE_PFN_WRITE) ||
(!spage && args->vma->vm_flags & VM_WRITE))
*dst |= MIGRATE_PFN_WRITE;
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index abd9f6850db6..82f09b24d913 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -148,7 +148,8 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
goto next;
mpfn = migrate_pfn(page_to_pfn(page)) |
- MIGRATE_PFN_MIGRATE;
+ MIGRATE_PFN_MIGRATE |
+ MIGRATE_PFN_DEVICE;
if (is_writable_device_private_entry(entry))
mpfn |= MIGRATE_PFN_WRITE;
} else {
@@ -918,7 +919,7 @@ static unsigned long migrate_device_pfn_lock(unsigned long pfn)
return 0;
}
- return migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE;
+ return migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE | MIGRATE_PFN_DEVICE;
}
/**
--
2.34.1
next prev parent reply other threads:[~2025-11-28 4:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 4:41 [RFC PATCH 0/6] Remove device private pages from physical address space Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 1/6] mm/hmm: Add flag to track device private PFNs Jordan Niethe
2025-11-28 18:36 ` Matthew Brost
2025-12-02 1:20 ` Jordan Niethe
2025-12-03 4:25 ` Balbir Singh
2025-11-28 4:41 ` Jordan Niethe [this message]
2025-11-28 4:41 ` [RFC PATCH 3/6] mm/page_vma_mapped: Add flags to page_vma_mapped_walk::pfn " Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 4/6] mm: Add a new swap type for migration entries with " Jordan Niethe
2025-12-01 2:43 ` Chih-En Lin
2025-12-02 1:42 ` Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 5/6] mm/util: Add flag to track device private PFNs in page snapshots Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 6/6] mm: Remove device private pages from the physical address space Jordan Niethe
2025-11-28 17:51 ` Jason Gunthorpe
2025-12-02 2:28 ` Jordan Niethe
2025-12-02 4:10 ` Alistair Popple
2025-11-28 7:40 ` [RFC PATCH 0/6] Remove device private pages from " David Hildenbrand (Red Hat)
2025-11-30 23:33 ` Alistair Popple
2025-11-28 15:09 ` Matthew Wilcox
2025-12-02 1:31 ` Jordan Niethe
2025-11-28 16:07 ` Mika Penttilä
2025-12-02 1:32 ` Jordan Niethe
2025-11-28 19:22 ` Matthew Brost
2025-11-30 23:23 ` Alistair Popple
2025-12-01 1:51 ` Matthew Brost
2025-12-02 1:40 ` Jordan Niethe
2025-12-02 22:20 ` Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251128044146.80050-3-jniethe@nvidia.com \
--to=jniethe@nvidia.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=balbirs@nvidia.com \
--cc=dakr@kernel.org \
--cc=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=lyude@redhat.com \
--cc=matthew.brost@intel.com \
--cc=mpenttil@redhat.com \
--cc=rcampbell@nvidia.com \
--cc=simona@ffwll.ch \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox