Migrate on fault for device pages
Subsystems (7)
v8 cover Migrate on fault for device pages
From: Mika Penttilä <[email protected]>
Currently, the way device page faulting and migration works is not optimal, if you want to do both fault handling and migration at once.
Being able to migrate not present pages (or pages mapped with incorrect permissions, eg. COW) to the GPU requires doing either of the following sequences:
1. hmm_range_fault() - fault in non-present pages with correct permissions, etc.
2. migrate_vma_*() - migrate the pages
Or:
1. migrate_vma_*() - migrate present pages
2. If non-present pages detected by migrate_vma_*():
a) call hmm_range_fault() to fault pages in
b) call migrate_vma_*() again to migrate now present pages
The problem with the first sequence is that you always have to do two page walks even when most of the time the pages are present or zero page mappings so the common case takes a performance hit.
The second sequence is better for the common case, but far worse if pages aren't present because now you have to walk the page tables three times (once to find the page is not present, once so hmm_range_fault() can find a non-present page to fault in and once again to setup the migration). It is also tricky to code correctly. One page table walk could costs over 1000 cpu cycles on X86-64, which is a significant hit.
We should be able to walk the page table once, faulting pages in as required and replacing them with migration entries if requested.
Add a new flag to HMM APIs, HMM_PFN_REQ_MIGRATE,
which tells to prepare for migration also during fault handling. Also, for the migrate_vma_setup() call paths, a flag, MIGRATE_VMA_FAULT, is added to tell to add fault handling to migrate.
One extra benefit of migrating with hmm_range_fault() path is the migrate_vma.vma gets populated, so no need to retrieve that separataly.
Tested in X86-64 VM with HMM test device, passing the selftests. For performance, the migrate throughput tests from the selftests show similar numbers (within error margin) as unmodified kernel. Tested also rebased on the
"Remove device private pages from physical address space" series:
https://lore.kernel.org/linux-mm/[email protected]/
plus a small patch to adjust with no problems.
Changes v7-v8
- rebase on 7.0
- fixed subject in two patches
- enhanced commit messages
- squashed patch 6 into patch 4 to fix kernel test robot warning
- readded dropped Cc block from cover letter
- fixed white space
Changes v6-v7
- rebase on 7.0.0-rc6
- added documentation and comments
- denote to be migrated zero page as HMM_PFN_MIGRATE alone
- got rid of HMM_PFN_INOUT_FLAGS movement in patch 2
- picked up Acked-By from David for patch 1
Changes v5-v6
- rebase on 7.0.0-rc4
- use range based TLB flushing while unmapping ptes
- gate migration behind HMM_PFN_REQ_MIGRATE for fault and migrate paths
- always infer migration flags from migrate->flags only
Changes v4-v5
- rebase on 6.19
- fixed David's email address
- fixed link issue without CONFIG_TRANSPARENT_HUGEPAGE
- refactored into smaller commits
- added more comments to code
Changes v3-v4:
- rebase on 6.19-rc8
- fixed issues found by kernel test robot with random configs
- fixed typos
Changes v2-v3:
- rebase on 6.19-rc7
- fixed issues found by kernel test robot
- fixed smatch issues reported by Dan Carpenter <[email protected]>
- fixes to lock handling (pmd/pte) on errors
- added assertions for pmd/pte lock states
- other issues discovered by Matthew, thanks!
Changes v1-v2:
- rebase on 6.19-rc6
- fixed issues found by kernel test robot
- fixed locking (pmd/ptl) to cover handle_ and prepare_ regions parts if migrating
- other issues discovered by Matthew, thanks!
Changes RFC-v1:
- rebase on 6.19-rc5
- adjust for the device THP
- changes from feedback
Revisions:
- RFC https://lore.kernel.org/linux-mm/[email protected]/
- v1: https://lore.kernel.org/all/[email protected]/
- v2: https://lore.kernel.org/all/[email protected]/
- v3: https://lore.kernel.org/all/[email protected]/
- v4: https://lore.kernel.org/all/[email protected]/
- v5: https://lore.kernel.org/linux-mm/[email protected]/
- v6: https://lore.kernel.org/linux-mm/[email protected]/
- v7: https://lore.kernel.org/linux-mm/[email protected]/
Mika Penttilä (5):
mm/Kconfig: changes for migrate on fault for device pages
mm: Add helper to convert HMM pfn to migrate pfn mm/hmm: do the plumbing for HMM to participate in migration
mm: setup device page migration in HMM pagewalk lib/test_hmm:: add a new testcase for the migrate on fault
include/linux/hmm.h | 19 +- include/linux/migrate.h | 26 +- lib/test_hmm.c | 101 ++- lib/test_hmm_uapi.h | 19 +- mm/Kconfig | 2 + mm/hmm.c | 821 +++++++++++++++++++++++-- mm/migrate_device.c | 589 +++--------------- tools/testing/selftests/mm/hmm-tests.c | 54 ++ 8 files changed, 1053 insertions(+), 578 deletions(-)
base-commit: 028ef9c96e96197026887c0f092424679298aae8
Signature · 1 line
2.50.0
PATCH v8 1/5 mm/Kconfig: changes for migrate on fault for device pages
From: Mika Penttilä <[email protected]>
HMM depends on MMU notifiers. With the unified HMM/migrate_device page table walk migrate_device needs HMM enabled. Enable them explicitly to avoid breaking random configs.
--- mm/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
mm/Kconfig +2 -0
@@ -647,6 +647,7 @@ config MIGRATION config DEVICE_MIGRATION def_bool MIGRATION && ZONE_DEVICE + select HMM_MIRROR config ARCH_ENABLE_HUGEPAGE_MIGRATION bool
@@ -1222,6 +1223,7 @@ config ZONE_DEVICE config HMM_MIRROR bool depends on MMU + select MMU_NOTIFIER config GET_FREE_REGION bool
Signature · 1 line
2.50.0
PATCH v8 2/5 mm: Add helper to convert HMM pfn to migrate pfn
In reply to [email protected]From: Mika Penttilä <[email protected]>
The unified HMM/migrate_device pagewalk does the "collecting" on the HMM side, so we need a helper to transfer pfns to the migrate_vma world.
--- include/linux/hmm.h | 19 +++++++++++++- include/linux/migrate.h | 3 ++- mm/migrate_device.c | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-)
include/linux/hmm.h +18 -1
@@ -13,6 +13,8 @@struct mmu_interval_notifier ; +struct migrate_vma ; +/* * On output: * 0 - The page is faultable and a future call with
@@ -27,6 +29,13 @@ struct mmu_interval_notifier;* HMM_PFN_P2PDMA_BUS - Bus mapped P2P transfer * HMM_PFN_DMA_MAPPED - Flag preserved on input-to-output transformation * to mark that page is already DMA mapped +* HMM_PFN_MIGRATE - The entry is to be migrated. Note, HMM_PFN_MIGRATE +* alone without HMM_PFN_VALID denotes the +* empty page. +* This flag together with HMM_PFN_COMPOUND are +* indicators for migrate_hmm_range_setup() to +* setup the migrate pfns. +* HMM_PFN_COMPOUND - The entry is represents a > 0 order page * * On input: * 0 - Return the current state of the page, do not fault it.
@@ -34,6 +43,8 @@ struct mmu_interval_notifier;* will fail * HMM_PFN_REQ_WRITE - The output must have HMM_PFN_WRITE or hmm_range_fault() * will fail. Must be combined with HMM_PFN_REQ_FAULT. +* HMM_PFN_REQ_MIGRATE - For default_flags, request to migrate, according to +* hmm_range.migrate.flags */ enum hmm_pfn_flags {/* Output fields and flags */
@@ -48,11 +59,15 @@ enum hmm_pfn_flags {HMM_PFN_P2PDMA =1UL << (BITS_PER_LONG -5 ),HMM_PFN_P2PDMA_BUS =1UL << (BITS_PER_LONG -6 ), -HMM_PFN_ORDER_SHIFT = (BITS_PER_LONG -11 ), +/* Migrate request */ +HMM_PFN_MIGRATE =1UL << (BITS_PER_LONG -7 ), +HMM_PFN_COMPOUND =1UL << (BITS_PER_LONG -8 ), +HMM_PFN_ORDER_SHIFT = (BITS_PER_LONG -13 ),/* Input flags */ HMM_PFN_REQ_FAULT =HMM_PFN_VALID ,HMM_PFN_REQ_WRITE =HMM_PFN_WRITE , +HMM_PFN_REQ_MIGRATE =HMM_PFN_MIGRATE , HMM_PFN_FLAGS = ~((1UL << HMM_PFN_ORDER_SHIFT) - 1), };
@@ -107,6 +122,7 @@ static inline unsigned int hmm_pfn_to_map_order(unsigned long hmm_pfn)* @default_flags: default flags for the range (write, read, ... see hmm doc) * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter * @dev_private_owner: owner of device private pages +* @migrate: structure for migrating a range of a VMA */ struct hmm_range {struct mmu_interval_notifier *notifier;
@@ -117,6 +133,7 @@ struct hmm_range {unsigned long default_flags;unsigned long pfn_flags_mask;void *dev_private_owner; +struct migrate_vma *migrate; };/*
include/linux/migrate.h +2 -1
@@ -3,6 +3,7 @@#define _LINUX_MIGRATE_H#include <linux/mm.h> +#include <linux/hmm.h> #include <linux/mempolicy.h> #include <linux/migrate_mode.h> #include <linux/hugetlb.h>
@@ -200,7 +201,7 @@ void migrate_device_pages(unsigned long *src_pfns, unsigned long *dst_pfns, unsigned long npages);void migrate_device_finalize (unsigned long *src_pfns,unsigned long *dst_pfns,unsigned long npages); - +void migrate_hmm_range_setup (struct hmm_range *range);#endif /* CONFIG_MIGRATION */ #endif /* _LINUX_MIGRATE_H */
mm/migrate_device.c +55 -0
58 lines not on this page · raw message
Signature · 1 line
2.50.0
PATCH v8 3/5 mm/hmm: do the plumbing for HMM to participate in migration
In reply to [email protected]From: Mika Penttilä <[email protected]>
Do the preparations in hmm_range_fault() and pagewalk callbacks to do the "collecting" part of migration, needed for migration on fault.
These steps include locking for pmd/pte if migrating, capturing the vma for further migrate actions, and calling the still dummy hmm_vma_handle_migrate_prepare_pmd() and hmm_vma_handle_migrate_prepare() functions in the pagewalk.
--- include/linux/migrate.h | 18 +- lib/test_hmm.c | 2 +- mm/hmm.c | 423 +++++++++++++++++++++++++++++++++++----- 3 files changed, 388 insertions(+), 55 deletions(-)
include/linux/migrate.h +17 -1
@@ -106,6 +106,16 @@ static inline void softleaf_entry_wait_on_locked(softleaf_t entry, spinlock_t *p spin_unlock(ptl); } +enum migrate_vma_info { +MIGRATE_VMA_SELECT_NONE =0 , +MIGRATE_VMA_SELECT_COMPOUND =MIGRATE_VMA_SELECT_NONE , +}; + +static inline enum migrate_vma_info hmm_select_migrate (struct hmm_range *range) +{ +return MIGRATE_VMA_SELECT_NONE ; +} +#endif /* CONFIG_MIGRATION */ #ifdef CONFIG_NUMA_BALANCING
@@ -149,7 +159,7 @@ static inline unsigned long migrate_pfn(unsigned long pfn)return (pfn <<MIGRATE_PFN_SHIFT ) |MIGRATE_PFN_VALID ; } -enum migrate_vma_direction { +enum migrate_vma_info {MIGRATE_VMA_SELECT_SYSTEM =1 <<0 ,MIGRATE_VMA_SELECT_DEVICE_PRIVATE =1 <<1 ,MIGRATE_VMA_SELECT_DEVICE_COHERENT =1 <<2 ,
@@ -191,6 +201,12 @@ struct migrate_vma {struct page *fault_page; }; +// TODO: enable migration +static inline enum migrate_vma_info hmm_select_migrate (struct hmm_range *range) +{ +return 0 ; +} +int migrate_vma_setup (struct migrate_vma *args);void migrate_vma_pages (struct migrate_vma *migrate);void migrate_vma_finalize (struct migrate_vma *migrate);
lib/test_hmm.c +1 -1
@@ -145,7 +145,7 @@ static bool dmirror_is_private_zone(struct dmirror_device *mdevice) HMM_DMIRROR_MEMORY_DEVICE_PRIVATE); } -static enum migrate_vma_direction +static enum migrate_vma_info dmirror_select_device (struct dmirror *dmirror) { return (dmirror->mdevice->zone_device_type ==
mm/hmm.c +370 -53
597 lines not on this page · raw message
Signature · 1 line
2.50.0
PATCH v8 4/5 mm: setup device page migration in HMM pagewalk
In reply to [email protected]From: Mika Penttilä <[email protected]>
Implement the needed hmm_vma_handle_migrate_prepare_pmd() and hmm_vma_handle_migrate_prepare() functions which are mostly carried over from migrate_device.c, as well as the needed split functions.
Make migrate_device take use of HMM pagewalk for collecting part of migration.
Also, remove the now unused migrate_vma_collect() functions.
--- include/linux/migrate.h | 9 +- mm/hmm.c | 420 ++++++++++++++++++++++++++++++- mm/migrate_device.c | 534 ++-------------------------------------- 3 files changed, 438 insertions(+), 525 deletions(-)
include/linux/migrate.h +7 -2
@@ -164,6 +164,7 @@ enum migrate_vma_info {MIGRATE_VMA_SELECT_DEVICE_PRIVATE =1 <<1 ,MIGRATE_VMA_SELECT_DEVICE_COHERENT =1 <<2 ,MIGRATE_VMA_SELECT_COMPOUND =1 <<3 , + MIGRATE_VMA_FAULT = 1 << 4, }; struct migrate_vma {
@@ -201,10 +202,14 @@ struct migrate_vma {struct page *fault_page; }; -// TODO: enable migration static inline enum migrate_vma_info hmm_select_migrate (struct hmm_range *range) { -return 0 ; +enum migrate_vma_info minfo; + + minfo = (range->default_flags &HMM_PFN_REQ_MIGRATE ) ? + range->migrate->flags :0 ; + +return minfo; }int migrate_vma_setup (struct migrate_vma *args);
mm/hmm.c +409 -11
478 lines not on this page · raw message
mm/migrate_device.c +22 -512
560 lines not on this page · raw message
Signature · 1 line
2.50.0
PATCH v8 5/5 lib/test_hmm:: add a new testcase for the migrate on fault
In reply to [email protected]From: Mika Penttilä <[email protected]>
Enhance the hmm test driver (lib/test_hmm) with migrate on fault case.
--- lib/test_hmm.c | 99 ++++++++++++++++++++++++++ lib/test_hmm_uapi.h | 19 ++--- tools/testing/selftests/mm/hmm-tests.c | 54 ++++++++++++++ 3 files changed, 163 insertions(+), 9 deletions(-)
lib/test_hmm.c +99 -0
@@ -36,6 +36,7 @@#define DMIRROR_RANGE_FAULT_TIMEOUT 1000#define DEVMEM_CHUNK_SIZE (256 * 1024 * 1024U)#define DEVMEM_CHUNKS_RESERVE 16 +#define PFNS_ARRAY_SIZE 64/* * For device_private pages, dpage is just a dummy struct page
@@ -1196,6 +1197,100 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,return ret; } +static int do_fault_and_migrate (struct dmirror *dmirror,struct hmm_range *range) +{ +struct migrate_vma *migrate = range->migrate; +int ret; + +mmap_read_lock (dmirror->notifier.mm); + +/* Fault-in pages for migration and update device page table */ + ret =dmirror_range_fault (dmirror, range); + +pr_debug ("Migrating from sys mem to device mem\n" ); +migrate_hmm_range_setup (range); + +dmirror_migrate_alloc_and_copy (migrate, dmirror); +migrate_vma_pages (migrate); +dmirror_migrate_finalize_and_map (migrate, dmirror); +migrate_vma_finalize (migrate); + +mmap_read_unlock (dmirror->notifier.mm); +return ret; +} + +static int dmirror_fault_and_migrate_to_device (struct dmirror *dmirror, +struct hmm_dmirror_cmd *cmd) +{ +unsigned long start, size, end, next; +unsigned long src_pfns[PFNS_ARRAY_SIZE ] = {0 }; +unsigned long dst_pfns[PFNS_ARRAY_SIZE ] = {0 }; +struct migrate_vma migrate = {0 }; +struct hmm_range range = {0 }; +struct dmirror_bounce bounce; +int ret =0 ; + +/* Whole range */ + start = cmd->addr; + size = cmd->npages <<PAGE_SHIFT ; + end = start + size; + +if (!mmget_not_zero (dmirror->notifier.mm)) { + ret = -EFAULT ; + goto out; + } + + migrate.pgmap_owner = dmirror->mdevice; + migrate.src = src_pfns; + migrate.dst = dst_pfns; + migrate.flags =MIGRATE_VMA_SELECT_SYSTEM ; + + range.migrate = &migrate; + range.hmm_pfns = src_pfns; + range.pfn_flags_mask =0 ; + range.default_flags =HMM_PFN_REQ_FAULT |HMM_PFN_REQ_MIGRATE ; + range.dev_private_owner = dmirror->mdevice; + range.notifier = &dmirror->notifier; + +for (next = start; next < end; next = range.end) { + range.start = next; + range.end =min (end, next + (PFNS_ARRAY_SIZE <<PAGE_SHIFT )); + +pr_debug ("Fault and migrate range start:%#lx end:%#lx\n" , + range.start, range.end); + + ret =do_fault_and_migrate (dmirror, &range); +if (ret) + goto out_mmput; + } + +/* +* Return the migrated data for verification. +* Only for pages in device zone +*/ + ret =dmirror_bounce_init (&bounce, start, size); +if (ret) + goto out_mmput; + +mutex_lock (&dmirror->mutex); + ret =dmirror_do_read (dmirror, start, end, &bounce); +mutex_unlock (&dmirror->mutex); +if (ret ==0 ) { + ret =copy_to_user (u64_to_user_ptr (cmd->ptr), bounce.ptr, bounce.size); +if (ret) + ret = -EFAULT ; + } + + cmd->cpages = bounce.cpages; +dmirror_bounce_fini (&bounce); + + +out_mmput: +mmput (dmirror->notifier.mm); +out: +return ret; +} +static void dmirror_mkentry (struct dmirror *dmirror,struct hmm_range *range,unsigned char *perm,unsigned long entry) {
@@ -1512,6 +1607,10 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, ret =dmirror_migrate_to_device (dmirror, &cmd);break ; +case HMM_DMIRROR_MIGRATE_ON_FAULT_TO_DEV : + ret =dmirror_fault_and_migrate_to_device (dmirror, &cmd); +break ; +case HMM_DMIRROR_MIGRATE_TO_SYS : ret =dmirror_migrate_to_system (dmirror, &cmd);break ;
lib/test_hmm_uapi.h +10 -9
@@ -29,15 +29,16 @@ struct hmm_dmirror_cmd { };/* Expose the address space of the calling process through hmm device file */ -#define HMM_DMIRROR_READ _IOWR('H', 0x00, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_MIGRATE_TO_DEV _IOWR('H', 0x02, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_MIGRATE_TO_SYS _IOWR('H', 0x03, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x04, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_EXCLUSIVE _IOWR('H', 0x05, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x06, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_RELEASE _IOWR('H', 0x07, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_FLAGS _IOWR('H', 0x08, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_READ _IOWR('H', 0x00, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_MIGRATE_TO_DEV _IOWR('H', 0x02, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_MIGRATE_ON_FAULT_TO_DEV _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_MIGRATE_TO_SYS _IOWR('H', 0x04, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x05, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_EXCLUSIVE _IOWR('H', 0x06, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x07, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_RELEASE _IOWR('H', 0x08, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_FLAGS _IOWR('H', 0x09, struct hmm_dmirror_cmd)#define HMM_DMIRROR_FLAG_FAIL_ALLOC (1ULL << 0)
tools/testing/selftests/mm/hmm-tests.c +54 -0
66 lines not on this page · raw message
Signature · 1 line
2.50.0
Andrew Morton
maintainerQuoted 6 lines · On Tue, 14 Apr 2026 07:12:21 +0300 [email protected] wrote:
From: Mika Penttilä <[email protected]>
Currently, the way device page faulting and migration works is not optimal, if you want to do both fault handling and migration at once.
Quoted 6 lines
Being able to migrate not present pages (or pages mapped with incorrect permissions, eg. COW) to the GPU requires doing either of the following sequences:
...
Via which tree would it be best to upstream this?
Quoted 9 lines
include/linux/hmm.h | 19 +- include/linux/migrate.h | 26 +- lib/test_hmm.c | 101 ++- lib/test_hmm_uapi.h | 19 +- mm/Kconfig | 2 + mm/hmm.c | 821 +++++++++++++++++++++++-- mm/migrate_device.c | 589 +++--------------- tools/testing/selftests/mm/hmm-tests.c | 54 ++ 8 files changed, 1053 insertions(+), 578 deletions(-)
Looks like mm.git.
It might be more useful to add it to a DRM tree if there's ongoing development against this. But please no upstreaming without good review!
Anyway, this is a bit dated and Sashiko AI review wasn't able to apply the patches. Nor was it able to apply v7 or v6. So please refresh, retest, resend?
Quoted 27 lines · Andrew Morton
Quoted 6 lines · On Tue, 14 Apr 2026 07:12:21 +0300 [email protected] wrote:
From: Mika Penttilä <[email protected]>
Currently, the way device page faulting and migration works is not optimal, if you want to do both fault handling and migration at once.
Quoted 6 lines
Being able to migrate not present pages (or pages mapped with incorrect permissions, eg. COW) to the GPU requires doing either of the following sequences:
...
Via which tree would it be best to upstream this?
Quoted 9 lines
include/linux/hmm.h | 19 +- include/linux/migrate.h | 26 +- lib/test_hmm.c | 101 ++- lib/test_hmm_uapi.h | 19 +- mm/Kconfig | 2 + mm/hmm.c | 821 +++++++++++++++++++++++-- mm/migrate_device.c | 589 +++--------------- tools/testing/selftests/mm/hmm-tests.c | 54 ++ 8 files changed, 1053 insertions(+), 578 deletions(-)Looks like mm.git.
Quoted 7 lines
It might be more useful to add it to a DRM tree if there's ongoing development against this. But please no upstreaming without good review!
Anyway, this is a bit dated and Sashiko AI review wasn't able to apply the patches. Nor was it able to apply v7 or v6. So please refresh, retest, resend?
It is against Linus tree v7.0, base-commit: 028ef9c96e96197026887c0f092424679298aae8, but applies and passes hmm selftests on mm trees as is.
I plan to do v9 refresh and maybe minor updates in week or so.
--Mika
Matthew Brost
reviewerQuoted 33 lines · Mika Penttilä
Quoted 31 lines · Andrew Morton
Quoted 6 lines · On Tue, 14 Apr 2026 07:12:21 +0300 [email protected] wrote:
From: Mika Penttilä <[email protected]>
Currently, the way device page faulting and migration works is not optimal, if you want to do both fault handling and migration at once.
Quoted 6 lines
Being able to migrate not present pages (or pages mapped with incorrect permissions, eg. COW) to the GPU requires doing either of the following sequences:
...
Via which tree would it be best to upstream this?
Quoted 9 lines
include/linux/hmm.h | 19 +- include/linux/migrate.h | 26 +- lib/test_hmm.c | 101 ++- lib/test_hmm_uapi.h | 19 +- mm/Kconfig | 2 + mm/hmm.c | 821 +++++++++++++++++++++++-- mm/migrate_device.c | 589 +++--------------- tools/testing/selftests/mm/hmm-tests.c | 54 ++ 8 files changed, 1053 insertions(+), 578 deletions(-)Looks like mm.git.
It might be more useful to add it to a DRM tree if there's ongoing development against this. But please no upstreaming without good review!
Quoted 9 lines
Quoted 3 lines
Anyway, this is a bit dated and Sashiko AI review wasn't able to apply the patches. Nor was it able to apply v7 or v6. So please refresh, retest, resend?
It is against Linus tree v7.0, base-commit:
028ef9c96e96197026887c0f092424679298aae8, but applies and passes hmm selftests on mm trees as is.I plan to do v9 refresh and maybe minor updates in week or so.
It might be good to send a version which applies to drm-tip to [email protected] to trigger our CI too. I know tested an earlier rev and everything seemed to be working but another round of testing before merging is likely a good idea.
Matt
Quoted 2 lines
--Mika
Quoted 40 lines · Matthew Brost
Quoted 39 lines · Mika Penttilä
Quoted 27 lines · Andrew Morton
Quoted 6 lines · On Tue, 14 Apr 2026 07:12:21 +0300 [email protected] wrote:
From: Mika Penttilä <[email protected]>
Currently, the way device page faulting and migration works is not optimal, if you want to do both fault handling and migration at once.
Quoted 6 lines
Being able to migrate not present pages (or pages mapped with incorrect permissions, eg. COW) to the GPU requires doing either of the following sequences:
...
Via which tree would it be best to upstream this?
Quoted 9 lines
include/linux/hmm.h | 19 +- include/linux/migrate.h | 26 +- lib/test_hmm.c | 101 ++- lib/test_hmm_uapi.h | 19 +- mm/Kconfig | 2 + mm/hmm.c | 821 +++++++++++++++++++++++-- mm/migrate_device.c | 589 +++--------------- tools/testing/selftests/mm/hmm-tests.c | 54 ++ 8 files changed, 1053 insertions(+), 578 deletions(-)Looks like mm.git.
Quoted 7 lines
It might be more useful to add it to a DRM tree if there's ongoing development against this. But please no upstreaming without good review!
Anyway, this is a bit dated and Sashiko AI review wasn't able to apply the patches. Nor was it able to apply v7 or v6. So please refresh, retest, resend?
It is against Linus tree v7.0, base-commit:
028ef9c96e96197026887c0f092424679298aae8, but applies and passes hmm selftests on mm trees as is.
Quoted 8 lines
Quoted 2 lines
I plan to do v9 refresh and maybe minor updates in week or so.
It might be good to send a version which applies to drm-tip to [email protected] to trigger our CI too. I know tested an earlier rev and everything seemed to be working but another round of testing before merging is likely a good idea.
Matt
Sure, will do that, thanks!
--Mika