* Re: [PATCH RFC v6 0/5] Accelerate page migration with batch copying and hardware offload
[not found] <20260630-shivank-batch-migrate-offload-v6-0-da95d7e8b8a2@amd.com>
@ 2026-11-28 22:46 ` Ravi Jonnalagadda
[not found] ` <20260630-shivank-batch-migrate-offload-v6-4-da95d7e8b8a2@amd.com>
1 sibling, 0 replies; 3+ messages in thread
From: Ravi Jonnalagadda @ 2026-11-28 22:46 UTC (permalink / raw)
To: Shivank Garg
Cc: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Karim Manaouil, Frank van der Linden, Teja Vojjala,
Pravin Tamkhane, Kinsey Ho, Wei Xu, Matthew Wilcox,
Davidlohr Bueso, Vinod Koul, Bharata B Rao, SeongJae Park,
David Rientjes, Xuezheng Chu, Yiannis Nikolakopoulos, Dave Hansen,
Johannes Weiner, John Hubbard, Peter Xu, Rik van Riel,
Shakeel Butt, Tejun Heo, Fan Ni, Jonathan Cameron,
Aneesh Kumar K.V, Nathan Lynch, Frank Li, Dan Williams, linux-mm,
linux-kernel, Mike Day, dmaengine, Vinicius Costa Gomes, Frank Li
On Tue, 30 Jun 2026 07:28:36 +0000, Shivank Garg wrote:
> 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.
> 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.
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/20261012-wt-idxd-fixes-v1-0-30a35a445077@intel.com/
[3] https://lore.kernel.org/all/20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@intel.com/
[4] https://lore.kernel.org/all/20260822-dmaengine-kref-fix-v5-0-d4a4ee47d927@amd.com/
[5] https://lore.kernel.org/all/20260619160725.lfcxrbj5go67qy6u@wrangler/
[6] https://lore.kernel.org/all/20260630-shivank-batch-migrate-offload-v6-0-da95d7e8b8a2@amd.com/
[7] https://lore.kernel.org/all/20261103-sdxi-base-v4-0-3668ccc7aab8@amd.com/
[8] https://lore.kernel.org/all/20261119-migrate-refactor-shivank-v2-0-f4535bd0bc52@amd.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm)
[not found] ` <20260630-shivank-batch-migrate-offload-v6-4-da95d7e8b8a2@amd.com>
@ 2026-11-28 22:59 ` Ravi Jonnalagadda
2026-11-28 23:12 ` Ravi Jonnalagadda
0 siblings, 1 reply; 3+ messages in thread
From: Ravi Jonnalagadda @ 2026-11-28 22:59 UTC (permalink / raw)
To: Shivank Garg
Cc: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Karim Manaouil, Frank van der Linden, Teja Vojjala,
Pravin Tamkhane, Kinsey Ho, Wei Xu, Matthew Wilcox,
Davidlohr Bueso, Vinod Koul, Bharata B Rao, SeongJae Park,
David Rientjes, Xuezheng Chu, Yiannis Nikolakopoulos, Dave Hansen,
Johannes Weiner, John Hubbard, Peter Xu, Rik van Riel,
Shakeel Butt, Tejun Heo, Fan Ni, Jonathan Cameron,
Aneesh Kumar K.V, Nathan Lynch, Frank Li, Dan Williams, linux-mm,
linux-kernel, Mike Day, dmaengine, Vinicius Costa Gomes, Frank Li
On Tue, 30 Jun 2026 07:28:40 +0000, Shivank Garg wrote:
> 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)
-----------------------------------------------------------
> + 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
-------------------------------------------------------------------
> + max_channels = min3(READ_ONCE(nr_dma_channels), nr_folios,
> + (unsigned int)MAX_DMA_CHANNELS);
[...]
> + for (i = 0; i < max_channels; i++) {
> + works[actual_channels].chan = dma_request_chan_by_mask(&mask);
> + if (IS_ERR(works[actual_channels].chan))
[...]
> + 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
-------------------------------------------------------------
> + 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/20261128224616.66122-1-ravis.opensrc@gmail.com/
[2] https://lore.kernel.org/all/20260619160725.lfcxrbj5go67qy6u@wrangler/
[3] https://lore.kernel.org/all/20260822-dmaengine-kref-fix-v5-0-d4a4ee47d927@amd.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm)
2026-11-28 22:59 ` [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm) Ravi Jonnalagadda
@ 2026-11-28 23:12 ` Ravi Jonnalagadda
0 siblings, 0 replies; 3+ messages in thread
From: Ravi Jonnalagadda @ 2026-11-28 23:12 UTC (permalink / raw)
To: Shivank Garg
Cc: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Karim Manaouil, Frank van der Linden, Teja Vojjala,
Pravin Tamkhane, Kinsey Ho, Wei Xu, Matthew Wilcox,
Davidlohr Bueso, Vinod Koul, Bharata B Rao, SeongJae Park,
David Rientjes, Xuezheng Chu, Yiannis Nikolakopoulos, Dave Hansen,
Johannes Weiner, John Hubbard, Peter Xu, Rik van Riel,
Shakeel Butt, Tejun Heo, Fan Ni, Jonathan Cameron,
Aneesh Kumar K.V, Nathan Lynch, Frank Li, Dan Williams, linux-mm,
linux-kernel, Mike Day, dmaengine, Vinicius Costa Gomes, Frank Li
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-28 23:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260630-shivank-batch-migrate-offload-v6-0-da95d7e8b8a2@amd.com>
2026-11-28 22:46 ` [PATCH RFC v6 0/5] Accelerate page migration with batch copying and hardware offload Ravi Jonnalagadda
[not found] ` <20260630-shivank-batch-migrate-offload-v6-4-da95d7e8b8a2@amd.com>
2026-11-28 22:59 ` [PATCH RFC v6 4/5] drivers/migrate_offload: add DMA batch copy driver (dcbm) Ravi Jonnalagadda
2026-11-28 23:12 ` Ravi Jonnalagadda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox