-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/verbs: Add native API support for DMA-buf regions #9343
Conversation
prov/verbs/src/verbs_mr.c
Outdated
return vrb_reg_dmabuf(domain, attr->dmabuf->fd, | ||
attr->dmabuf->offset, attr->dmabuf->len, | ||
vrb_mr_ofi2ibv_access(attr->access, domain), | ||
mr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bypasses the reg cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was intentional because I don't know how we deal with a dma-buf in the cache or if we need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for now. In the long run, we may still want the registration be cached, probably by using a separate mr cache that use <fd, offset> instead of addr as the key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that I don't know how you verify that the entry is still valid or eject it from the cache.
@j-xiong - It looks like we might be able to adapt fi_mr_reg_xe and fi_rdmabw-xe to verify the new registration call. |
Yes, the existing component tests can be extended to have an option to use the new API. |
@@ -740,6 +775,11 @@ The follow flag may be specified to any memory registration call. | |||
API AllocHost call (as opposed to using malloc-like host allocation, | |||
unified/shared memory allocation, or AllocDevice). | |||
|
|||
*FI_MR_DMABUF* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also be a capability bit so that the application can check if this supported by the provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, and I had the same thought. Can the current FI_HMEM work, which would require providers support FI_HMEM to also support dmabuf registration? I'd like to avoid capability bit overload when possible. But I'm not sure if FI_HMEM is sufficient.
I was thinking that a provider could call mmap() to map the region into the VA space, then treat the dmabuf the same as a VA registered region. The provider may need to discover what hmem API was used to allocate the region. Is there an issue if the provider were forced down this path? IOW, dmabuf support becomes an optimization that the provider could leverage, otherwise it needs to fallback to whatever its standard HMEM support is.
DMA-buf support is handled internally by some providers. However, there's no mechanism for an application to pass dma-buf mapped buffers directly to them. Add this to the MR API using the HMEM infrastructure. Signed-off-by: Sean Hefty <[email protected]>
Updated: I changed the value of FI_MR_DMABUF, so that it could be defined as a capability bit in the future, if needed. However, I left it defined only as a memory registration flag. I added a requirement that the flag requires FI_HMEM support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough for starting to write tests.
@j-xiong - I added an update to fi-mr-reg-xe. It's not tested (I couldn't even build that on my system, so I need to move my patches.) The Intel CI passed, but I'm not sure that test is built or run. Only verbs supports the new API directly, but it looks like rxm should pass the call through okay. |
The test passed:
|
printf("mr %p, buf %p, rkey 0x%lx, len %zd\n", | ||
mr, buf, fi_mr_key(mr), buf_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should print out dmabuf_mr
instead of mr
, same for the mr key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - updated. And thanks for testing. :)
The rkey doen't look right:
|
I see the issue. The libfabric fid_mr wasn't initialized after the register call returned. |
I need to either go through vrb_mr_reg_common() or duplicate the functionality after ibv_reg_mr(). |
Support callers using dma-buf registatration directly. Signed-off-by: Sean Hefty <[email protected]>
Add direct testing of dmabuf memory registration. Signed-off-by: Sean Hefty <[email protected]>
Restructured the verbs changes to go through vrb_mr_reg_common(), so that the memory region is properly initialized. |
Works fine now:
|
bot:aws:retest |
This expands the memory registration API to support passing in a DMA-buf region. DMA buf regions are specified using a struct fi_mr_dmabuf. The struct fi_mr_attr is updated to accept passing in the dmabuf structure as input, with a flag used to indicate that the registration is for a DMA-buf region.
The verbs provider is updated to support DMA-buf registration.
Changes are compile tested only. There's no test yet available to verify functionality.