Skip to content

block: fix pgmap handling for zone device pages in bio merge paths#712

Open
blktests-ci[bot] wants to merge 2 commits intolinus-master_basefrom
series/1075658=>linus-master
Open

block: fix pgmap handling for zone device pages in bio merge paths#712
blktests-ci[bot] wants to merge 2 commits intolinus-master_basefrom
series/1075658=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci bot commented Apr 1, 2026

Pull request for series with
subject: block: fix pgmap handling for zone device pages in bio merge paths
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1075658

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 1, 2026

Upstream branch: 9147566
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 1, 2026

Upstream branch: 9147566
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 91b056d to 3c59258 Compare April 1, 2026 14:19
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch 2 times, most recently from ecbdbb4 to 480b162 Compare April 2, 2026 07:52
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 2, 2026

Upstream branch: 9147566
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 3c59258 to 17ca370 Compare April 2, 2026 07:57
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch 2 times, most recently from a96fba7 to 0cd6ac2 Compare April 3, 2026 07:51
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 3, 2026

Upstream branch: 9147566
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 17ca370 to 1c8bb61 Compare April 3, 2026 07:58
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 0cd6ac2 to 910d344 Compare April 3, 2026 11:53
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 3, 2026

Upstream branch: d8a9a4b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 1c8bb61 to 043be15 Compare April 3, 2026 12:00
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 910d344 to ed862bc Compare April 4, 2026 05:34
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 4, 2026

Upstream branch: 7ca6d1c
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 043be15 to 1de2fc3 Compare April 4, 2026 05:41
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from ed862bc to 2d0c3d5 Compare April 4, 2026 16:55
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 4, 2026

Upstream branch: 3aae938
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 1de2fc3 to 0f98c7c Compare April 4, 2026 17:02
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 2d0c3d5 to 931d9b0 Compare April 8, 2026 10:29
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 8, 2026

Upstream branch: 3036cd0
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 0f98c7c to f913d24 Compare April 8, 2026 10:37
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 931d9b0 to 78a4682 Compare April 10, 2026 00:51
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 10, 2026

Upstream branch: 9a9c8ce
series: https://patchwork.kernel.org/project/linux-block/list/?series=1075658
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from f913d24 to 216bd2b Compare April 10, 2026 00:57
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci bot commented Apr 10, 2026

Upstream branch: 9a9c8ce
series: https://patchwork.kernel.org/project/linux-block/list/?series=1079831
version: 2

Naman Jain added 2 commits April 11, 2026 00:38
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: 49580e6 ("block: add check when merging zone device pages")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
…ages

bio_add_page() and bio_integrity_add_page() reject pages from different
dev_pagemaps entirely, returning 0 even when those pages have compatible
DMA mapping requirements. This forces callers to start a new bio when
buffers span pgmap boundaries, even though the pages could safely coexist
as separate bvec entries.

This matters for guests where memory is registered through
devm_memremap_pages() with MEMORY_DEVICE_GENERIC in multiple calls,
creating separate dev_pagemaps for each chunk. When a direct I/O buffer
spans two such chunks, bio_add_page() rejects the second page, forcing an
unnecessary bio split or I/O failure.

Introduce zone_device_pages_compatible() in blk.h to check whether two
pages can coexist in the same bio as separate bvec entries. The block DMA
iterator (blk_dma_map_iter_start) caches the P2PDMA mapping state from the
first segment and applies it to all others, so P2PDMA pages from different
pgmaps must not be mixed, and neither must P2PDMA and non-P2PDMA pages.
All other combinations (MEMORY_DEVICE_GENERIC pages from different pgmaps,
or MEMORY_DEVICE_GENERIC with normal RAM) use the same dma_map_phys path
and are safe.

Replace the blanket zone_device_pages_have_same_pgmap() rejection with
zone_device_pages_compatible(), while keeping
zone_device_pages_have_same_pgmap() as a merge guard.
Pages from different pgmaps can be added as separate bvec entries but
must not be coalesced into the same segment, as that would make
it impossible to recover the correct pgmap via page_pgmap().

Fixes: 49580e6 ("block: add check when merging zone device pages")
Cc: stable@vger.kernel.org
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
@blktests-ci blktests-ci bot added V2 and removed V1 labels Apr 10, 2026
@blktests-ci blktests-ci bot force-pushed the series/1075658=>linus-master branch from 216bd2b to f341413 Compare April 10, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant