From: Christoph Hellwig <hch@lst.de>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Naman Jain <namjain@linux.microsoft.com>,
hch@lst.de, axboe@kernel.dk, akpm@linux-foundation.org,
viro@zeniv.linux.org.uk, osalvador@suse.de, logang@deltatee.com,
leon@kernel.org, kbusch@kernel.org, ssengar@linux.microsoft.com,
linux-block@vger.kernel.org, linux-mm@kvack.org,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] iov_iter: Allow DMA-compatible device pages in bvec extraction
Date: Thu, 3 Dec 2026 11:03:55 +0100 [thread overview]
Message-ID: <20261203100355.GA6235@lst.de> (raw)
In-Reply-To: <9755d72b-d081-44a0-9de6-0f9deda1e339@kernel.org>
On Thu, Dec 03, 2026 at 11:02:29AM +0100, David Hildenbrand (Arm) wrote:
> On 12/3/26 09:43, Naman Jain wrote:
> > Commit 38446014648c ("block: don't merge different kinds of P2P transfers
> > in a single bio") made bio_add_page() reject pages from different
> > dev_pagemaps. This was needed for PCI P2PDMA, but also rejected pages
> > with compatible DMA mapping requirements.
> >
> > Commit 41c665aae2b5 ("block: relax pgmap check in bio_add_page for
> > compatible zone device pages") allows these pages in separate bvecs.
> > Commit 13920e4b7b784 ("block: add pgmap check to biovec_phys_mergeable")
> > prevents physically contiguous bvecs from different pgmaps from being
> > merged into one segment.
> >
> > But iov_iter_extract_bvecs() still rejects pages from different pgmaps
> > without checking their DMA compatibility. Direct I/O uses this helper,
> > so a non-atomic request submitted as a single bio transfers only the
> > data before the pgmap boundary and returns fewer bytes than requested.
> >
> > Fix this by moving zone_device_pages_compatible() from blk.h to
> > memremap.h and using it in iov_iter_extract_bvecs(). Rename the helper to
> > zone_device_pages_dma_compatible() to make its purpose clear.
> >
> > Fixes: 38446014648c ("block: don't merge different kinds of P2P transfers in a single bio")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
> > ---
>
> [...]
>
> > static inline bool folio_is_device_coherent(const struct folio *folio)
> > {
> > return folio_is_zone_device(folio) &&
> > diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> > index 56c59a2b589d3..32b57f5747782 100644
> > --- a/lib/iov_iter.c
> > +++ b/lib/iov_iter.c
> > @@ -4,6 +4,7 @@
> > #include <linux/fault-inject-usercopy.h>
> > #include <linux/uio.h>
> > #include <linux/pagemap.h>
> > +#include <linux/memremap.h>
> > #include <linux/highmem.h>
> > #include <linux/slab.h>
> > #include <linux/vmalloc.h>
> > @@ -1968,7 +1969,7 @@ ssize_t iov_iter_extract_bvecs(struct iov_iter *iter, struct bio_vec *bv,
> > unsigned int nr_to_add;
> >
> > if (*nr_vecs > 0 &&
> > - !zone_device_pages_have_same_pgmap(bv[*nr_vecs - 1].bv_page,
> > + !zone_device_pages_dma_compatible(bv[*nr_vecs - 1].bv_page,
> > pages[i]))
>
> Nit: ^ I'd just fit that into a single line to de-uglify.
No, avoid ureadably long lines. This is excactly as it should be.
prev parent reply other threads:[~2026-12-03 10:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:43 [PATCH v2] iov_iter: Allow DMA-compatible device pages in bvec extraction Naman Jain
2026-12-03 9:53 ` Christoph Hellwig
2026-12-03 10:02 ` David Hildenbrand (Arm)
2026-12-03 10:03 ` Christoph Hellwig [this message]
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=20261203100355.GA6235@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=david@kernel.org \
--cc=kbusch@kernel.org \
--cc=leon@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=logang@deltatee.com \
--cc=namjain@linux.microsoft.com \
--cc=osalvador@suse.de \
--cc=ssengar@linux.microsoft.com \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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