Commit 3f5698c
authored
Fix data race in VMM APIs (#3889)
## Motivation
Data race fixed by adding missing memory_lock_ acquisition
## Technical Details
Four virtual memory management functions in runtime.cpp were accessing
shared data structures (memory_handle_map_, mapped_handle_map_) without
holding the memory_lock_, causing data races under concurrent access.
Add std::lock_guard<std::shared_mutex> to:
- VMemoryExportShareableHandle: reads memory_handle_map_
- VMemoryImportShareableHandle: reads/writes memory_handle_map_
- VMemoryRetainAllocHandle: reads mapped_handle_map_, modifies ref_count
- VMemoryGetAllocPropertiesFromHandle: reads memory_handle_map_ This is
consistent with all other VMM functions in the file which already
acquire memory_lock_ before accessing these shared maps.
## JIRA ID
Resolves ROCM-3902
## Test Plan
Tested with rccl-tests workloads
## Test Result
No data race seen.
## Submission Checklist
- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.1 parent 7ee0ce2 commit 3f5698c
File tree
1 file changed
+4
-0
lines changed- projects/rocr-runtime/runtime/hsa-runtime/core/runtime
1 file changed
+4
-0
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4038 | 4038 | | |
4039 | 4039 | | |
4040 | 4040 | | |
| 4041 | + | |
4041 | 4042 | | |
4042 | 4043 | | |
4043 | 4044 | | |
| |||
4056 | 4057 | | |
4057 | 4058 | | |
4058 | 4059 | | |
| 4060 | + | |
4059 | 4061 | | |
4060 | 4062 | | |
4061 | 4063 | | |
| |||
4122 | 4124 | | |
4123 | 4125 | | |
4124 | 4126 | | |
| 4127 | + | |
4125 | 4128 | | |
4126 | 4129 | | |
4127 | 4130 | | |
| |||
4135 | 4138 | | |
4136 | 4139 | | |
4137 | 4140 | | |
| 4141 | + | |
4138 | 4142 | | |
4139 | 4143 | | |
4140 | 4144 | | |
| |||
0 commit comments