[PATCH v2 2/2] udmabuf: Add back support for mapping hugetlb pages (v2)

David Hildenbrand david at redhat.com
Tue Jul 18 18:05:02 UTC 2023


On 18.07.23 10:26, Vivek Kasireddy wrote:
> A user or admin can configure a VMM (Qemu) Guest's memory to be
> backed by hugetlb pages for various reasons. However, a Guest OS
> would still allocate (and pin) buffers that are backed by regular
> 4k sized pages. In order to map these buffers and create dma-bufs
> for them on the Host, we first need to find the hugetlb pages where
> the buffer allocations are located and then determine the offsets
> of individual chunks (within those pages) and use this information
> to eventually populate a scatterlist.
> 
> Testcase: default_hugepagesz=2M hugepagesz=2M hugepages=2500 options
> were passed to the Host kernel and Qemu was launched with these
> relevant options: qemu-system-x86_64 -m 4096m....
> -device virtio-gpu-pci,max_outputs=1,blob=true,xres=1920,yres=1080
> -display gtk,gl=on
> -object memory-backend-memfd,hugetlb=on,id=mem1,size=4096M
> -machine memory-backend=mem1
> 
> Replacing -display gtk,gl=on with -display gtk,gl=off above would
> exercise the mmap handler.
> 
> v2: Updated get_sg_table() to manually populate the scatterlist for
>      both huge page and non-huge-page cases.
> 
> Cc: David Hildenbrand <david at redhat.com>
> Cc: Mike Kravetz <mike.kravetz at oracle.com>
> Cc: Hugh Dickins <hughd at google.com>
> Cc: Peter Xu <peterx at redhat.com>
> Cc: Jason Gunthorpe <jgg at nvidia.com>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: Dongwon Kim <dongwon.kim at intel.com>
> Cc: Junxiao Chang <junxiao.chang at intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
> ---
>   drivers/dma-buf/udmabuf.c | 84 +++++++++++++++++++++++++++++++++------
>   1 file changed, 71 insertions(+), 13 deletions(-)

LGTM, in general. But I really hope Mike can comment.

-- 
Cheers,

David / dhildenb



More information about the dri-devel mailing list