[PATCH 07/13] PCI/P2PDMA: create compound page for aligned p2pdma memory
Alistair Popple
apopple at nvidia.com
Wed Jan 7 21:14:07 PST 2026
On 2025-12-20 at 15:04 +1100, Hou Tao <houtao at huaweicloud.com> wrote...
> From: Hou Tao <houtao1 at huawei.com>
>
> Commit c4386bd8ee3a ("mm/memremap: add ZONE_DEVICE support for compound
> pages") has already supported compound page for ZONE_DEVICE memory. It
> not only decreases the memory overhead of ZONE_DEVICE memory through
> the deduplication of vmemmap pages
Is this true? I wouldn't expect supporting P2PDMA compound pages would change
the vmemmap overhead - I think we'd still need a struct page in the vmemmap
for each 4K of memory unless you were going to prevent anything smaller than a
PMD/PUD sized BAR region from getting mapped.
> , it also optimize the performance of
> get_user_pages when the memory is used for IO.
>
> As for now, the alignment of p2p dma memory is already known, setting
> vmemmap_shift accordingly to create compound page for p2pdma memory.
>
> Signed-off-by: Hou Tao <houtao1 at huawei.com>
> ---
> drivers/pci/p2pdma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index 70482e240304..7180dea4855c 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -447,6 +447,8 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
> pgmap->nr_range = 1;
> pgmap->type = MEMORY_DEVICE_PCI_P2PDMA;
> pgmap->ops = &p2pdma_pgmap_ops;
> + if (align > PAGE_SIZE)
> + pgmap->vmemmap_shift = ilog2(align) - PAGE_SHIFT;
> p2p_pgmap->mem = mem;
>
> addr = devm_memremap_pages(&pdev->dev, pgmap);
> --
> 2.29.2
>
More information about the Linux-nvme
mailing list