On Thu, Mar 6, 2025 at 2:52 AM Huang, Honglei1 <honglei1.hu...@amd.com> wrote:
> > On 2025/3/1 5:21, Demi Marie Obenour wrote: > > On 2/28/25 12:36 AM, Honglei Huang wrote: > >> From: Honglei Huang <honglei1.hu...@amd.com> > >> > >> Add a new resource for blob resource, called userptr, used for let > >> host access guest user space memory, to acquire buffer based userptr > >> feature in virtio GPU. > >> > >> - The capset VIRTIO_GPU_CAPSET_HSAKMT used for context init, > >> in this series patches only HSAKMT context can use the userptr > >> feature. HSAKMT is a GPU compute library in HSA stack, like > >> the role libdrm in mesa stack. > > > > Userptr should not be limited to HSMKMT contexts. Userptr can > > accelerate shm buffers by avoiding a copy from guest to host, and > > it can be implemented using grant tables on Xen. > > Yes, I totally agree userptr can accelerate shm buffers, but I currently > don't know if there are any other projects working on similar features, > or if maintainers have any opinions or better ways to implement them, so > I temporarily limit this feature to HSAKMT context only. > > I am waiting for everyone's opinions, please provide your thoughts. > I wonder if you can emulate userptr using udmabuf on the host-side? Essentially for the guest, it'll be a malloc'ed memory, which means a guest sg list. We can convert the guest sg-list to udmabuf using well-known mechanisms on the host side. I hope amdkfd can operate on dma-bufs too? I do such a feature that would have a more generic utility outside of HSAKMT contexts and not rely on Xen-specific grant tables ... checkout VIRTIO_GPU_BLOB_FLAG_CREATE_GUEST_HANDLE in crosvm for an example. > > Regards, > Honglei >