Skip to content

fix(rocr): wddm/queue: fix AQL->PM4 consumer race on not-yet-published VENDOR_SPECIFIC packets - #9274

Merged
fcui-amd merged 4 commits into
developfrom
users/fcui/wsl-aql-pm4-acquire-fix
Aug 9, 2026
Merged

fix(rocr): wddm/queue: fix AQL->PM4 consumer race on not-yet-published VENDOR_SPECIFIC packets#9274
fcui-amd merged 4 commits into
developfrom
users/fcui/wsl-aql-pm4-acquire-fix

Conversation

@fcui-amd

Copy link
Copy Markdown
Contributor

Motivation

port librocdxg pr
ROCm/librocdxg#68
ROCm/librocdxg#72
to rocr repo

Technical Details

details are described in ROCm/librocdxg#68

Issue Tracking

Test Plan

HIP graph replay as mentioned in ROCm/librocdxg#68

Test Result

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail 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
JIRA ID (on separate line)
ROCM-25757
ISSUE ID : TESTUTO-3334
ISSUE ID #3334
ISSUE ID - TESTAUTO-3433
ISSUE ID (on separate line)
AIRUNTIME-2352
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 ⚠️ Warning 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/libhsakmt/include/impl/wddm/queue.h, projects/rocr-runtime/libhsakmt/src/dxg/wddm/queue.cpp; no test file found
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

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

🚫 Please fix the failed policies

  • ❌ PR Description

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.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

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

zeekay and others added 2 commits August 6, 2026 10:14
…FIC packets at write-index burst boundaries

AqlToPm4Thread can admit a ring slot before its body is published when a producer bumps
write_dispatch_id by a whole burst at once (e.g. HIP graph replay). IsInvalidPacket reads the
header non-atomically and gates only HSA_PACKET_TYPE_INVALID, so a recycled slot mid-publication
reads type VENDOR_SPECIFIC (0) with a stale ven_hdr and is processed as a malformed PM4-IB ->
assert(ven_hdr == AMD_AQL_FORMAT_PM4_IB) at queue.cpp:841 (or silent GPU corruption on NDEBUG).

Fix: read the slot header in SwitchAql2PM4 via wsl::atomic::Load(memory_order_acquire), and
defer-and-retry a VENDOR_SPECIFIC slot whose ven_hdr != AMD_AQL_FORMAT_PM4_IB (return
HSA_STATUS_SUCCESS), mirroring the INVALID handling. Hoist AMD_AQL_FORMAT_PM4_IB to a file const.

Validated gfx1151 / ROCm 7.13 / WSL2: A/B assert builds abort before, zero aborts after.
consume

Follow-up nits from PR #68:

1. IsInvalidPacket() now reads the slot header via
   wsl::atomic::Load(..., memory_order_acquire), matching
SwitchAql2PM4() so the readiness gate uses the same acquire pairing with
the producer's release publication instead of a plain (racy) read.

2. Clear ven_hdr (= 0) when a VENDOR_SPECIFIC slot is consumed, so a
   recycled slot cannot transiently read a stale AMD_AQL_FORMAT_PM4_IB
before the next producer republishes its body.

Signed-off-by: Flora Cui <flora.cui@amd.com>
@fcui-amd
fcui-amd force-pushed the users/fcui/wsl-aql-pm4-acquire-fix branch from dc4ff32 to 34742e0 Compare August 6, 2026 02:14
@fcui-amd
fcui-amd merged commit c7d7439 into develop Aug 9, 2026
201 of 225 checks passed
@fcui-amd
fcui-amd deleted the users/fcui/wsl-aql-pm4-acquire-fix branch August 9, 2026 04:27
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