[rocprofiler-sdk] Prevent queue-interposition doorbell over-advance - #7796
Merged
minseobshin11 merged 1 commit intoJun 26, 2026
Merged
Conversation
minseobshin11
force-pushed
the
users/mishin/aiprofsdk-910-queue-interposition-hang
branch
3 times, most recently
from
June 25, 2026 14:31
ee8f8e3 to
89cbd98
Compare
Contributor
bwelton
approved these changes
Jun 25, 2026
minseobshin11
marked this pull request as ready for review
June 25, 2026 18:08
minseobshin11
force-pushed
the
users/mishin/aiprofsdk-910-queue-interposition-hang
branch
from
June 25, 2026 21:46
89cbd98 to
fae7fd5
Compare
ApoKalipse-V
approved these changes
Jun 26, 2026
minseobshin11
deleted the
users/mishin/aiprofsdk-910-queue-interposition-hang
branch
June 26, 2026 16:39
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Motivation
The inline queue-interposition path intermittently hangs HIP applications under
kernel_dispatchtracing. Two reported symptoms — a multi-threaded producer deadlock (threads stuck in the doorbell path) and an async signal handler waiting forever on a completion signal pinned atvalue=1— are both caused by a single bug in the doorbell handling. This PR fixes that root cause.Technical Details
process_doorbell_implvirtualizes the queue write pointer: producers advance a shadow index (virtual_wptr) and the real hardware doorbell is only meant to be advanced by the SDK after it has actually submitted packets (real_wdid == next_submit_pos). Two early-exit paths violated this:scan_pos >= wptr_end(nothing new to scan) anddrained == 0(next slot claimed by a producer but not yet written).Both rang the hardware doorbell with the application's virtualized
value(virtual_wptr - 1), which can point past what the SDK has published. This advertises unpublished (and possibly unwritten) ring slots to the GPU, so the hardware read index (real_rdid) overshoots the shadow submit index. The overshoot then (1) wedgeswait_for_free_slotin an unsigned-underflow spin (submit_pos - real_rdidunderflows to ~UINT64_MAX) while holdinggate_lock, so every other producer blocks on that lock — the producer deadlock; and (2) leaves a dispatch's completion signal at its+1bump (never retired in order), so the async handler waits forever — thevalue=1stall.Fix:
ring_published_doorbell(), which rings the doorbell with the last index the SDK has actually submitted (next_submit_pos - 1), and use it in both early-exit paths instead of forwarding the virtualvalue. Liveness is preserved because a not-yet-written slot is published by its own producer's later doorbell, andprocess_doorbell_implalways scans up to the currentvirtual_wptr.wait_for_free_slotsubtraction so it can never underflow-spin (return whenreal_rdid >= submit_pos) — defense-in-depth.Single file changed:
source/lib/rocprofiler-sdk/hsa/queue_interposition.cpp.JIRA ID
Resolves AIPROFSDK-910
Test Plan
developbuild using high queue contention:HSA_XNACK=1 HIP_VISIBLE_DEVICES=0 rocprofv3 --kernel-trace -- transpose 16 800 800 1024 1024.gate_lockholder spinning inwait_for_free_slot;*real_rdid > *real_wdid == next_submit_pos) and via temporary in-tree instrumentation that captured the over-advancing doorbell ring (value+1 > real_wdid) immediately preceding the overshoot.kernel_dispatchrecord count matches the expected number of dispatches (no dropped/duplicated kernels).Test Result
still waiting on signalwarnings — and dispatch counts matched expected on every run.unified-memory-output-sys-run,kfd-events-sys-run) to be confirmed via the TheRock test workflow.Submission Checklist