From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.95.11.211 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796292240; b=mYb2TaoekdCJ3NsJR71o7MfU3M8cMb/TNCGcKG7ucHYbwG+onD7YpsWCaNg6g2X2Y8hJ n7VS3FdxipWK9MBWZglla92a771jsFqsBG9+0BP2WAtl/0xW5gnRodSi2C7dlAqovZZ1d u8QY0hEMus9F3p8fJPUr2GvXDeUcrh+bODRh3p64MxjJr6//kymwBXYu5iq37jkX9ZVFp 6w8UAYpEvIOj7e3pgVoLjSEu1EiRcb++9TIWD/UzLjnnwAUcwcYcEVT5l0W2AGmmagl/e tz0YCrzB4nsGzwNiDb9UnF6jO/KdPxA/+ufTMuOPrccKv2Gy2h6linXXhnAanGwpK+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292240; h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; bh=Vt5TLHvcY4ZMsnHajRoN7zn1ydNwJYfWPtxO/A7QUJA=; b=j1YQaZMcofPKKtuDckSZUB8bvnZXlzbmtemSJFfRavO5k1EMrYoow/J6nYN+fOW1DY8/ vzq8Gz6Xneni7Lv8A+66uefi9+aUOH4x+1g4e1tm157NXLdyS5XFjGw5bublddLqA8Dqb Cau9WVntOoYZ7JgEHx/oRDj1s3/ong1L3k+zak8PZIq/56T2DGlZErUZH94tIrFePUJfC 2n1nUlZH5L0ibluNreB5S4iBiMBMz51KaqsTrg3149edW/c4kvB6Hy6UCtEvBLUp3WYvw ZcrV8Xh8idicLqb60SQS/gGA2P7o7H74u5/eO5BmYM6zAP6VLUf3/T0mXkJkeApVzXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.remote-ip=213.95.11.211 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33D39606A32C; Thu, 3 Dec 2026 10:04:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33D39606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 7E72168BFE; Thu, 3 Dec 2026 11:03:55 +0100 (CET) Date: Thu, 3 Dec 2026 11:03:55 +0100 From: Christoph Hellwig To: "David Hildenbrand (Arm)" Cc: Naman Jain , 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 Message-ID: <20261203100355.GA6235@lst.de> References: <20261203084315.3776182-1-namjain@linux.microsoft.com> <9755d72b-d081-44a0-9de6-0f9deda1e339@kernel.org> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9755d72b-d081-44a0-9de6-0f9deda1e339@kernel.org> User-Agent: Mutt/1.5.17 (2007-11-01) 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 > > --- > > [...] > > > 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 > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -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.