* [PATCH 0/2] block: fix pgmap handling for zone device pages in bio merge paths @ 2026-04-01 8:23 Naman Jain 2026-04-01 8:23 ` [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable Naman Jain 2026-04-01 8:23 ` [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page Naman Jain 0 siblings, 2 replies; 10+ messages in thread From: Naman Jain @ 2026-04-01 8:23 UTC (permalink / raw) To: Jens Axboe Cc: Christoph Hellwig, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley, namjain When zone device memory is registered in multiple chunks, each chunk gets its own dev_pagemap. A single bio can contain bvecs from different pgmaps -- iov_iter_extract_bvecs() breaks at pgmap boundaries but the outer loop in bio_iov_iter_get_pages() continues filling the same bio. There are two problems with the current code: 1. biovec_phys_mergeable() has no pgmap check, so the request merge, DMA mapping, and integrity merge paths can coalesce physically contiguous bvec segments from different pgmaps. This makes it impossible to recover the correct pgmap for the merged segment via page_pgmap(). 2. bio_add_page() and bio_integrity_add_page() reject pages from a different pgmap entirely (returning 0), rather than just skipping the merge and adding them as new bvec entries. This forces callers to start a new bio unnecessarily. Patch 1 fixes the merge-path gap by adding a pgmap check to biovec_phys_mergeable(). Patch 2 fixes the bio_add_page() and bio_integrity_add_page() API behavior, moving the pgmap check into the merge conditional so different-pgmap pages can be added as separate bvec entries. This depends on patch 1 being in place. Naman Jain (2): block: add pgmap check to biovec_phys_mergeable block: allow different-pgmap pages as separate bvecs in bio_add_page block/bio-integrity.c | 6 ++---- block/bio.c | 6 ++---- block/blk.h | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable 2026-04-01 8:23 [PATCH 0/2] block: fix pgmap handling for zone device pages in bio merge paths Naman Jain @ 2026-04-01 8:23 ` Naman Jain 2026-04-01 14:07 ` Christoph Hellwig 2026-04-01 8:23 ` [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page Naman Jain 1 sibling, 1 reply; 10+ messages in thread From: Naman Jain @ 2026-04-01 8:23 UTC (permalink / raw) To: Jens Axboe Cc: Christoph Hellwig, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley, namjain biovec_phys_mergeable() is used by the request merge, DMA mapping, and integrity merge paths to decide if two physically contiguous bvec segments can be coalesced into one. It currently has no check for whether the segments belong to different dev_pagemaps. When zone device memory is registered in multiple chunks, each chunk gets its own dev_pagemap. A single bio can legitimately contain bvecs from different pgmaps -- iov_iter_extract_bvecs() breaks at pgmap boundaries but the outer loop in bio_iov_iter_get_pages() continues filling the same bio. If such bvecs are physically contiguous, biovec_phys_mergeable() will coalesce them, making it impossible to recover the correct pgmap for the merged segment via page_pgmap(). Add a zone_device_pages_have_same_pgmap() check to prevent merging bvec segments that span different pgmaps. Fixes: 49580e690755 ("block: add check when merging zone device pages") Cc: stable@vger.kernel.org Signed-off-by: Naman Jain <namjain@linux.microsoft.com> --- block/blk.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk.h b/block/blk.h index 103cb1d0b9cb3..0cb3441638284 100644 --- a/block/blk.h +++ b/block/blk.h @@ -127,6 +127,8 @@ static inline bool biovec_phys_mergeable(struct request_queue *q, if (addr1 + vec1->bv_len != addr2) return false; + if (!zone_device_pages_have_same_pgmap(vec1->bv_page, vec2->bv_page)) + return false; if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page)) return false; if ((addr1 | mask) != ((addr2 + vec2->bv_len - 1) | mask)) -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable 2026-04-01 8:23 ` [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable Naman Jain @ 2026-04-01 14:07 ` Christoph Hellwig 0 siblings, 0 replies; 10+ messages in thread From: Christoph Hellwig @ 2026-04-01 14:07 UTC (permalink / raw) To: Naman Jain Cc: Jens Axboe, Christoph Hellwig, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-01 8:23 [PATCH 0/2] block: fix pgmap handling for zone device pages in bio merge paths Naman Jain 2026-04-01 8:23 ` [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable Naman Jain @ 2026-04-01 8:23 ` Naman Jain 2026-04-01 14:08 ` Christoph Hellwig 1 sibling, 1 reply; 10+ messages in thread From: Naman Jain @ 2026-04-01 8:23 UTC (permalink / raw) To: Jens Axboe Cc: Christoph Hellwig, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley, namjain bio_add_page() and bio_integrity_add_page() reject pages from a different dev_pagemap entirely, returning 0 even when the page could be added as a new bvec entry. The pgmap check was intended only to prevent merging into the same bvec segment, not to block the page from being added at all. This causes callers to unnecessarily start a new bio when a buffer spans pages from two different pgmaps, even though the bio has room for another bvec. Fix both functions by moving the zone_device_pages_have_same_pgmap() check into the merge conditional. Pages from different pgmaps now skip the merge attempt and fall through to be added as new separate bvec entries. This is safe because biovec_phys_mergeable() now also checks for pgmap mismatches, preventing the downstream merge, DMA mapping, and request coalescing paths from combining segments across pgmaps. Fixes: 49580e690755 ("block: add check when merging zone device pages") Cc: stable@vger.kernel.org Signed-off-by: Naman Jain <namjain@linux.microsoft.com> --- block/bio-integrity.c | 6 ++---- block/bio.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index e79eaf0477943..3462697331890 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -231,10 +231,8 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, if (bip->bip_vcnt > 0) { struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) - return 0; - - if (bvec_try_merge_hw_page(q, bv, page, len, offset)) { + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && + bvec_try_merge_hw_page(q, bv, page, len, offset)) { bip->bip_iter.bi_size += len; return len; } diff --git a/block/bio.c b/block/bio.c index 77067fa346d35..7715e59e68613 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1034,10 +1034,8 @@ int bio_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) - return 0; - - if (bvec_try_merge_page(bv, page, len, offset)) { + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && + bvec_try_merge_page(bv, page, len, offset)) { bio->bi_iter.bi_size += len; return len; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-01 8:23 ` [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page Naman Jain @ 2026-04-01 14:08 ` Christoph Hellwig 2026-04-02 5:21 ` Naman Jain 0 siblings, 1 reply; 10+ messages in thread From: Christoph Hellwig @ 2026-04-01 14:08 UTC (permalink / raw) To: Naman Jain Cc: Jens Axboe, Christoph Hellwig, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley On Wed, Apr 01, 2026 at 08:23:29AM +0000, Naman Jain wrote: > bio_add_page() and bio_integrity_add_page() reject pages from a > different dev_pagemap entirely, returning 0 even when the page could > be added as a new bvec entry. The pgmap check was intended only to > prevent merging into the same bvec segment, not to block the page > from being added at all. > > This causes callers to unnecessarily start a new bio when a buffer > spans pages from two different pgmaps, even though the bio has room > for another bvec. This is not unnecessary. A single dma mapping operation can only map a single target pgmap. The old SG API works around this by doing multiple mapping operation underneath, but compared to that just having multiple bios is much easier and more efficient. What is your use case here? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-01 14:08 ` Christoph Hellwig @ 2026-04-02 5:21 ` Naman Jain 2026-04-02 5:30 ` Christoph Hellwig 0 siblings, 1 reply; 10+ messages in thread From: Naman Jain @ 2026-04-02 5:21 UTC (permalink / raw) To: Christoph Hellwig Cc: Jens Axboe, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley On 4/1/2026 7:38 PM, Christoph Hellwig wrote: > On Wed, Apr 01, 2026 at 08:23:29AM +0000, Naman Jain wrote: >> bio_add_page() and bio_integrity_add_page() reject pages from a >> different dev_pagemap entirely, returning 0 even when the page could >> be added as a new bvec entry. The pgmap check was intended only to >> prevent merging into the same bvec segment, not to block the page >> from being added at all. >> >> This causes callers to unnecessarily start a new bio when a buffer >> spans pages from two different pgmaps, even though the bio has room >> for another bvec. > > This is not unnecessary. A single dma mapping operation can only > map a single target pgmap. The old SG API works around this by > doing multiple mapping operation underneath, but compared to that > just having multiple bios is much easier and more efficient. > > What is your use case here? Hello Christoph, Thanks for reviewing these patches. The use case driving this patch is the MSHV VTL driver (drivers/hv/mshv_vtl_main.c) for VMs with paravisor architecture (OpenHCL/OpenVMM: https://openvmm.dev/guide/index.html). In this setup, the guest runs at two Virtual Trust Levels: - VTL2 (higher privilege): runs a Linux kernel acting as "paravisor" that handles device I/O on behalf of the guest - VTL0 (lower privilege): runs the actual guest OS (Windows/Linux) VTL2 Linux performs block I/O (NVMe, SCSI, etc.) using VTL0's memory as DMA buffers. To enable this, VTL0 memory is registered into the VTL2 kernel via the MSHV_ADD_VTL0_MEMORY ioctl, which calls devm_memremap_pages() to create MEMORY_DEVICE_GENERIC zone device pages. The ioctl is called multiple times, by the Virtual Machine Manager (VMM), registering VTL0's physical address space in chunks. Each call creates a separate dev_pagemap. This chunking is necessary because: 1. Firmware/UEFI fragments the guest physical address space (MMIO holes, reserved regions) 2. Alignment constraints: vmemmap_shift is computed from the range alignment, and highly aligned large ranges can exceed MAX_FOLIO_ORDER, causing devm_memremap_pages() to fail When a direct I/O request spans pages from different chunks (different pgmaps), the current code rejected the second page entirely: if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) return 0; // Rejection - forces bio split or I/O error Both chunks are regular RAM from the DMA perspective (MEMORY_DEVICE_GENERIC, not P2PDMA). The only requirement is that they not be merged into the same bvec segment, which patch 1/2 enforces by adding the pgmap check to biovec_phys_mergeable(). This patch allows pages from different pgmaps to be added as separate bvec entries in the same bio, eliminating bio splits and I/O failures when buffers span pgmap boundaries. I noticed this while doing kernel upgrade from 6.12 to 6.18 for OpenHCL kernel. There's this another concern flagged from Sashiko code review: https://sashiko.dev/#/patchset/20260401082329.1602328-1-namjain%40linux.microsoft.com From my code analysis, this issue would not happening as of now, so this is future proofing the APIs after change 2/2. I would need to add a check like this to fix this: diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 3462697331890..6f2f30a814560 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -231,6 +231,9 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, if (bip->bip_vcnt > 0) { struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; + if (is_pci_p2pdma_page(bv->bv_page) != + is_pci_p2pdma_page(page)) + return 0; if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && bvec_try_merge_hw_page(q, bv, page, len, offset)) { bip->bip_iter.bi_size += len; diff --git a/block/bio.c b/block/bio.c index 7715e59e68613..6216a554de68b 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1034,6 +1034,9 @@ int bio_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; + if (is_pci_p2pdma_page(bv->bv_page) != + is_pci_p2pdma_page(page)) + return 0; if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && bvec_try_merge_page(bv, page, len, offset)) { bio->bi_iter.bi_size += len; Please let me know what you think about this. Thanks, Naman ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-02 5:21 ` Naman Jain @ 2026-04-02 5:30 ` Christoph Hellwig 2026-04-02 8:55 ` Naman Jain 0 siblings, 1 reply; 10+ messages in thread From: Christoph Hellwig @ 2026-04-02 5:30 UTC (permalink / raw) To: Naman Jain Cc: Christoph Hellwig, Jens Axboe, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley On Thu, Apr 02, 2026 at 10:51:05AM +0530, Naman Jain wrote: > When a direct I/O request spans pages from different chunks (different > pgmaps), the current code rejected the second page entirely: > > if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) > return 0; // Rejection - forces bio split or I/O error > > Both chunks are regular RAM from the DMA perspective > (MEMORY_DEVICE_GENERIC, not P2PDMA). The only requirement is that they not > be merged into the same bvec segment, which patch 1/2 enforces by adding > the pgmap check to biovec_phys_mergeable(). > > This patch allows pages from different pgmaps to be added as separate bvec > entries in the same bio, eliminating bio splits and I/O failures > when buffers span pgmap boundaries. Which as I said we can't do in general, as different pgmaps cna have different DMA mapping requirements. We might be able to relax this if we know multiple pgmaps can be mapped in the same way. I.e. replace zone_device_pages_have_same_pgmap with zone_device_pages_compatible and add additional conditions to it. > --- a/block/bio-integrity.c > +++ b/block/bio-integrity.c > @@ -231,6 +231,9 @@ int bio_integrity_add_page(struct bio *bio, struct page > *page, > if (bip->bip_vcnt > 0) { > struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; > > + if (is_pci_p2pdma_page(bv->bv_page) != > + is_pci_p2pdma_page(page)) > + return 0; > if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && The above is implied by not having the same pgmap. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-02 5:30 ` Christoph Hellwig @ 2026-04-02 8:55 ` Naman Jain 2026-04-07 5:52 ` Christoph Hellwig 0 siblings, 1 reply; 10+ messages in thread From: Naman Jain @ 2026-04-02 8:55 UTC (permalink / raw) To: Christoph Hellwig Cc: Jens Axboe, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley On 4/2/2026 11:00 AM, Christoph Hellwig wrote: > On Thu, Apr 02, 2026 at 10:51:05AM +0530, Naman Jain wrote: >> When a direct I/O request spans pages from different chunks (different >> pgmaps), the current code rejected the second page entirely: >> >> if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) >> return 0; // Rejection - forces bio split or I/O error >> >> Both chunks are regular RAM from the DMA perspective >> (MEMORY_DEVICE_GENERIC, not P2PDMA). The only requirement is that they not >> be merged into the same bvec segment, which patch 1/2 enforces by adding >> the pgmap check to biovec_phys_mergeable(). >> >> This patch allows pages from different pgmaps to be added as separate bvec >> entries in the same bio, eliminating bio splits and I/O failures >> when buffers span pgmap boundaries. > > Which as I said we can't do in general, as different pgmaps cna have > different DMA mapping requirements. We might be able to relax this > if we know multiple pgmaps can be mapped in the same way. I.e. > replace zone_device_pages_have_same_pgmap with > zone_device_pages_compatible and add additional conditions to it. > >> --- a/block/bio-integrity.c >> +++ b/block/bio-integrity.c >> @@ -231,6 +231,9 @@ int bio_integrity_add_page(struct bio *bio, struct page >> *page, >> if (bip->bip_vcnt > 0) { >> struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; >> >> + if (is_pci_p2pdma_page(bv->bv_page) != >> + is_pci_p2pdma_page(page)) >> + return 0; >> if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && > > The above is implied by not having the same pgmap. Thanks. If I understand correctly, here is how this would look like. Please let me know if this is what you suggested. diff --git a/block/bio-integrity.c b/block/bio-integrity.c index e79eaf0477943..e54c6e06e1cbb 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -231,10 +231,10 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, if (bip->bip_vcnt > 0) { struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) + if (!zone_device_pages_compatible(bv->bv_page, page)) return 0; - - if (bvec_try_merge_hw_page(q, bv, page, len, offset)) { + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && + bvec_try_merge_hw_page(q, bv, page, len, offset)) { bip->bip_iter.bi_size += len; return len; } diff --git a/block/bio.c b/block/bio.c index 77067fa346d35..0e70bb912338c 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1034,10 +1034,10 @@ int bio_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) + if (!zone_device_pages_compatible(bv->bv_page, page)) return 0; - - if (bvec_try_merge_page(bv, page, len, offset)) { + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && + bvec_try_merge_page(bv, page, len, offset)) { bio->bi_iter.bi_size += len; return len; } diff --git a/block/blk.h b/block/blk.h index 0cb3441638284..c5710ba4c81b9 100644 --- a/block/blk.h +++ b/block/blk.h @@ -136,6 +136,23 @@ static inline bool biovec_phys_mergeable(struct request_queue *q, return true; } +/* + * Check if two pages from potentially different zone device pgmaps can + * coexist as separate bvec entries in the same bio. + * + * The block DMA iterator (blk_dma_map_iter_start) caches the P2PDMA mapping + * state from the first segment and applies it to all subsequent segments, so + * P2PDMA and non-P2PDMA pages must never be mixed in the same bio. + * + * Other zone device types (FS_DAX, GENERIC) use the same dma_map_phys() path + * as normal RAM. PRIVATE and COHERENT pages never appear in bios. + */ +static inline bool zone_device_pages_compatible(const struct page *a, + const struct page *b) +{ + return is_pci_p2pdma_page(a) == is_pci_p2pdma_page(b); +} + static inline bool __bvec_gap_to_prev(const struct queue_limits *lim, struct bio_vec *bprv, unsigned int offset) { ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-02 8:55 ` Naman Jain @ 2026-04-07 5:52 ` Christoph Hellwig 2026-04-07 7:08 ` Naman Jain 0 siblings, 1 reply; 10+ messages in thread From: Christoph Hellwig @ 2026-04-07 5:52 UTC (permalink / raw) To: Naman Jain Cc: Christoph Hellwig, Jens Axboe, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley > - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) > + if (!zone_device_pages_compatible(bv->bv_page, page)) > return 0; > - > - if (bvec_try_merge_hw_page(q, bv, page, len, offset)) { > + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && > + bvec_try_merge_hw_page(q, bv, page, len, offset)) { We still can't merge merge pages with different P2P pgmaps into the same request. So the zone_device_pages_have_same_pgmap check should go into zone_device_pages_compatible and we need to stop building the bio as well in that case. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page 2026-04-07 5:52 ` Christoph Hellwig @ 2026-04-07 7:08 ` Naman Jain 0 siblings, 0 replies; 10+ messages in thread From: Naman Jain @ 2026-04-07 7:08 UTC (permalink / raw) To: Christoph Hellwig Cc: Jens Axboe, Chaitanya Kulkarni, John Hubbard, Logan Gunthorpe, linux-kernel, linux-block, Saurabh Sengar, Long Li, Michael Kelley On 4/7/2026 11:22 AM, Christoph Hellwig wrote: >> - if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) >> + if (!zone_device_pages_compatible(bv->bv_page, page)) >> return 0; >> - >> - if (bvec_try_merge_hw_page(q, bv, page, len, offset)) { >> + if (zone_device_pages_have_same_pgmap(bv->bv_page, page) && >> + bvec_try_merge_hw_page(q, bv, page, len, offset)) { > > We still can't merge merge pages with different P2P pgmaps into the > same request. > > So the zone_device_pages_have_same_pgmap check should go into > zone_device_pages_compatible and we need to stop building the bio > as well in that case. Ok, so rest all things same, from my last email, but my previous compatible function would look like this: static inline bool zone_device_pages_compatible(const struct page *a, const struct page *b) { if (is_pci_p2pdma_page(a) || is_pci_p2pdma_page(b)) return zone_device_pages_have_same_pgmap(a, b); return true; } This would prevent two P2PDMA pages from different pgmaps (different PCI devices) passing the compatible check and both get added to the bio. Please correct me if that is not what you meant. I'll wait for a couple more days and send the next version with this, and we can review this again. Thanks for your inputs. Regards, Naman ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-04-07 7:08 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-04-01 8:23 [PATCH 0/2] block: fix pgmap handling for zone device pages in bio merge paths Naman Jain 2026-04-01 8:23 ` [PATCH 1/2] block: add pgmap check to biovec_phys_mergeable Naman Jain 2026-04-01 14:07 ` Christoph Hellwig 2026-04-01 8:23 ` [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page Naman Jain 2026-04-01 14:08 ` Christoph Hellwig 2026-04-02 5:21 ` Naman Jain 2026-04-02 5:30 ` Christoph Hellwig 2026-04-02 8:55 ` Naman Jain 2026-04-07 5:52 ` Christoph Hellwig 2026-04-07 7:08 ` Naman Jain
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox