From: Hou Tao 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, 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 --- 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