Re: [PATCH 2/2] block: allow different-pgmap pages as separate bvecs in bio_add_page

From: Naman Jain

Date: Tue Apr 07 2026 - 03:10:33 EST




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