Accelerate page migration with batch copying and hardware offload
Subsystems (4)
v6 cover Accelerate page migration with batch copying and hardware offload
This is the sixth RFC of the patchset to enhance page migration by batching folio-copy operations and enabling acceleration via DMA offload. I had intended to split the batch-copy path into a non-RFC series this round. However, given some major changes, it does not hurt to take one more pass with the RFC tag.
Single-threaded, folio-by-folio copying bottlenecks page migration in modern systems with deep memory hierarchies, especially for large folios where copy overhead dominates, leaving significant hardware potential untapped.
By batching the copy phase, we create an opportunity for hardware acceleration. This series builds the framework and provides a DMA offload driver (dcbm) as a reference implementation, targeting bulk migration workloads where offloading the copy improves throughput and latency while freeing CPU cycles.
See the RFC V3 cover letter [3] for motivation.
Changelog since V5:
-------------------
1. Few cleanups and preparatory patches have been split out into a separate series [12].
2. Rename FOLIO_ALREADY_COPIED to FOLIO_CONTENT_COPIED. (David Hildenbrand)
3. Mark the copy-done state per folio (FOLIO_CONTENT_COPIED) right after each successful copy, instead of threading an already_copied bool through migrate_folios_move() -> migrate_folio_move() -> move_to_new_folio(). This looks clean and lets a partially failed batch fall back per folio rather than re-copying the whole
batch. (David)
4. Moved folios_mc_copy() into mm/migrate.c as migrate_folios_mc_copy() to have per-folio copy marker (David). And add cond_resched() (Sashiko)
5. FOLIO_CONTENT_COPIED packs into the unused low bits of the anon_vma pointer in migrate_info, but 32-bit cannot guarantee bit-2 is free. The flag is BIT(2) on CONFIG_64BIT and 0 otherwise,
and MIGRATION_COPY_OFFLOAD now depends on 64BIT. (Sashiko, Zi Yan)
6. Move copy-offload interface out of migrate.c into migrate_copy_offload.c. Restructure patches (migrate_offload_do_batch) (David)
7. Add MAINTAINERS entry for drivers/migrate_offload (David)
8. Avoid DMA-pinned folios on the batch path to avoid stale data race. (Sashiko). So, could not rename folio_can_batch_copy) to page-specific name, as it's no longer specific to movable_ops.
9. Add configurable migration reason callback. (David Rientjes)
10. Renamed the dispatch static_call to migrate_offload_batch_copy_fn and the hot-path predicate to migrate_should_offload().
11. Fix the DCBM crash when build with =y. Expose DCBM runtime
knobs as module parameters under /sys/module/dcbm/parameters instead of earlier /sys/kernel.
12. Rebased on v7.2-rc1.
DESIGN:
-------
New migration flow:
[ migrate_pages_batch() ]
|
|--> offload = migrate_should_offload(reason) // core filters by migration reason
|
|--> for each folio:
| migrate_folio_unmap() // unmap the folio
| +--> (success):
| if offload && folio_can_batch_copy():
| -> unmap_batch / dst_batch // batch list for copy offloading
| else:
| -> unmap_single / dst_single // single list for per-folio CPU copy
|
|--> try_to_unmap_flush() // single batched TLB flush
|
|--> Batch copy (if unmap_batch not empty):
| - Migrator is configurable at runtime via module parameters.
| static_call(migrate_offload_batch_copy_fn) // Pluggable Migrators
| / | \
| v v v
| [ default ] [ DMA (dcbm) ] [ ... ]
| Each copied dst is marked FOLIO_CONTENT_COPIED; folios left
| unmarked (driver error / copy failure) fall back to per-folio
| CPU copy in the move phase.
|
+--> migrate_folios_move() // metadata, PTEs, finalizeOffload registration:
A driver fills struct migrator { .name, .offload_copy, .owner } and calls migrate_offload_register(). This:
- pins the module
- patches the migrate_offload_batch_copy_fn static_call target
- enables the migrate_offload_enabled static branch.
migrate_offload_unregister() disables the branch, reverts the static_call, then synchronize_srcu() waits for in-flight migrations before module_put().
PERFORMANCE RESULTS:
--------------------
AMD EPYC 7713 (Zen 3), 2 sockets, 32 cores, SMT on,
1 NUMA node per socket, 256 GB/node, v7.2-rc1, DVFS=Performance, PTDMA (16 DMA channels).
Benchmark: move_pages() syscall to move pages between two NUMA nodes.
1). Moving different sized folios such that total transfer size is constant (1GB), with different number of DMA channels. Throughput in GB/s.
a. Baseline (vanilla kernel, single-threaded, serial folio_copy):
================================================================================
4K | 16K | 64K | 256K | 1M | 2M |
================================================================================
3.28±0.14 | 4.98±0.18 | 6.19±0.08 | 6.77±0.08 | 7.02±0.11 | 10.80±0.13 |
b. DMA offload (Patched Kernel, dcbm driver, N DMA channels):
============================================================================================
N channel| 4K | 16K | 64K | 256K | 1M | 2M |
============================================================================================
1 | 2.38±0.17 | 2.77±0.03 | 3.21±0.03 | 5.00±0.02 | 5.09±0.64 | 12.62±0.07 | 2 | 2.87±0.11 | 4.06±0.05 | 5.09±0.04 | 6.97±0.08 | 8.43±0.06 | 14.32±0.10 | 4 | 3.32±0.07 | 5.30±0.06 | 7.21±0.09 | 9.69±0.15 | 11.36±0.13 | 26.98±0.19 | 8 | 3.68±0.09 | 6.28±0.10 | 9.16±0.13 | 12.05±0.16 | 15.33±2.80 | 46.06±0.55 | 12 | 3.83±0.05 | 6.65±0.17 | 10.00±0.16 | 12.98±0.18 | 15.87±0.19 | 61.31±1.28 | 16 | 3.94±0.09 | 6.78±0.10 | 10.48±0.13 | 13.48±0.20 | 16.90±0.24 | 65.06±2.46 |
2). First-folio latency: custom tracepoints (in migrate_pages_batch enter/exit,
migrate_folio_done) measure latency per migrate_pages_batch() call.
Throughput (GB/s) and first-folio latency (us), median of 10 runs.
a. Vanilla Kernel:
NR_MAX_BATCHED_MIGRATION upstream default value is 512.
--- Order 0 (4K folios) --- --- Order 9 (2M folios) ---
n vanilla/cpu n vanilla/cpu
(folios) GB/s | first(us) (folios) GB/s | first(us)
-------------------------- --------------------------
1 0.03 | 24 1 6.86 | 204
4 0.13 | 30 4 8.68 | 191
8 0.27 | 27 8 7.92 | 207
16 0.43 | 34 16 6.77 | 234
64 1.12 | 51 64 10.44 | 179
256 1.67 | 166 256 10.43 | 181
512 1.98 | 255 512 10.55 | 179
2048 2.38 | 233
4096 2.42 | 168
16384 2.72 | 167
65536 3.00 | 156262144 3.10 | 151
b. Patched kernel:
N = NR_MAX_BATCHED_MIGRATION (in pages), Total migrated data fixed at 1 GB. Change N with knob (just for testing) to measure impact of different max batched size.
--- ORDER 0 (4K folios) ---
N offload/dma1 offload/dma4 offload/dma16
GB/s | first(us) GB/s | first(us) GB/s | first(us)
------------------------------------------------------------------------
512 2.21 | 628 3.29 | 275 3.25 | 245
1024 2.06 | 1271 3.21 | 601 3.36 | 518
2048 2.02 | 2646 3.00 | 1388 3.20 | 1110
4096 2.08 | 4832 3.17 | 2514 3.41 | 2175
8192 2.16 | 9253 3.14 | 4839 3.62 | 3592
16384 2.24 | 17543 3.23 | 9680 3.58 | 7144
32768 2.22 | 36408 3.26 | 19301 3.67 | 14524
65536 2.12 | 82572 3.24 | 38091 3.62 | 29835
131072 2.08 | 153669 3.17 | 79744 3.48 | 62157
262144 2.05 | 332297 2.97 | 175315 3.33 | 134774--- ORDER 9 (2M folios) ---
N offload/dma1 offload/dma4 offload/dma16
GB/s | first(us) GB/s | first(us) GB/s | first(us)
------------------------------------------------------------------------
512 11.74 | 160 11.71 | 160 11.75 | 159
1024 12.18 | 310 13.82 | 274 13.76 | 275
2048 12.39 | 612 25.55 | 290 25.69 | 289
4096 12.54 | 1211 26.25 | 564 42.36 | 334
8192 12.54 | 2421 26.82 | 1111 51.85 | 485
16384 12.61 | 4824 26.91 | 2209 54.26 | 925
32768 12.62 | 9652 27.04 | 4404 54.72 | 1942
65536 12.64 | 19287 26.95 | 8835 57.30 | 3535
131072 12.64 | 38824 26.95 | 17900 58.58 | 7747
262144 12.66 | 77610 26.95 | 35743 66.31 | 13801OPEN QUESTION:
--------------
The best batch size depends on the hardware, and bigger isn't always better. NR_MAX_BATCHED_MIGRATION decides how many pages we move at once. Higher batch size can help amortize the setup cost of migrator but increases the first-folio latency (the folio is inaccessible for this window).
Goals could be workload dependent, e.g. higher throughput versus same throughput under a bounded latency.
Should this be tunable to accommodate different hardware and goals?
FOLLOW-UPS:
-----------
1. dmaengine_prep_dma_memcpy_sg() in DCBM (Vinod Koul); needs the ptdma/sdxi SG hook - device_prep_dma_memcpy_sg [10]. will post separately. This will address two concerns:
- IOMMU SG merging in DCBM: dma_map_sgtable() may merge PFNs unevenly so src.nents != dst.nents. (Gregory)
- Descriptor Chaining: out-of-order completion of DMA descriptors on some dma engine eg. Intel DSA can yield incorrect results. (Karim Manaouil)
2. SDXI as a second migrator [11]. SDXI is a generic memcpy engine without DMA_PRIVATE, so channel acquisition uses dma_find_channel() rather than dma_request_chan_by_mask(); I have a local DCBM variant working and will post once SDXI settles.
3. Revisit Multi-threaded CPU copy migrator once the infra is settled or follow it separately as it brings other discussion, like whom to charge? [13].
4. Batching the migration rmap walks: try_to_migrate_one() and remove_migration_pte() overheads dominate for PTE-mapped large folios. I have this working locally, and will post it separately.
EARLIER POSTINGS:
-----------------
[1] RFC V5: https://lore.kernel.org/all/[email protected]
[2] RFC V4: https://lore.kernel.org/all/[email protected]
[3] RFC V3: https://lore.kernel.org/all/[email protected]
[4] RFC V2: https://lore.kernel.org/all/[email protected]
[5] RFC V1: https://lore.kernel.org/all/[email protected]
[6] RFC from Zi Yan: https://lore.kernel.org/all/[email protected]
RELATED DISCUSSIONS:
--------------------
[7] MM-alignment Session [Nov 12, 2025]:
https://lore.kernel.org/linux-mm/[email protected] [8] Linux Memory Hotness and Promotion call [Nov 6, 2025]: https://lore.kernel.org/linux-mm/[email protected] [9] LSFMM 2025: https://lore.kernel.org/all/[email protected] [10] DMA_MEMCPY_SG comparison: https://lore.kernel.org/linux-mm/[email protected] [11] SDXI V3: https://lore.kernel.org/all/[email protected] [12] migrate cleanups/prep: https://lore.kernel.org/all/[email protected] [13] Charge calling thread for multi-threaded copy: https://lore.kernel.org/all/[email protected]/ [14] OSS India: https://ossindia2025.sched.com/event/23Jk1
Thanks to everyone who reviewed, tested, or participated in discussions around this series.
---
Shivank Garg (4):
mm/migrate: skip data copy for already-copied folios mm/migrate: add batch-copy path in migrate_pages_batch mm/migrate: add copy offload registration infrastructure drivers/migrate_offload: add DMA batch copy driver (dcbm)
Zi Yan (1):
mm/migrate: adjust NR_MAX_BATCHED_MIGRATION for testing
MAINTAINERS | 2 + drivers/Kconfig | 2 + drivers/Makefile | 2 + drivers/migrate_offload/Kconfig | 9 + drivers/migrate_offload/Makefile | 1 + drivers/migrate_offload/dcbm/Makefile | 1 + drivers/migrate_offload/dcbm/dcbm.c | 481 ++++++++++++++++++++++++++++++++++ include/linux/migrate.h | 28 ++ include/linux/migrate_copy_offload.h | 69 +++++ mm/Kconfig | 6 + mm/Makefile | 1 + mm/migrate.c | 133 +++++++--- mm/migrate_copy_offload.c | 249 ++++++++++++++++++ 13 files changed, 954 insertions(+), 30 deletions(-)
---
base-commit: 8b84e29dc92dbcada913c9bab976aa6f761b04e6
change-id: 20260616-shivank-batch-migrate-offload-deac05cbeaa5
prerequisite-change-id: 20260626-migrate-cleanups-prep-77a0ad340cc6:v1
prerequisite-patch-id: 816a6f6957cc9c0f3903db7b7f462a4ade2a7519
prerequisite-patch-id: d8521dbc801fb6e7cbaa5be8cecad491f7e2f809
prerequisite-patch-id: 3fcedadd87cd30b3fe8833e0ed33890f15c0e950
Best regards,
Signature · 1 line
Shivank Garg <[email protected]>
RFC PATCH v6 1/5 mm/migrate: skip data copy for already-copied folios
Add FOLIO_CONTENT_COPIED marker to the dst->migrate_info migration state. When set, it tells __migrate_folio() to skip folio_mc_copy() and perform metadata-only migration. This bit is not set yet, the batch-copy path enables it later in a subsequent patch.
Update __migrate_folio_extract() to preserve FOLIO_CONTENT_COPIED while it consumes old states of src folio.
Move the dst->migrate_info state enum to migrate.h header file so offload drivers can see FOLIO_CONTENT_COPIED.
On 32Bit, we do not have spare bit to store FOLIO_CONTENT_COPIED info, migration copy offload is disabled for them.
--- include/linux/migrate.h | 25 +++++++++++++++++++++++++ mm/migrate.c | 29 +++++++++++++---------------- 2 files changed, 38 insertions(+), 16 deletions(-)
include/linux/migrate.h +25 -0
@@ -72,6 +72,31 @@ int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, struct folio *folio, int extra_count);int set_movable_ops (const struct movable_operations *ops,enum pagetype type); +/* +* To record some information during migration, we use the migrate_info +* field of struct folio of the newly allocated destination folio, +* together with the anon_vma pointer. The state is encoded in the +* unused low bits of the pointer. +* This is safe because nobody is using it except us. +* +* FOLIO_WAS_MAPPED and FOLIO_WAS_MLOCKED record the src folios's state +* at unmap time and are consumed during the move/undo phase. +* FOLIO_CONTENT_COPIED tells __migrate_folio() that the folio contents +* have already been copied, so the per-folio copy can be skipped. A +* driver must set this bit on each dst folio it copied. +*/ +enum { +FOLIO_WAS_MAPPED =BIT (0 ), +FOLIO_WAS_MLOCKED =BIT (1 ), +FOLIO_OLD_STATES =FOLIO_WAS_MAPPED |FOLIO_WAS_MLOCKED , +#ifdef CONFIG_64BIT +FOLIO_CONTENT_COPIED =BIT (2 ), +#else +/* On 32bit we do not have a spare bit, migration-copy offload is disabled. */ +FOLIO_CONTENT_COPIED =0 , +#endif +}; +#else static inline void putback_movable_pages (struct list_head *l) {}
mm/migrate.c +13 -16
@@ -859,14 +859,21 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, enum migrate_mode mode) {int rc, expected_count =folio_expected_ref_count (src) +1 ; +const bool already_copied = dst->migrate_info &FOLIO_CONTENT_COPIED ; + +/* Consume the content copied marker */ +if (already_copied) + dst->migrate_info &= ~FOLIO_CONTENT_COPIED ;/* Check whether src does not have extra refs before we do more work */ if (folio_ref_count (src) != expected_count)return -EAGAIN ; - rc =folio_mc_copy (dst, src); -if (unlikely (rc)) -return rc; +if (!already_copied) { + rc =folio_mc_copy (dst, src); +if (unlikely (rc)) +return rc; + } rc =__folio_migrate_mapping (mapping, dst, src, expected_count);if (rc)
@@ -1129,17 +1136,6 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,return rc; } -/* -* To record some information during migration, we use the migrate_info -* field of struct folio of the newly allocated destination folio. -* This is safe because nobody is using it except us. -*/ -enum { -FOLIO_WAS_MAPPED =BIT (0 ), -FOLIO_WAS_MLOCKED =BIT (1 ), -FOLIO_OLD_STATES =FOLIO_WAS_MAPPED |FOLIO_WAS_MLOCKED , -}; -static void __migrate_folio_record (struct folio *dst,int old_folio_state,struct anon_vma *anon_vma) {
@@ -1151,9 +1147,10 @@ static void __migrate_folio_extract(struct folio *dst, {unsigned long info = dst->migrate_info; - *anon_vmap = (struct anon_vma *)(info & ~FOLIO_OLD_STATES ); + *anon_vmap = (struct anon_vma *)(info & ~(FOLIO_OLD_STATES | +FOLIO_CONTENT_COPIED )); *old_folio_state = info &FOLIO_OLD_STATES ; - dst->migrate_info =0 ; + dst->migrate_info &=FOLIO_CONTENT_COPIED ; }/* Restore the source folio to the original state upon failure */
Signature · 1 line
2.43.0
RFC PATCH v6 2/5 mm/migrate: add batch-copy path in migrate_pages_batch
In reply to Shivank GargAdd migrate_folios_mc_copy() which walks src/dst folio lists in lockstep, copies folio content via folio_mc_copy() and marks the dst with FOLIO_CONTENT_COPIED so the move phase in __migrate_folio() can skip the per-folio copy. The folios_cnt parameter is unused here, present for the offload_copy callback signature compatibility used by later patches in the series.
Split unmapped folios into batch-eligible (unmap_batch/dst_batch) and standard (unmap_single/dst_single) lists. A folio is batch-eligible when the migration reason is allowed by the driver, refcount equals expected and it's not a movable_ops page.
After TLB flush, batch copy the eligible folios via migrate_folios_mc_copy(), then run the move phase. The FOLIO_CONTENT_COPIED marker is consumed on first read in the __migrate_folio, so a -EAGAIN retry falls back to fresh per-folio copy.
--- include/linux/migrate.h | 3 ++ mm/migrate.c | 107 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 97 insertions(+), 13 deletions(-)
include/linux/migrate.h +3 -0
@@ -71,6 +71,9 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio);int folio_migrate_mapping (struct address_space *mapping,struct folio *newfolio,struct folio *folio,int extra_count);int set_movable_ops (const struct movable_operations *ops,enum pagetype type); +int migrate_folios_mc_copy (struct list_head *dst_list, +struct list_head *src_list, +unsigned int __always_unused folios_cnt);/* * To record some information during migration, we use the migrate_info
mm/migrate.c +94 -13
162 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC PATCH v6 3/5 mm/migrate: add copy offload registration infrastructure
In reply to Shivank GargAdd a registration interface that lets a single offload provider (DMA, multi-threaded CPU copy, etc) take over the batch folio copy performed by migrate_pages_batch().
The provider fills in a struct migrator with an offload_copy() callback and calls migrate_offload_register(), passing the set of migration reasons it wants to handle. Registration updates the migrate_offload_batch_copy_fn() static_call and enables the migrate_offload_enabled static branch. migrate_offload_unregister() reverts both.
The active_reason_mask is the single source of truth for which migration reasons are eligible for batched copy and offload. This is checked with the migrate_should_offload(). The active reason mask can be changed at runtime via migrate_offload_set_reason_mask(). Also, add migrate_offload_reason_mask_parse() and migrate_offload_reason_mask_format() so a provider can expose its reason mask using migrate_reason_names[] (e.g. "compaction,demotion", "all", "none").
Only one migrator can be active at a time. A second registration gets -EBUSY, and only the active migrator can unregister itself. The static_call dispatch is protected by SRCU so that the synchronize_srcu() in unregister waits for all in-flight copy before the module reference is dropped.
Callbacks must set FOLIO_CONTENT_COPIED on each successfully copied dst folio so __migrate_folio() skips the per-folio copy; folios without the marker fall back to CPU copy in the move phase.
--- MAINTAINERS | 2 + include/linux/migrate_copy_offload.h | 69 ++++++++++ mm/Kconfig | 6 + mm/Makefile | 1 + mm/migrate.c | 9 +- mm/migrate_copy_offload.c | 249 +++++++++++++++++++++++++++++++++++ 6 files changed, 329 insertions(+), 7 deletions(-)
MAINTAINERS +2 -0
@@ -17065,9 +17065,11 @@ F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy-weighted-interleave F: include/linux/mempolicy.h F: include/uapi/linux/mempolicy.h F: include/linux/migrate.h +F: include/linux/migrate_copy_offload.h F: include/linux/migrate_mode.h F: mm/mempolicy.c F: mm/migrate.c +F: mm/migrate_copy_offload.c F: mm/migrate_device.c MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)
include/linux/migrate_copy_offload.h new file +69 -0
69 lines not on this page · raw message
mm/Kconfig +6 -0
@@ -700,6 +700,12 @@ config MIGRATION config DEVICE_MIGRATION def_bool MIGRATION && ZONE_DEVICE +# Page-migration batch-copy offload infrastructure. +# Selected by migrator drivers (e.g. CONFIG_DCBM_DMA). +config MIGRATION_COPY_OFFLOAD + bool + depends on MIGRATION && 64BIT + config ARCH_ENABLE_HUGEPAGE_MIGRATION bool
mm/Makefile +1 -0
@@ -96,6 +96,7 @@ obj-$(CONFIG_FAILSLAB) += failslab.o obj-$(CONFIG_FAIL_PAGE_ALLOC) += fail_page_alloc.o obj-$(CONFIG_MEMTEST) += memtest.o obj-$(CONFIG_MIGRATION) += migrate.o +obj-$(CONFIG_MIGRATION_COPY_OFFLOAD) += migrate_copy_offload.o obj-$(CONFIG_NUMA) += memory-tiers.o obj-$(CONFIG_DEVICE_MIGRATION) += migrate_device.o obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o
mm/migrate.c +2 -7
@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h>
@@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;
@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {
mm/migrate_copy_offload.c new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.43.0
Huang, Ying
reviewerRe: [PATCH RFC v6 3/5] mm/migrate: add copy offload registration infrastructure
Shivank Garg <[email protected]> writes:
[snip]
Quoted 26 lines
mm/migrate.c +1
-6@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h> @@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;
mm/migrate.c static int migrate_pages_batch(struct list_head *from, · line 2051
Quoted 8 lines
mm/migrate.c +1
-1@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {
Found a difference between v5 and v6 here. In v5, migrate_pages_batch() checks the return value of migrate_offload_batch_copy() and acts accordingly. While in v6, it does not. Why was this changed?
IIUC, FOLIO_CONTENT_COPIED is now used to indicate a copy failure. Is this necessary? Is it possible that some (but not all) folios fail to be copied?
[snip]
---
Best Regards,
Huang, Ying
Zi Yan
reviewerRe: [PATCH RFC v6 3/5] mm/migrate: add copy offload registration infrastructure
Quoted 43 lines · Ying
Shivank Garg <[email protected]> writes:
[snip]
Quoted 26 lines
mm/migrate.c +1
-6@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h> @@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;mm/migrate.c static int migrate_pages_batch(struct list_head *from, · line 2051
Quoted 8 lines
mm/migrate.c +1
-1@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {Found a difference between v5 and v6 here. In v5,
migrate_pages_batch()checks the return value ofmigrate_offload_batch_copy()and acts accordingly. While in v6, it does not. Why was this changed?
Quoted 3 lines
IIUC,
FOLIO_CONTENT_COPIEDis now used to indicate a copy failure. Is this necessary? Is it possible that some (but not all) folios fail to be copied?
Based on the discussion[1], FOLIO_CONTENT_COPIED is used to indicate both
1. folio is copied via offloading, and 2. MC copy failure. So the code no longer needs to store the return value of migrate_offload_batch_copy() and can just check dst->migrate_info & FOLIO_CONTENT_COPIED.
For 32bit, FOLIO_CONTENT_COPIED is always 0, so all folios are always copied in the serialized path. Hmm, that might be causing double copying, since migrate_folios_mc_copy() copies batched folios and later migrate_folios_move() copies them again since dst->migrate_info & FOLIO_CONTENT_COPIED is always false. Maybe we could make migrate_folios_mc_copy() return immediately in 32bit, otherwise, we will need to find somewhere else to store FOLIO_CONTENT_COPIED.
[1] https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
[snip]
---
Best Regards,
Huang, Ying
Best Regards,
Yan, Zi
Re: [PATCH RFC v6 3/5] mm/migrate: add copy offload registration infrastructure
Quoted 62 lines · Zi Yan
Quoted 43 lines · Ying
Shivank Garg <[email protected]> writes:
[snip]
Quoted 26 lines
mm/migrate.c +1
-6@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h> @@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;mm/migrate.c static int migrate_pages_batch(struct list_head *from, · line 2051
Quoted 8 lines
mm/migrate.c +1
-1@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {Found a difference between v5 and v6 here. In v5,
migrate_pages_batch()checks the return value ofmigrate_offload_batch_copy()and acts accordingly. While in v6, it does not. Why was this changed?Quoted 3 lines
IIUC,
FOLIO_CONTENT_COPIEDis now used to indicate a copy failure. Is this necessary? Is it possible that some (but not all) folios fail to be copied?Based on the discussion[1],
FOLIO_CONTENT_COPIEDis used to indicate both
1. folio is copied via offloading, and 2. MC copy failure. So the code no longer needs to store the return value ofmigrate_offload_batch_copy()and can just checkdst->migrate_info&FOLIO_CONTENT_COPIED.For 32bit,
FOLIO_CONTENT_COPIEDis always 0, so all folios are always copied in the serialized path. Hmm, that might be causing double copying, sincemigrate_folios_mc_copy()copies batched folios and latermigrate_folios_move()copies them again sincedst->migrate_info&FOLIO_CONTENT_COPIEDis always false. Maybe we could makemigrate_folios_mc_copy()return immediately in 32bit, otherwise, we will need to find somewhere else to storeFOLIO_CONTENT_COPIED.
Quoted 3 lines
[1] https://lore.kernel.org/all/[email protected]/
Quoted 1 line
It is not cause double copying. migrate_should_offload() /and migrate_offload_enabled gate if folio can be added to unmap_batch/dst_batch.
migrate_offload_enabled branch is enabled from the offload driver like DCBM (which again depends on 64_BIT) will call migrate_offload_register().
I think I can add a defensive 64_BIT check in migrate_should_offload() to prevent any potential bugs.
Thanks,
Shivank
Quoted 9 lines
Quoted 5 lines
[snip]
---
Best Regards,
Huang, YingBest Regards,
Yan, Zi
Zi Yan
reviewerRe: [PATCH RFC v6 3/5] mm/migrate: add copy offload registration infrastructure
Quoted 63 lines · Shivank
Quoted 62 lines · Zi Yan
Quoted 43 lines · Ying
Shivank Garg <[email protected]> writes:
[snip]
Quoted 26 lines
mm/migrate.c +1
-6@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h> @@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;mm/migrate.c static int migrate_pages_batch(struct list_head *from, · line 2051
Quoted 8 lines
mm/migrate.c +1
-1@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {Found a difference between v5 and v6 here. In v5,
migrate_pages_batch()checks the return value ofmigrate_offload_batch_copy()and acts accordingly. While in v6, it does not. Why was this changed?Quoted 3 lines
IIUC,
FOLIO_CONTENT_COPIEDis now used to indicate a copy failure. Is this necessary? Is it possible that some (but not all) folios fail to be copied?Based on the discussion[1],
FOLIO_CONTENT_COPIEDis used to indicate both
1. folio is copied via offloading, and 2. MC copy failure. So the code no longer needs to store the return value ofmigrate_offload_batch_copy()and can just checkdst->migrate_info&FOLIO_CONTENT_COPIED.For 32bit,
FOLIO_CONTENT_COPIEDis always 0, so all folios are always copied in the serialized path. Hmm, that might be causing double copying, sincemigrate_folios_mc_copy()copies batched folios and latermigrate_folios_move()copies them again sincedst->migrate_info&FOLIO_CONTENT_COPIEDis always false. Maybe we could makemigrate_folios_mc_copy()return immediately in 32bit, otherwise, we will need to find somewhere else to storeFOLIO_CONTENT_COPIED.
Quoted 6 lines
Quoted 3 lines
[1] https://lore.kernel.org/all/[email protected]/
Quoted 1 line
It is not cause double copying.
migrate_should_offload()/andmigrate_offload_enabledgate if folio can be added to unmap_batch/dst_batch.
So migrate_should_offload() is actually migrate_should_offload_batched_copy(). 32BIT does not get batched copy nor offloaded copy.
Quoted 6 lines
migrate_offload_enabledbranch is enabled from the offload driver like DCBM (which again depends on 64_BIT) will callmigrate_offload_register().I think I can add a defensive 64_BIT check in
migrate_should_offload()to prevent any potential bugs.
I think a better name would be helpful and sufficient.
BTW, ideally, batched copy and offloaded copy are two separate features and could be enabled separately. But considering the hassle of finding a place to store FOLIO_CONTENT_COPIED on 32BIT, it might be fine to have a combined batched and offloaded copy.
Best Regards,
Yan, Zi
Huang, Ying
reviewerRe: [PATCH RFC v6 3/5] mm/migrate: add copy offload registration infrastructure
In reply to Zi YanQuoted 62 lines · Zi Yan
Quoted 43 lines · Ying
Shivank Garg <[email protected]> writes:
[snip]
Quoted 26 lines
mm/migrate.c +1
-6@@ -43,6 +43,7 @@#include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> #include <linux/pagewalk.h> +#include <linux/migrate_copy_offload.h> #include <asm/tlbflush.h> @@ -51,12 +52,6 @@#include "internal.h" #include "swap.h" -/* For now, never offload. Wired up in later patch. */ -static bool migrate_should_offload (int reason) -{ -return false; -} -static const struct movable_operations *offline_movable_ops;static const struct movable_operations *zsmalloc_movable_ops;mm/migrate.c static int migrate_pages_batch(struct list_head *from, · line 2051
Quoted 8 lines
mm/migrate.c +1
-1@@ -2050,7 +2045,7 @@ static int migrate_pages_batch(struct list_head *from,/* Batch-copy eligible folios before the move phase */ if (!list_empty (&unmap_batch)) -migrate_folios_mc_copy (&dst_batch, &unmap_batch, nr_batch); +migrate_offload_batch_copy (&dst_batch, &unmap_batch, nr_batch); retry =1 ;for (pass =0 ; pass < nr_pass && retry; pass++) {Found a difference between v5 and v6 here. In v5,
migrate_pages_batch()checks the return value ofmigrate_offload_batch_copy()and acts accordingly. While in v6, it does not. Why was this changed?Quoted 3 lines
IIUC,
FOLIO_CONTENT_COPIEDis now used to indicate a copy failure. Is this necessary? Is it possible that some (but not all) folios fail to be copied?Based on the discussion[1],
FOLIO_CONTENT_COPIEDis used to indicate both
1. folio is copied via offloading, and 2. MC copy failure. So the code no longer needs to store the return value ofmigrate_offload_batch_copy()and can just checkdst->migrate_info&FOLIO_CONTENT_COPIED.For 32bit,
FOLIO_CONTENT_COPIEDis always 0, so all folios are always copied in the serialized path. Hmm, that might be causing double copying, sincemigrate_folios_mc_copy()copies batched folios and latermigrate_folios_move()copies them again sincedst->migrate_info&FOLIO_CONTENT_COPIEDis always false. Maybe we could makemigrate_folios_mc_copy()return immediately in 32bit, otherwise, we will need to find somewhere else to storeFOLIO_CONTENT_COPIED.
Quoted 1 line
Thanks a lot for your information! Although personally I don't think that it's necessary to optimize for really rare folio_mc_copy() failure cases, I am fine with it if you think that this is the better way.
Quoted 3 lines
Quoted 3 lines
[snip]
---
Best Regards,
Huang, Ying
RFC PATCH v6 4/5 drivers/migrate_offload: add DMA batch copy driver (dcbm)
In reply to Shivank GargAdd a simple DMAEngine-based migrator that plugs into the page migration copy-offload infrastructure and batch-copies folios via DMA memcpy channels. It is intended for testing the offload plumbing and as a template for future migrators (SDXI, multi-threaded CPU copy, etc.).
On success, the dst folios are marked with FOLIO_CONTENT_COPIED so __migrate_folio skips the per-folio copy. On any DMA error, FOLIO_CONTENT_COPIED market is not set and the migration falls back to per-folio CPU copy.
dcbm registers with reason mask with reason mask MIGRATE_OFFLOAD_REASONS_ALLOWED, this set can be narrowed at runtime via the reason_mask parameter.
Runtime controls are under /sys/module/dcbm/parameters/:
offloading - enable/disable DMA offload (0/1) nr_dma_chan - max DMA channels to use (1..N) reason_mask - reasons to offload: names (e.g. "compaction,demotion"),
"all"/"none" or raw numerical mask.
folios_migrated - folios DMA-copied (write to reset) folios_failures - fallback count (write to reset)
CONFIG_DCBM_DMA selects MIGRATION_COPY_OFFLOAD so enabling the driver pulls in the infrastructure automatically.
Channel acquisition uses dma_request_chan_by_mask(DMA_MEMCPY), which works for providers that set DMA_PRIVATE (e.g. AMD PTDMA). Generic mem-to-mem engines that do not set DMA_PRIVATE (e.g. SDXI) should acquire channels via dma_find_channel(DMA_MEMCPY) or the async_tx APIs, which can be added in a follow-up.
[Correctness Note:
Karim: Descriptor can complete out of order for some dmaengines. so descriptor chaining may yield incorrect results. For correctness we need to add callback to every descriptor
https://lore.kernel.org/all/20260619160725.lfcxrbj5go67qy6u@wrangler
Shivank: device_prep_dma_memcpy_sg() would solve this.
]
--- drivers/Kconfig | 2 + drivers/Makefile | 2 + drivers/migrate_offload/Kconfig | 9 + drivers/migrate_offload/Makefile | 1 + drivers/migrate_offload/dcbm/Makefile | 1 + drivers/migrate_offload/dcbm/dcbm.c | 481 ++++++++++++++++++++++++++++++++++ 6 files changed, 496 insertions(+)
drivers/Kconfig +2 -0
@@ -253,4 +253,6 @@ source "drivers/cdx/Kconfig" source "drivers/resctrl/Kconfig" +source "drivers/migrate_offload/Kconfig" + endmenu
drivers/Makefile +2 -0
@@ -42,6 +42,8 @@ obj-y += clk/ # really early. obj-$(CONFIG_DMADEVICES) += dma/ +obj-$(CONFIG_MIGRATION_COPY_OFFLOAD) += migrate_offload/ + # SOC specific infrastructure drivers. obj-y += soc/ obj-$(CONFIG_PM_GENERIC_DOMAINS) += pmdomain/
drivers/migrate_offload/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config DCBM_DMA + tristate "DMA Core Batch Migrator" + depends on MIGRATION && DMA_ENGINE && 64BIT + select MIGRATION_COPY_OFFLOAD + help + DMA-based batch copy engine for page migration. Uses + DMAEngine memcpy channels to offload folio data copies + during migration. Primarily intended for testing the copy + offload infrastructure.
drivers/migrate_offload/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_DCBM_DMA) += dcbm/
drivers/migrate_offload/dcbm/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_DCBM_DMA) += dcbm.o
drivers/migrate_offload/dcbm/dcbm.c new file +481 -0
481 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm)
Quoted 5 lines · Shivank Garg
Add a simple DMAEngine-based migrator that plugs into the page migration copy-offload infrastructure and batch-copies folios via DMA memcpy channels. It is intended for testing the offload plumbing and as a template for future migrators (SDXI, multi-threaded CPU copy, etc.).
Hi Shivank,
Following my test report in reply to the cover letter [1], below are the code-level findings on dcbm.c. They cover completion ordering, channel lifetime and fault recovery, each with a design question.
The setup, the configurations compared and all results are in [1]. Each section below names the result it explains and refers to [1] for the numbers.
1. Completion ordering on out-of-order channels (Intel DSA)
-----------------------------------------------------------
Quoted 4 lines
+ if (i ==
work->src_sgt->nents- 1) {
+tx->callback=dma_completion_callback;
+tx->callback_param= work;
+ }
What I saw ([1], section 2):
- On DSA, the last descriptor's callback ran while earlier copies in the same channel list were still in flight.
- On a 4 KiB demotion run, the DSA work queue filled up and migration blocked.
- Counting completion on every descriptor (the diff below) removed both.
Where it comes from:
- submit_dma_transfers() sets DMA_PREP_INTERRUPT and dma_completion_callback only on the last descriptor of each channel's scatter-gather list.
- On ordered engines such as SDXI v4, that is enough. The driver appends a fenced interrupt descriptor when DMA_PREP_INTERRUPT is set, so the last callback implies the earlier descriptors are done.
- Intel DSA advertises DMA_COMPLETION_NO_ORDER (Karim's v5 point [2]). Trailing 4 KiB copies can finish, and run the callback, while an earlier 2 MiB THP copy is still in flight.
- The DSA driver also frees a software descriptor on normal completion only when it was prepared with DMA_PREP_INTERRUPT. Without it, the work queue fills up.
- The diff below requests an interrupt and counts every descriptor on DMA_COMPLETION_NO_ORDER channels:
* work->pending reserves one count for the last descriptor;
* it is incremented before each earlier descriptor is submitted;
* ordered engines still get a single interrupt per channel list.
@@ -173,14 +173,19 @@ static int submit_dma_transfers(struct dma_work *work)
struct dma_async_tx_descriptor *tx;
unsigned long flags = DMA_CTRL_ACK;
dma_cookie_t cookie;
+ bool no_order, last;
int i; + /* Last-descriptor callback covers earlier ones only on ordered channels. */
+ no_order = dma_has_cap(DMA_COMPLETION_NO_ORDER,
+ work->chan->device->cap_mask);
atomic_set(&work->pending, 1);
sg_src = work->src_sgt->sgl;
sg_dst = work->dst_sgt->sgl;
for_each_sgtable_dma_sg(work->src_sgt, sg_src, i) {
- if (i == work->src_sgt->nents - 1)
+ last = i == work->src_sgt->nents - 1;
+ if (last || no_order)
flags |= DMA_PREP_INTERRUPT;
tx = dmaengine_prep_dma_memcpy(work->chan,
@@ -192,7 +197,9 @@ static int submit_dma_transfers(struct dma_work *work)
return -EIO;
} - if (i == work->src_sgt->nents - 1) {
+ if (last || no_order) {
+ if (!last)
+ atomic_inc(&work->pending);
tx->callback = dma_completion_callback;
tx->callback_param = work;
}Question: would you include this check in v7 to handle unordered providers (Intel DSA) until device_prep_dma_memcpy_sg() lands, while keeping a single interrupt per channel list on ordered providers?
2. Per-batch channel allocation vs. holding channels across batches
-------------------------------------------------------------------
Quoted 2 lines
+
max_channels= min3(READ_ONCE(nr_dma_channels),nr_folios,
+ (unsigned int)MAX_DMA_CHANNELS);
[...]
Quoted 3 lines
+ for (i = 0; i <
max_channels; i++) {
+ works[actual_channels].chan =dma_request_chan_by_mask(&mask);
+ if (IS_ERR(works[actual_channels].chan))
[...]
Quoted 1 line
+
dma_release_channel(works[i].chan);
What I saw ([1], section 1):
- On SDXI, v6 is slower than CPU copy for move_pages() of THPs, and slower on 8 channels than on 1 for DAMON migrate_cold.
- On SDXI NUMA hint faults, v6 makes each promoting fault slower than CPU copy.
- On SDXI unbind under load, v6 warned in every run.
- Holding channels while offloading is enabled removed all three.
Where it comes from:
- Each batch requests and releases up to nr_dma_chan channels. The count is capped by the number of folios (min3() above), and the folios are split across the channels.
- On SDXI v4, each request and release starts and stops a hardware context.
- move_pages() and hint faults pass one folio per batch. So they pay a context start and stop for every folio.
- On 8 channels, dma_request_chan_by_mask() plus dma_release_channel() take 23-25 % of the time inside migrate_pages() on DAMON batches (4 % on 1 channel). That accounts for the whole 1 -> 8 drop.
- Requesting channels per batch does not avoid provider removal. The v6 unbind runs showed two kinds of WARN:
* dma_request_chan_by_mask() in the loop above reached sdxi_dma_alloc_chan_resources() while the provider was being torn down, and its unwind hit an ida_free WARN;
* a batch still held its channel when the provider unregistered it ("__dma_async_device_channel_unregister called while 1 clients hold a reference").
- So with either channel model, the client has to stop using a provider's channels before the provider unbinds (or, on DSA, before an idxd work queue is disabled). The DMAengine core has no removal callback that tells it to.
- My prototype handles this on the client side:
* it acquires channels at enable time with a provider filter;
* it registers BUS_NOTIFY_UNBIND_DRIVER notifiers on the provider
and child buses;
* the notifier drops a provider's channels after in-flight batches finish (with your dma_chan_put() fixes [3]).
chan = dma_request_channel(mask, dcbm_chan_filter, NULL); case BUS_NOTIFY_UNBIND_DRIVER: dcbm_drop_dev(dev, true); break;
Question: since dcbm needs to handle provider removal with either channel model, would you and Vinod prefer a DMAengine core callback that notifies channel holders before channel unregister / work-queue disable, or client-side bus notifiers in dcbm as above?
3. Timeouts, faulted channel recovery and CPU fallback policy
-------------------------------------------------------------
Quoted 2 lines
+ if (works[i].mapped)
+dmaengine_terminate_sync(works[i].chan);
What I saw ([1], section 3):
- On SDXI, a faulted descriptor makes every later batch on its channel wait out the timeout.
- With several failed channels, v6's one-by-one cleanup adds a drain per channel and led to hung-task reports.
- Replacing failed channels and draining them in parallel kept rounds near 20 s.
- On the NUMA hint-fault path, one faulted descriptor still stalls every faulting task for about 20 s.
Where it comes from:
- After an SDXI address fault, the context stops before the trailing interrupt descriptor, so the callback never runs.
- tx_status() reports DMA_ERROR 0.1-0.2 ms after submission. dcbm does not poll it, and waits for wait_for_completion_timeout() to expire (10 s).
- A faulted channel kept in the pool repeats that wait for every batch sent to it. A 1 GiB move_pages() call is 512 single-THP batches, round-robin over 16 channels, so 32 of them land on the dead channel. The first waits 10 s; each later one waits 10 s plus a 10 s drain: about 645 s per call.
- In v6, cleanup_dma_work() then calls dmaengine_terminate_sync() on each affected channel in turn:
* each waits up to 10 s in sdxi_dma_synchronize();
* 16 failed channels cost 130 s;
* when the whole function has stopped, the channel releases that follow also run one by one, about 2.4 s each.
- Calling dmaengine_terminate_async() on all failed channels, and running their dmaengine_synchronize() in parallel, overlaps the drains into one 10 s window. The work runs on a WQ_MEM_RECLAIM workqueue, so it is safe when dcbm is called from kswapd on demotion.
- dma_release_channel() is deferred to a background work item. The same work item re-requests replacement channels (the refill).
- When the refill gets back fewer channels than it released, offloading is marked degraded and batches use CPU copy:
/* Fewer channels re-acquired than failed channels just released. */
if (dcbm_nr_chans - nr < replaced) {
dcbm_degraded = true;- A refill shortfall has two possible causes:
* the provider function is in an error state;
* another DMAengine client took the freed channels during the refill.
- I forced the refill to fail on a healthy function (3 runs each):
* Without the degraded mode: dcbm carried on with 15 of 16 channels at the same rate.
* With the degraded mode: dcbm went to CPU copy until offloading was re-enabled.
- On the hint-fault path, the faulted channel stays in the round-robin until its first timeout. Each faulting task's next single-folio batch lands on it, and waits the 10 s timeout plus a 10 s drain.
Question: when failed channels cannot be replaced after a timeout, which should dcbm do?
- Stay on CPU fallback until offloading is re-enabled.
- Carry on with the channels it still holds, and retry with a backoff.
- Rely on error reporting from the provider, so it can tell a failed function from a busy one without waiting out the 10 s timeout.
And should MR_NUMA_MISPLACED stay out of offload until failures are detected sooner, for example through a copy-engine choice carried in migrate_control, as your migration refactor RFC suggested?
Thanks,
Ravi
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/20260619160725.lfcxrbj5go67qy6u@wrangler/
[3] https://lore.kernel.org/all/[email protected]/
Re: [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm)
The diff in section 1 of my reply above lost its indentation on the way out. Here it is again, with its indentation restored:
@@ -173,14 +173,19 @@ static int submit_dma_transfers(struct dma_work *work)
struct dma_async_tx_descriptor *tx;
unsigned long flags = DMA_CTRL_ACK;
dma_cookie_t cookie;
+ bool no_order, last;
int i; + /* Last-descriptor callback covers earlier ones only on ordered channels. */
+ no_order = dma_has_cap(DMA_COMPLETION_NO_ORDER,
+ work->chan->device->cap_mask);
atomic_set(&work->pending, 1);
sg_src = work->src_sgt->sgl;
sg_dst = work->dst_sgt->sgl;
for_each_sgtable_dma_sg(work->src_sgt, sg_src, i) {
- if (i == work->src_sgt->nents - 1)
+ last = i == work->src_sgt->nents - 1;
+ if (last || no_order)
flags |= DMA_PREP_INTERRUPT;
tx = dmaengine_prep_dma_memcpy(work->chan,
@@ -192,7 +197,9 @@ static int submit_dma_transfers(struct dma_work *work)
return -EIO;
} - if (i == work->src_sgt->nents - 1) {
+ if (last || no_order) {
+ if (!last)
+ atomic_inc(&work->pending);
tx->callback = dma_completion_callback;
tx->callback_param = work;
}Sorry for the noise.
Thanks,
Ravi
Re: [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm)
In reply to Ravi JonnalagaddaQuoted 3 lines · Ravi Jonnalagadda
Question: would you include this check in v7 to handle unordered providers (Intel DSA) until
device_prep_dma_memcpy_sg()lands, while keeping a single interrupt per channel list on ordered providers?
Hi Ravi, Shivank,
I run dcbm on DSA as well, on top of v6, and hit the same three things. Two of them are dmaengine matters that I have series for, so here are some pointers before v7.
On the check: DMA_COMPLETION_NO_ORDER is going away in my polled-status series, together with DMA_OUT_OF_ORDER:
https://lore.kernel.org/dmaengine/[email protected]/
With that series idxd answers the status of every cookie from the descriptor's own completion record. A client can wait for each descriptor of a batch, with an interrupt or by polling. A descriptor without DMA_PREP_INTERRUPT is retired by the query that sees it end, so the work queue no longer fills up. v2 of it is in preparation. It gives a provider a flag that says its status is per descriptor, and a client like dcbm can test that where it would test DMA_COMPLETION_NO_ORDER today.
In my copy of dcbm every descriptor has its own completion on every provider, counted down on a pending counter as in your diff. That needs no test at all, at the price of an interrupt per descriptor on an ordered provider.
Quoted 4 lines
Question: since dcbm needs to handle provider removal with either channel model, would you and Vinod prefer a DMAengine core callback that notifies channel holders before channel unregister / work-queue disable, or client-side bus notifiers in dcbm as above?
I hold the channels too, and I have a third variant for this. It is not posted yet. The core marks a channel that its provider removes under clients as detached. The channel takes no new work, what is outstanding on it ends with an error, and its memory stays until the last client releases it. The client tests dma_chan_detached() where it uses the channel and lets go of it then. That needs no callback into the client under the provider's locks, and the client does not have to know the provider's bus.
It goes on top of the two helpers of this series, which is on the list:
https://lore.kernel.org/r/[email protected]
Today idxd warns and then frees the channel under a client that still holds it when the queue is unbound, which is the warning you saw.
Quoted 2 lines
Question: when failed channels cannot be replaced after a timeout, which should dcbm do?
On DSA I ended up never terminating from dcbm. terminate_all acts on the whole channel, so on a held, shared channel it ends the other batches too. A device whose completions are overdue takes no new work until everything out on it has landed, and the CPU copies meanwhile. A halted DSA device completes what it held with an error, so that ends with the device's own recovery.
Quoted 2 lines
And should
MR_NUMA_MISPLACEDstay out of offload until failures are detected sooner
I leave NUMA hinting faults out by default, for the reason you give.
For device_prep_dma_memcpy_sg() I have an idxd implementation on DSA batch descriptors. It is not posted either, in case it helps the comparison.
I think it would be best to merge my dcbm changes with a v7 and with yours instead of posting yet another variant. So that you can see my changes now, I am sending the dcbm part as an RFC on top of v6. It applies on v7.4-rc2 and does not need my dmaengine series. The patches that do need my dmaengine series, the detached channels and the idxd memcpy_sg among it, will follow with those series.
Shivank, you can take from the RFC what fits v7, and let me know if you need any changes.
Thanks,
Daniel
RFC PATCH v6 5/5 mm/migrate: adjust NR_MAX_BATCHED_MIGRATION for testing
In reply to Shivank GargFrom: Zi Yan <[email protected]>
Change NR_MAX_BATCHED_MIGRATION to HPAGE_PUD_NR to allow batching THP copies.
These are for testing purpose only.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -1592,7 +1592,7 @@ static inline int try_split_folio(struct folio *folio, struct list_head *split_f }#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define NR_MAX_BATCHED_MIGRATION HPAGE_PMD_NR +#define NR_MAX_BATCHED_MIGRATION HPAGE_PUD_NR#else #define NR_MAX_BATCHED_MIGRATION 512#endif
Signature · 1 line
2.43.0
Huang, Ying
reviewerHi, Garg,
Thanks for updated patch.
Shivank Garg <[email protected]> writes:
[snip]
Quoted 92 lines
PERFORMANCE RESULTS:
--------------------AMD EPYC 7713 (Zen 3), 2 sockets, 32 cores, SMT on,
1 NUMA node per socket, 256 GB/node, v7.2-rc1, DVFS=Performance, PTDMA (16 DMA channels).Benchmark:
move_pages()syscall to move pages between two NUMA nodes.1). Moving different sized folios such that total transfer size is constant (1GB), with different number of DMA channels. Throughput in GB/s.
a. Baseline (vanilla kernel, single-threaded, serial
folio_copy):
================================================================================
4K | 16K | 64K | 256K | 1M | 2M |
================================================================================
3.28±0.14 | 4.98±0.18 | 6.19±0.08 | 6.77±0.08 | 7.02±0.11 | 10.80±0.13 |b. DMA offload (Patched Kernel, dcbm driver, N DMA channels):
============================================================================================
N channel| 4K | 16K | 64K | 256K | 1M | 2M |
============================================================================================1 | 2.38±0.17 | 2.77±0.03 | 3.21±0.03 | 5.00±0.02 | 5.09±0.64 | 12.62±0.07 | 2 | 2.87±0.11 | 4.06±0.05 | 5.09±0.04 | 6.97±0.08 | 8.43±0.06 | 14.32±0.10 | 4 | 3.32±0.07 | 5.30±0.06 | 7.21±0.09 | 9.69±0.15 | 11.36±0.13 | 26.98±0.19 | 8 | 3.68±0.09 | 6.28±0.10 | 9.16±0.13 | 12.05±0.16 | 15.33±2.80 | 46.06±0.55 | 12 | 3.83±0.05 | 6.65±0.17 | 10.00±0.16 | 12.98±0.18 | 15.87±0.19 | 61.31±1.28 | 16 | 3.94±0.09 | 6.78±0.10 | 10.48±0.13 | 13.48±0.20 | 16.90±0.24 | 65.06±2.46 |2). First-folio latency: custom tracepoints (in
migrate_pages_batchenter/exit,
migrate_folio_done) measure latency permigrate_pages_batch()call.Throughput (GB/s) and first-folio latency (us), median of 10 runs.
a. Vanilla Kernel:
NR_MAX_BATCHED_MIGRATIONupstream default value is 512.
--- Order 0 (4K folios) --- --- Order 9 (2M folios) ---n vanilla/cpu n vanilla/cpu (folios) GB/s | first(us) (folios) GB/s | first(us) -------------------------- -------------------------- 1 0.03 | 24 1 6.86 | 204 4 0.13 | 30 4 8.68 | 191 8 0.27 | 27 8 7.92 | 207 16 0.43 | 34 16 6.77 | 234 64 1.12 | 51 64 10.44 | 179 256 1.67 | 166 256 10.43 | 181 512 1.98 | 255 512 10.55 | 179 2048 2.38 | 233 4096 2.42 | 168 16384 2.72 | 167 65536 3.00 | 156262144 3.10 | 151
b. Patched kernel:
N =NR_MAX_BATCHED_MIGRATION(in pages), Total migrated data fixed at 1 GB. Change N with knob (just for testing) to measure impact of different max batched size.--- ORDER 0 (4K folios) ---
N offload/dma1 offload/dma4 offload/dma16 GB/s | first(us) GB/s | first(us) GB/s | first(us) ------------------------------------------------------------------------ 512 2.21 | 628 3.29 | 275 3.25 | 245 1024 2.06 | 1271 3.21 | 601 3.36 | 518 2048 2.02 | 2646 3.00 | 1388 3.20 | 1110 4096 2.08 | 4832 3.17 | 2514 3.41 | 2175 8192 2.16 | 9253 3.14 | 4839 3.62 | 3592 16384 2.24 | 17543 3.23 | 9680 3.58 | 7144 32768 2.22 | 36408 3.26 | 19301 3.67 | 14524 65536 2.12 | 82572 3.24 | 38091 3.62 | 29835 131072 2.08 | 153669 3.17 | 79744 3.48 | 62157 262144 2.05 | 332297 2.97 | 175315 3.33 | 134774--- ORDER 9 (2M folios) ---
N offload/dma1 offload/dma4 offload/dma16 GB/s | first(us) GB/s | first(us) GB/s | first(us) ------------------------------------------------------------------------ 512 11.74 | 160 11.71 | 160 11.75 | 159 1024 12.18 | 310 13.82 | 274 13.76 | 275 2048 12.39 | 612 25.55 | 290 25.69 | 289 4096 12.54 | 1211 26.25 | 564 42.36 | 334 8192 12.54 | 2421 26.82 | 1111 51.85 | 485 16384 12.61 | 4824 26.91 | 2209 54.26 | 925 32768 12.62 | 9652 27.04 | 4404 54.72 | 1942 65536 12.64 | 19287 26.95 | 8835 57.30 | 3535 131072 12.64 | 38824 26.95 | 17900 58.58 | 7747 262144 12.66 | 77610 26.95 | 35743 66.31 | 13801
Quoted 8 lines
OPEN QUESTION:
--------------The best batch size depends on the hardware, and bigger isn't always better.
NR_MAX_BATCHED_MIGRATIONdecides how many pages we move at once. Higher batch size can help amortize the setup cost of migrator but increases the first-folio latency (the folio is inaccessible for this window).
Yes. This is an important parameter for the batched migration. We really need more information from people who have workload information to make a decision. Can you try to reach them?
Also, can we find a sweet point where we can archive higher throughput without increasing latency too much (e.g., < 1ms)?
Quoted 4 lines
Goals could be workload dependent, e.g. higher throughput versus same throughput under a bounded latency.
Should this be tunable to accommodate different hardware and goals?
[snip]
---
Best Regards,
Huang, Ying
Quoted 5 lines · Shivank Garg
By batching the copy phase, we create an opportunity for hardware acceleration. This series builds the framework and provides a DMA offload driver (dcbm) as a reference implementation, targeting bulk migration workloads where offloading the copy improves throughput and latency while freeing CPU cycles.
Hi Shivank,
Following our DAMON perf-event access-sampling RFC v4 [1] for tiered DRAM and CXL memory, I evaluated v6 on the demotion and promotion path. Below are the test setup, findings on channel lifetime, completion ordering, and fault recovery, and a proposal for follow-up work.
How I tested
------------
Setup:
- Kernel: v6 on mm-new.
- Systems and memory: an AMD EPYC system (for SDXI) and an Intel Xeon system (for DSA), each with DRAM and a CXL Type 3 memory expander.
- Providers:
* AMD SDXI: Nathan's v4 driver [7], 16 channels.
* Intel DSA: the idxd driver, 4 devices, with Vinicius's idxd fixes v2 [3]. Its 7/8 (6/6 in v1 [2]) keeps a DSA channel usable after dmaengine_terminate_*(), which held channels rely on.
Configurations compared:
- CPU copy: baseline migration with DMA offload disabled.
- v6 as posted: dcbm as submitted in this series.
- v6 with dcbm changes, called "held channels" below:
* Hold DMA channels while offloading is enabled (instead of requesting and releasing channels on every batch), and release held channels when a provider unbinds.
* Wait for every descriptor on out-of-order DMA engines (instead of putting a completion callback only on the last descriptor).
* Recover from faulted channels in three steps:
- Replace a faulted channel after its timeout.
- Drain all failed channels in parallel. v6 terminates them one by one.
- Fall back to CPU copy when failed channels cannot be replaced. Section 3 compares held channels with and without these steps.
Workloads and metrics:
- move_pages() throughput (GB/s over the whole syscall):
* 1 GiB of 2 MiB THPs, DRAM -> CXL.
* Each migrate_pages() call moves one THP.
* GB/s = bytes migrated / wall time of the move_pages() call.
* This covers all the syscall does: page lookup and isolation, then unmap, copy and remap inside migrate_pages().
- DAMON migrate_cold and migrate_hot throughput (GB/s inside migrate_pages() only):
* 4 GiB of 2 MiB folios. Cold moves DRAM -> CXL, hot CXL -> DRAM.
* GB/s = bytes migrated / time inside migrate_pages().
* The time comes from the tracepoints mm_migrate_pages_start and mm_migrate_pages.
* kdamond also monitors between its migrations, so its wall time is not a migration rate.
- The two GB/s are not comparable with each other. Each is compared only across the configurations below.
- NUMA hint-fault promotion latency (us):
* NUMA balancing in memory-tiering mode (numa_balancing=2).
* The task is pinned to the CPUs of the DRAM node.
* Its memory is first placed on the CPU-less CXL node.
* Each hint fault promotes one 2 MiB THP or 4 KiB page, inside the fault. Every traced fault promoted one folio.
* Latency = median ftrace function-graph duration of handle_mm_fault() for the task.
- Reliability tests:
* Mixed batches on DSA: each batch is one 2 MiB THP + sixteen 4 KiB pages.
* Provider removal under load: SDXI unbind, DSA work-queue disable and DSA device unbind, 20 runs each.
* Injected descriptor faults on SDXI:
- A test-only debug build of dcbm points one copy descriptor of a batch at an unmapped IOVA (SDXI in an IOMMU DMA domain).
- The descriptor faults and stops its SDXI context, so its completion never arrives.
- Done with 1 dead descriptor, and with 16 at once (one per channel).
- Load during move_pages(): 4 processes moving 64 MiB each, or 1 GiB calls.
- Load during reclaim demotion: a 144 GiB fill of a 128 GiB DRAM node.
- Load during NUMA hint-fault promotion: 8 faulting tasks.
* Forced completion timeouts on DSA, 20 runs:
- A DSA page fault completes with an error instead of hanging, so the same injection does not apply there.
- Instead, the debug build makes one batch time out, with its descriptors finished or still in flight.
- Configurations alternated within one boot, unless marked otherwise.
- Numbers are medians of 3 runs. Data checks found 0 mismatches.
Quoted 4 lines
2. SDXI as a second migrator [11]. SDXI is a generic memcpy engine without
DMA_PRIVATE, so channel acquisition usesdma_find_channel()rather thandma_request_chan_by_mask(); I have a local DCBM variant working and will post once SDXI settles.
On Follow-up 2 in your cover letter [6]:
- v6 works with SDXI v4 [7] out of the box without dma_find_channel().
- When no shared-pool client holds a memcpy device, the DMAengine core marks it private automatically on the first exclusive channel request (even though SDXI does not set DMA_PRIVATE at probe).
What I saw and where it comes from
----------------------------------
1. Channel lifetime: per-batch allocation vs. holding channels What I saw:
- 2 MiB SDXI move_pages(), each migrate_pages() call moving one THP (CPU copy 15.63 GB/s):
* v6: 4.42 GB/s on 1 channel, 4.41 GB/s on 8.
* Held channels: 26.25 GB/s on 1 channel, 25.63 GB/s on 8.
- 2 MiB SDXI DAMON migrate_cold (CPU copy 20.70 GB/s):
* v6: 41.38 GB/s on 1 channel, dropping to 33.09 GB/s on 8.
* Held channels: 43.02 GB/s on 1 channel, 43.21 GB/s on 8.
- 2 MiB SDXI DAMON migrate_hot (CPU copy 14.36 GB/s):
* v6: 37.43 GB/s on 1 channel, dropping to 28.98 GB/s on 8.
* Held channels: 40.88 GB/s on 1 channel, 41.59 GB/s on 8.
- SDXI NUMA hint-fault promotion, median fault (CPU copy 147 us for a 2 MiB THP, 4 us for a 4 KiB page):
* v6: 479 us for 2 MiB, 424 us for 4 KiB.
* Held channels: 67 us for 2 MiB, 13 us for 4 KiB.
- SDXI unbind under move_pages() load:
* v6: every run warned (19/19 runs with a log), and 4 of 20 runs reset the machine. The warnings were of two kinds:
- a channel request reached the provider while it was being torn down (ida_free WARN in its channel allocation, once followed by a NULL pointer dereference);
- a batch still held its channel when the provider unregistered it ("... called while 1 clients hold a reference").
* Held channels, with the bus-unbind notifier shown in my reply to 4/5: 20/20 clean.
- DSA work-queue disable and device unbind under load:
* v6: under this load it blocks on a full work queue first (section 2). On a lighter load, idxd warned that v6 still held a channel of the work queue being disabled.
* Held channels, with the same notifier: 20/20 each, 0 WARNs.
Where it comes from:
- v6 requests and releases up to the configured channel limit (nr_dma_chan) on every batch, splitting the batch across them.
- On SDXI, each channel request and release starts and stops a hardware context over MMIO and the admin ring.
- So the per-batch cost depends on the provider: it is large where a channel request starts hardware state, as on SDXI.
- Because move_pages() and NUMA hint faults pass one folio per batch, v6 uses only one channel per batch and pays a hardware context start/stop for every single folio.
- On multi-folio DAMON batches with 8 channels (nr_dma_chan=8), starting and stopping 8 contexts on every batch takes 23-25 % of migrate_pages() time (vs. 4 % when starting/stopping 1 context), which accounts for the whole 1 -> 8 channel drop.
- Holding channels while offloading is enabled (offloading=1) eliminates that per-batch context setup. With held channels, 1 and 8 channels both reach about 43 GB/s on DAMON migrate_cold.
- A 4 KiB hint fault still takes 13 us with held channels, against 4 us with CPU copy, so small folios are better left to the CPU on this path.
- A per-batch request can start while the provider is being torn down, and a batch in flight holds its channel across the unbind; the WARNs above show both. Held channels are exposed to the same unbind for as long as they are held. In every case the client has to drop its channels before
the provider tears them down, and the DMAengine core has no removal callback that tells it to.
- Registering a bus-unbind notifier to drain in-flight batches and release held channels (with your channel-reference fixes [4]) passed 20/20 SDXI unbinds and 20/20 DSA work-queue disables plus 20/20 device unbinds with 0 WARNs:
workload / test | CPU copy | v6 (1/8 ch) | held (1/8 ch)
----------------------------+------------+-------------+--------------
SDXI move_pages 2M (GB/s) | 15.63 | 4.42 / 4.41 | 26.25 / 25.63 SDXI DAMON cold 2M (GB/s) | 20.70 |41.38 / 33.09| 43.02 / 43.21 SDXI DAMON hot 2M (GB/s) | 14.36 |37.43 / 28.98| 40.88 / 41.59 SDXI hint fault 2M/4K (us) | 147 / 4 | 479 / 424 | 67 / 13 SDXI unbind under load | - | 19/19 WARN | 20/20, 0 WARN DSA WQ disable / dev unbind | - | see above | 20/20 + 20/20
The code-level details and a question on channel-holder notification follow in my reply to 4/5.
2. Completion ordering: ordered (SDXI) vs. unordered (Intel DSA) What I saw:
- On Intel DSA with held channels, in mixed batches (one 2 MiB THP
+ sixteen 4 KiB pages), when the last descriptor's callback ran, the hardware completion record of at least one earlier descriptor was still unwritten in 172/438 batches (39 %) on 1 channel and 162/1740 (9 %) on 4 channels, on a kernel with lock debugging. On a kernel without it the rates were 14.1 % and 1.1 %.
- With completion counted on every descriptor, 0 of 3266 channel lists (the descriptors of one batch on one channel) completed early, in the same boot.
- On a 4 KiB demotion run with 1 held DSA channel, migration blocked in 5/5 runs after 109 folios, with all 128 work-queue descriptors allocated, vs. 0/5 blocked runs (at most 32/128 in use) with per-descriptor interrupts.
Where it comes from:
- v6 sets an interrupt and completion callback only on the last descriptor of each channel's scatter-gather list.
- That relies on in-order completion. It holds on ordered engines like SDXI, which fences its interrupt descriptor behind all earlier descriptors.
- Out-of-order engines like Intel DSA (Karim's v5 point [5]) can finish small 4 KiB copies at the end of a batch and run the callback while a 2 MiB copy at the front is still running.
- In addition, the DSA driver frees a software descriptor on normal completion only when that descriptor requested an interrupt.
- Requesting an interrupt and counting every descriptor on unordered channels eliminated both early completion (across 3266 channel lists) and descriptor exhaustion on DSA, while keeping one interrupt per channel list on SDXI:
DSA test (held channels) | last-descriptor | per-descriptor
----------------------------+---------------------+-------------------
mixed 2M+4K early (1/4 ch) | 39 % / 9 % | 0 / 3266 lists 4K demotion WQ exhaustion | 5/5 blocked | 0/5 blocked
The diff follows in my reply to 4/5.
3. Timeouts and fault recovery with held channels (SDXI, DSA) What I saw, per recovery step:
- Replace a faulted channel (1 faulted channel among 16, 1 GiB move_pages() calls of THPs):
* Kept in the pool: 645 s for the first call, 655 s for each later one.
* Replaced after its timeout: 10.4 s, then 0.05 s per call.
- Drain failed channels in parallel (4 processes moving 64 MiB each, 16 channels):
* v6's one-by-one cleanup, 16 faulted descriptors: 140.4-140.5 s per round of the four moves.
* One-by-one cleanup, function-wide errors (GSV_ERROR, 7 events across boots): 183-323 s per round, with hung-task reports.
* Parallel drain: 20.1-20.3 s per round, and all 16 function errors within 20.52 s with 0 hung tasks.
* Parallel drain from reclaim demotion: 8/8 runs clean, with the drain on a WQ_MEM_RECLAIM workqueue.
- On DSA with idxd v2, a forced timeout on a held channel recovered
in 20/20 runs. Without Vinicius's 7/8 [3] it never did (2/2).
- Still open: on the NUMA hint-fault path, 1 faulted descriptor
stalls all 8 faulting tasks for 19-20.5 s (up to 30.5 s with 16). Where it comes from:
- A faulted SDXI descriptor stops its context, so no completion arrives and dcbm waits out its 10 s timeout.
- A faulted channel left in the pool makes every later batch on it repeat that wait.
- One-by-one cleanup adds a drain of up to 10 s per failed channel. Parallel drain overlaps them into one 10 s window:
SDXI fault test (16 ch) | without the step | with the step
----------------------------+---------------------+-------------------
replace: 1 fault, 1G moves | 645s, then 655s | 10.4s, then 0.05s drain: 16 dead (4x64M load) | 140.4-140.5s (3/3) | 20.1-20.3s (3/3) drain: function error | 183-323s, hung (7) | <=20.52s, 0 (16) reclaim demotion, 1 dead | - | 8/8 clean hint fault, 1 / 16 dead | - | 19-20.5s / 30.5s
The code-level details and the fallback-policy questions follow in my reply to 4/5.
How to proceed
--------------
- In a reply to patch 4/5 that follows this one, I give the inline code context, the small unordered-completion diff, and the design questions for each of the three topics above.
- I see your migration refactor [8] reworks the batch path that v6 hooks into. Its RFC version also suggested that migrate_control could carry the copy-engine choice. I am happy to re-run these tests on v7 once it is rebased on that work.
- Would you like to fold the unordered-completion check into v7 for providers like Intel DSA, and have me post the held-channel and fault-recovery changes separately as a stacked RFC?
Thanks,
Ravi
[1] https://lore.kernel.org/linux-mm/20261005-damon-perf-rfc-v3-send-2026-10-03-v4-0-b03452e137f3@gmail.com/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/20260619160725.lfcxrbj5go67qy6u@wrangler/
[6] https://lore.kernel.org/all/[email protected]/
[7] https://lore.kernel.org/all/[email protected]/
[8] https://lore.kernel.org/all/[email protected]/