Re: [PATCH v2 1/3] dma-buf: align large mappings to PMD boundaries

From: T.J. Mercier

Date: Tue Nov 24 2026 - 16:17:11 EST


On Mon, Nov 23, 2026 at 6:45 PM Qiliang Yuan <qiliang.yuan@xxxxxxxxx> wrote:
>
> A dma-buf exporter whose buffer is backed by physically contiguous memory
> can map it with PMDs from a ->huge_fault() handler, which only works where
> the user address and the buffer offset are aligned alike to PMD_SIZE.
>
> dma_buf_fops has no ->get_unmapped_area(), so mmap() places a dma-buf at
> whatever page aligned address the default allocator returns. A 4 GiB
> udmabuf, for one, lands 616 KiB past a 2 MiB boundary, and then none of
> its PMD-sized ranges can be mapped with a PMD.
>
> Use thp_get_unmapped_area(), as filesystems that support huge mappings
> do. It aligns a mapping that covers at least one whole PMD to the buffer
> offset and leaves smaller mappings where they would be placed anyway.
>
> Signed-off-by: Qiliang Yuan <qiliang.yuan@xxxxxxxxx>
> Reviewed-by: Christian König <christian.koenig@xxxxxxx>

Reviewed-by: T.J. Mercier <tjmercier@xxxxxxxxxx>