Skip to content

[1/5] rocjitsu: Fix KFD queue compatibility and AQL slot retirement - #12934

Merged
kuhar merged 4 commits into
developfrom
users/Groverkss/rocjitsu-runtime-cts-stack-1
Oct 8, 2026
Merged

kuhar merged 4 commits into
developfrom
users/Groverkss/rocjitsu-runtime-cts-stack-1

Conversation

@Groverkss

Copy link
Copy Markdown
Contributor
  • Accept older CREATE_QUEUE payload sizes by zero-extending requests and copying back only the caller-provided bytes.
  • Allow clients to unmap complete doorbell views while preserving the simulator's backing and private monitoring alias until process teardown.
  • Invalidate consumed AQL packet headers before publishing the read index, retaining admission state across transient memory failures.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:56
@Groverkss
Groverkss requested review from a team and atgutier as code owners October 6, 2026 17:56
@Groverkss
Groverkss added this pull request to stack #12938 October 6, 2026 17:56
@Groverkss Groverkss changed the title [1/4] rocjitsu: Add runtime-cts ci and apply rocjitsu fixes [1/4] rocjitsu: Add AQL runtime-cts ci and apply rocjitsu fixes Oct 6, 2026
@therock-pr-bot

therock-pr-bot Bot commented Oct 6, 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 ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 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 Oct 6, 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.

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.

Copilot review overview

🟡 Changes recommended

The advertised runtime-cts CI integration is absent from the changed files.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Improves rocjitsu’s KFD and AQL compatibility, with regression coverage for payload sizing, doorbell remapping, and packet retirement.

Changes:

  • Supports variable-sized CREATE_QUEUE payloads.
  • Preserves doorbell backing across client unmaps.
  • Invalidates AQL slots before cursor publication with retry-safe state.
File Description
simulated_kfd_test.cpp Tests persistent doorbell backing.
kfd_ioctl_test.cpp Tests variable payload sizes.
gpu_vm_service_test.cpp Tests AQL release ordering and retries.
cdna5_sdma_test.cpp Updates packet-read fault hooks.
dispatch_entry.h Stores pending AQL slot release state.
command_processor.cpp Implements ordered slot invalidation.
simulated_kfd.cpp Updates ioctl and doorbell-unmap behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@atgutier atgutier 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.

AQL fetch no longer acquires packets published with a 16-bit header — emulation/rocjitsu/lib/
rocjitsu/src/rocjitsu/vm/amdgpu/command_processor.cpp:4403

Reasoning: The PR changes the header load from a 16-bit acquire to a 32-bit acquire. A 32-bit atomic
load does not synchronize with a producer’s 16-bit release store. For a VM-polled queue, the CP can
fetch after the write index advances but before a doorbell provides another acquire edge. It can
then see a valid header while reading stale setup or packet body data.

Evidence: ROCr still release-stores a 16-bit header in projects/rocr-runtime/runtime/hsa-runtime/
core/runtime/intercept_queue.cpp:319 (and for its retry barrier at line 276). The CP’s VM-polled
fetch path does not clamp admission to the doorbell (command_processor.cpp:4374–4389), and it now
takes setup from the 32-bit load at line 4433. The new slot-release test uses a fully written
packet, so it does not exercise concurrent publication.

Suggested fix: Define a publication and acquire protocol that covers both 16-bit and 32-bit
producers. Keep a matching 16-bit acquire for supported 16-bit publishers, or move those publishers
to a documented common width, and add a concurrent test for each supported form.

Confidence: High in the synchronization mismatch; a runtime manifestation has not been reproduced.

@Groverkss
Groverkss force-pushed the users/Groverkss/rocjitsu-runtime-cts-stack-1 branch from f7388a0 to 0029cfe Compare October 7, 2026 11:18
Clients built with older KFD headers send an 88-byte CREATE_QUEUE request. Exact-size dispatch silently ignored it, leaving the queue and doorbell unset. Zero-extend the supplied payload into the current structure, dispatch queue creation, and copy back only the caller-provided bytes.
Runtime clients finish queue work but fail teardown because munmap rejects their doorbell view while the process remains open. Allow complete client views to be unmapped while retaining the canonical backing and private monitoring alias until process teardown. Serialize unmapping with mapping replacement and retain protection for the private alias.
AQL producers observe an advanced read index while the consumed slot still contains a valid packet header, breaking ring reuse and drain checks. Release the packet format with a 32-bit atomic store before publishing the cursor. Retain the admitted packet snapshot across transient store failures so retries neither replay work nor release a different mapping.
@Groverkss
Groverkss force-pushed the users/Groverkss/rocjitsu-runtime-cts-stack-1 branch from 0029cfe to a631325 Compare October 7, 2026 13:59
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

gfx1250 B0-to-A0 translation baseline

Warning

The PR result is not directly comparable to the latest develop baseline.

Changed provenance:

Field develop PR
corpus_commit cc781dd88cabd1638d1beeb4539c521ccf27de60 387502e864cce3f0490a967e9a185b4922a5e7de

Compared PR head e02269c3f376c86c933ead0eca4918acf102a634 using rocjitsu-test-corpus run 37650857560.

@Groverkss Groverkss changed the title [1/4] rocjitsu: Add AQL runtime-cts ci and apply rocjitsu fixes [1/5] rocjitsu: Fix KFD queue compatibility and AQL slot retirement Oct 7, 2026
@Groverkss

Copy link
Copy Markdown
Contributor Author

AQL fetch no longer acquires packets published with a 16-bit header — emulation/rocjitsu/lib/ rocjitsu/src/rocjitsu/vm/amdgpu/command_processor.cpp:4403

Reasoning: The PR changes the header load from a 16-bit acquire to a 32-bit acquire. A 32-bit atomic load does not synchronize with a producer’s 16-bit release store. For a VM-polled queue, the CP can fetch after the write index advances but before a doorbell provides another acquire edge. It can then see a valid header while reading stale setup or packet body data.

Evidence: ROCr still release-stores a 16-bit header in projects/rocr-runtime/runtime/hsa-runtime/ core/runtime/intercept_queue.cpp:319 (and for its retry barrier at line 276). The CP’s VM-polled fetch path does not clamp admission to the doorbell (command_processor.cpp:4374–4389), and it now takes setup from the 32-bit load at line 4433. The new slot-release test uses a fully written packet, so it does not exercise concurrent publication.

Suggested fix: Define a publication and acquire protocol that covers both 16-bit and 32-bit producers. Keep a matching 16-bit acquire for supported 16-bit publishers, or move those publishers to a documented common width, and add a concurrent test for each supported form.

Confidence: High in the synchronization mismatch; a runtime manifestation has not been reproduced.

Addressed

@Groverkss
Groverkss requested a review from atgutier October 7, 2026 16:18
@kuhar
kuhar merged commit 26a2330 into develop Oct 8, 2026
83 of 88 checks passed
@kuhar
kuhar deleted the users/Groverkss/rocjitsu-runtime-cts-stack-1 branch October 8, 2026 13:29
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

anujshuk-amd pushed a commit that referenced this pull request Oct 12, 2026
…12934)

- Accept older CREATE_QUEUE payload sizes by zero-extending requests and
copying back only the caller-provided bytes.
- Allow clients to unmap complete doorbell views while preserving the
simulator's backing and private monitoring alias until process teardown.
- Invalidate consumed AQL packet headers before publishing the read
index, retaining admission state across transient memory failures.
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.

4 participants