From: Daniel Byrne <daniel1.byrne@intel.com>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: Daniel Byrne <daniel1.byrne@intel.com>,
Vinod Koul <vkoul@kernel.org>, Shivank Garg <shivankg@amd.com>,
Ravi Jonnalagadda <ravis.opensrc@gmail.com>,
dmaengine@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 08/10] dmaengine: reintroduce DMA_MEMCPY_SG
Date: Thu, 3 Dec 2026 13:15:42 -0800 [thread overview]
Message-ID: <20261203211542.2877574-1-daniel1.byrne@intel.com> (raw)
In-Reply-To: <aw8lMdRzFU54KtSy@SMW015318>
(cc trimmed to the lists.)
On Tue, 1 Dec 2026 19:51:13 +0000, Frank Li wrote:
> The key is how resolve src_nents != dst_ndents case. and each sg is miss
> matched, for example:
Hi Frank,
Thanks for taking a look at this.
I kept the rule that provider.rst still has for this type:
No matter what the overall size of the combined chunks for source and
destination is, only as many bytes as the smallest of the two will be
transmitted. That means the number and size of the scatter-gather
buffers in both lists need not be the same, and that the operation
functionally is equivalent to a strncpy where the count argument
equals the smallest total size of the two scatter-gather list
buffers.
So the transfer ends where the shorter of the two lists ends.
The way I handle a mismatch is that the provider walks both lists
together. Each piece is as long as what is left of the current source
entry or of the current destination entry, whichever is smaller, and
then the entry that ran out moves on to the next one. That gives at
most src_nents + dst_nents - 1 pieces, so 7 for the 3 and 5 entries in
your example. If a provider cannot do the whole transfer, it returns
NULL from the prep call and the client falls back to the CPU.
Since there isn't a provider in this series, the patch doesn't show
this. I have an idxd implementation that builds one DSA batch
descriptor with one copy per piece. It is not posted yet because it
depends on idxd fixes that are not all posted, but I would be happy to
share it. This is the general idea:
dst_avail = sg_dma_len(dst_sg);
src_avail = sg_dma_len(src_sg);
for (i = 0; i < batch_max; i++) {
dma_dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) -
dst_avail;
dma_src = sg_dma_address(src_sg) + sg_dma_len(src_sg) -
src_avail;
len = min_t(size_t, dst_avail, src_avail);
/* one MEMMOVE element of the batch: dma_src, dma_dst, len */
/* a list moves to its next entry when this one is used up */
dst_nents -= fetch_sg_and_pos(&dst_sg, &dst_avail, len);
src_nents -= fetch_sg_and_pos(&src_sg, &src_avail, len);
/* Stop when either scatter list is consumed. */
if (!dst_nents || !src_nents ||
!min_t(size_t, dst_avail, src_avail))
break;
}
I can send the whole patch as well if that helps. The client in patch
10 does not rely on mismatched lists either. Its two lists have one
entry per folio, with the same length on both sides.
Thanks,
Daniel
next prev parent reply other threads:[~2026-12-03 21:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 14:12 [RFC PATCH 00/10] mm/migrate: dcbm for Intel DSA, on top of the batch copy offload RFC v6 Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 01/10] mm/migrate: skip data copy for already-copied folios Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 02/10] mm/migrate: add batch-copy path in migrate_pages_batch Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 03/10] mm/migrate: add copy offload registration infrastructure Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 04/10] drivers/migrate_offload: add DMA batch copy driver (dcbm) Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 05/10] mm/migrate: give hugetlb its own bit for the content-copied marker Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 06/10] mm/migrate: keep folios with private data off the batch copy Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 07/10] mm/migrate: no filesystem reclaim under the batch's folio locks Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 08/10] dmaengine: reintroduce DMA_MEMCPY_SG Daniel Byrne
2026-12-01 19:51 ` Frank Li
2026-12-03 21:15 ` Daniel Byrne [this message]
2026-12-01 14:12 ` [RFC PATCH 09/10] dmaengine: add DMA_PREP_CACHE_CONTROL Daniel Byrne
2026-12-01 14:12 ` [RFC PATCH 10/10] drivers/migrate_offload: make dcbm correct on shared, out-of-order engines Daniel Byrne
2026-12-01 15:24 ` [RFC PATCH 00/10] mm/migrate: dcbm for Intel DSA, on top of the batch copy offload RFC v6 Dave Hansen
2026-12-01 16:05 ` Garg, Shivank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203211542.2877574-1-daniel1.byrne@intel.com \
--to=daniel1.byrne@intel.com \
--cc=Frank.li@oss.nxp.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ravis.opensrc@gmail.com \
--cc=shivankg@amd.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®