Skip to content
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

hmem: Define ofi_hmem_put_dmabuf_fd #10716

Merged
merged 7 commits into from
Jan 23, 2025
Merged

hmem: Define ofi_hmem_put_dmabuf_fd #10716

merged 7 commits into from
Jan 23, 2025

Conversation

iziemba
Copy link
Contributor

@iziemba iziemba commented Jan 22, 2025

For some HMEM ifaces, ofi_hmem_get_dmabuf_fd() may result in a new FD being allocated. Define ofi_hmem_put_dmabuf_fd() to close FD.

Support ofi_hmem_get_dmabuf_fd() with ROCR.

Update CXI provider accordingly.

For some HMEM ifaces, ofi_hmem_get_dmabuf_fd() may result in a new FD
being allocated. Define ofi_hmem_put_dmabuf_fd() to close FD.

Signed-off-by: Ian Ziemba <[email protected]>
With ROCR, callers of ofi_hmem_get_dmabuf_fd() should call
ofi_hmem_put_dmabuf_fd() once the DMA buf region is no longer used.

Signed-off-by: Ian Ziemba <[email protected]>
@iziemba iziemba requested review from swelch and j-xiong January 22, 2025 04:32
@shijin-aws
Copy link
Contributor

shijin-aws commented Jan 22, 2025

would u mind implementing this for cuda as well? it should be simply a close(fd) and we may want to use it in #10708

@@ -131,6 +131,7 @@ struct ofi_hmem_ops {
const void *src, size_t size);
int (*get_dmabuf_fd)(const void *addr, uint64_t size, int *fd,
uint64_t *offset);
int (*put_dmabuf_fd)(int fd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just name it as close_dmabuf_fd ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose put_dmabuf_fd to semantically align with get_dmabuf_fd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any hmem type where a get_dmabuf_fd does not implicitly increase the open count on the file? if not, I'd recommend going the other way and renaming get to open so that it's clear that it's not simply resolving an already-open file descriptor, but is actually opening a resource which must be eventually closed.

Copy link
Contributor

@j-xiong j-xiong Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the ZE hmem type always return the same fd.

With CUDA, callers of ofi_hmem_get_dmabuf_fd() should call
ofi_hmem_put_dmabuf_fd() once the DMA buf region is no longer used.

Signed-off-by: Ian Ziemba <[email protected]>
Performing multiple HSA allocations appears to result in a DMA buf
offset. Verify that the CXI provider can register a DMA buf offset
memory region.

Signed-off-by: Ian Ziemba <[email protected]>
When a MR is freed, the CXI provider should free the DMA buf FD used for
the ROCR region. Failing to do this will result in FDs being exhausted.

Signed-off-by: Ian Ziemba <[email protected]>
When a MR is freed, the CXI provider should free the DMA buf FD used for
the CUDA region. Failing to do this will result in FDs being exhausted.

Signed-off-by: Ian Ziemba <[email protected]>
@iziemba
Copy link
Contributor Author

iziemba commented Jan 22, 2025

@shijin-aws : I added CUDA support. If you could review, that would be great.

@swelch : If you could review CXI prov changes, that would be great.

Thanks!

@iziemba iziemba requested a review from shijin-aws January 22, 2025 15:25
Copy link
Contributor

@shijin-aws shijin-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@shijin-aws
Copy link
Contributor

@j-xiong is intel ci failure related?

@j-xiong
Copy link
Contributor

j-xiong commented Jan 22, 2025

@shijin-aws We are having slurm issues right now. The tests didn't actually run.

@shijin-aws
Copy link
Contributor

@j-xiong is Intel CI still having issues?

@j-xiong
Copy link
Contributor

j-xiong commented Jan 23, 2025

There are two intermittent failures with oneCCL over tcp provider. They are unrelated to this PR.

@j-xiong j-xiong merged commit ba880cc into ofiwg:main Jan 23, 2025
12 of 13 checks passed
@@ -575,6 +589,9 @@ static void cxip_unmap_nocache(struct cxip_md *md)
{
int ret;

if (md->dmabuf_fd_valid)
ofi_hmem_put_dmabuf_fd(md->info.iface, md->dmabuf_fd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious to know why cxi requires that the close of the dmabuf is deferred until point of unmapping it? Why can't you just close it immediately after you do the map? I thought this was a property of the dmabuf kernel interface and not something that would be different between providers, but I don't know this code well and might be missing something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the kernel driver would reference count properly so that closing right after mapping should work just fine. I don't see the drawback of doing either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants