Skip to content

Revert "fix(rocr): Dup dmabuf fd on VMemoryImportShareableHandle for deferred import"#8436

Merged
rahulc-gh merged 1 commit into
developfrom
revert-8304-users/jaypatel/vmem-import-dmabuf-fd-lifetime
Jul 11, 2026
Merged

Revert "fix(rocr): Dup dmabuf fd on VMemoryImportShareableHandle for deferred import"#8436
rahulc-gh merged 1 commit into
developfrom
revert-8304-users/jaypatel/vmem-import-dmabuf-fd-lifetime

Conversation

@rahulc-gh

Copy link
Copy Markdown
Collaborator

Reverts #8304 blocking TheRock R-S bump PR ROCm/TheRock#6483

@therock-pr-bot

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
🌿 Branch Name ✅ Pass
📝 PR Title/Description ❌ Fail Error: Title is too long (85 characters).
Expected: at most 80 characters.
Desired format: type(optional-scope): short description
───
Error: Title does not follow Conventional Commits style.
Expected: start with a valid type (feat, fix, docs, …).
Desired format: type(optional-scope): short description
───
Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
JIRA ID : TESTAUTO-6039
JIRA ID - #330
JIRA ID #330
ISSUE ID : TESTUTO-3334
ISSUE ID #3334
ISSUE ID - TESTAUTO-3433
ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
Closes #10
Fixes octo-org/octo-repo#100
Resolves: #123
#123
https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
Forbidden Files ✅ Pass
🧪 Unit Test ❌ Fail Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.cc, projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.h, projects/rocr-runtime/rocrtst/suites/test_common/main.cc, projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp, projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp (+2 more); no test file found
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

⚠️ 2 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Title/Description
  • ❌ Unit Test

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

@therock-pr-bot

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Title/Description
  • ❌ Unit Test

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts a prior ROCr change that duplicated DMA-BUF file descriptors during hsa_amd_vmem_import_shareable_handle, and removes the associated test coverage that validated correct FD lifetime behavior for deferred import.

Changes:

  • Removes os::DmaBufDup API and its Linux/Windows implementations.
  • Reverts Runtime::VMemoryImportShareableHandle to store the caller-provided dmabuf_fd directly (no duplication).
  • Removes the rocrtst subtest that closed the importer FD immediately after import and then called set_access.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/rocr-runtime/runtime/hsa-runtime/core/util/win/os_win.cpp Removes DmaBufDup Windows stub.
projects/rocr-runtime/runtime/hsa-runtime/core/util/os.h Removes DmaBufDup declaration.
projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp Removes DmaBufDup implementation (was dup(2) wrapper).
projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp Reverts import path to keep caller FD (no owned duplicate).
projects/rocr-runtime/rocrtst/suites/test_common/main.cc Stops invoking the FD-lifetime regression test.
projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.h Removes declarations for the FD-lifetime regression test helper(s).
projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.cc Removes implementation of the FD-lifetime regression test and drops <unistd.h>.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 4461 to 4465
hsa_status_t Runtime::VMemoryImportShareableHandle(int dmabuf_fd,
hsa_amd_vmem_alloc_handle_t* memoryOnlyHandle) {
/* The per-GPU import of this dmabuf is deferred until hsa_amd_vmem_set_access is called, but the
* caller is free to close their fd as soon as this function returns. Duplicate the fd so the
* MemoryHandle owns a copy that stays valid until the deferred import. The MemoryHandle destructor
* closes this owned fd. */
int owned_fd = os::DmaBufDup(dmabuf_fd);
if (owned_fd < 0) return HSA_STATUS_ERROR_OUT_OF_RESOURCES;

std::lock_guard<std::shared_mutex> lock(memory_lock_);
auto memoryHandle = std::make_unique<MemoryHandle>(owned_fd);
auto memoryHandle = std::make_unique<MemoryHandle>(dmabuf_fd);
*memoryOnlyHandle = MemoryHandle::Convert(memoryHandle.get());
Comment on lines 551 to 554
vmt.CPUAccessToGPUMemoryTest();
vmt.GPUAccessToCPUMemoryTest();
vmt.GPUAccessToGPUMemoryTest();
vmt.ImportedShareableHandleSetAccessAfterFdClose();
RunCustomTestEpilog(&vmt);

@amd-justchen amd-justchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rahulc-gh rahulc-gh merged commit c0430a5 into develop Jul 11, 2026
13 of 14 checks passed
@rahulc-gh rahulc-gh deleted the revert-8304-users/jaypatel/vmem-import-dmabuf-fd-lifetime branch July 11, 2026 00:59
dayatsin-amd added a commit that referenced this pull request Jul 11, 2026
… import (#8440)

## Summary

Re-land the dmabuf fd duplication fix from #8304, which was reverted in
#8436 to unblock TheRock R-S bump.

After #6471 deferred per-GPU dmabuf import to `hsa_amd_vmem_set_access`
time, `VMemoryImportShareableHandle` must own a dup of the caller's fd
so deferred import still works after the caller closes its fd (normal
IPC ownership). This restores correct behavior for multi-rank VMM/IPC
peer-access flows (e.g. RCCL CE collectives).

Also removes `LogPrint` from `DmaBufDup` on Linux to avoid rocdxg WSL
link issues (same pattern as #8436 follow-up).

Adds a rocrtst regression test that imports a shareable handle, closes
the caller fd before `set_access`, and verifies GPU access succeeds.

## JIRA ID

JIRA ID : ROCM-27777

## Test plan

- [x] Run `ImportedShareableHandleSetAccessAfterFdClose` rocrtst subtest
on Linux with VMM support
- [x] Verify HIP/RCCL multi-rank VMM peer-access reproducer from
ROCM-27777 (hip-allgather-batch-cumem1.cpp)
- [x] Confirm WSL/rocdxg build succeeds without LogPrint link errors in
`DmaBufDup`


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants