[rocjitsu][consan] Track native application dispatch lifetimes #16517
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 648 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.387
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #16517"
general
weight: 0.35
hanhanW
Applications can create queues before loading code objects and issue overlapping native helper kernels with null completion signals. The controlled ConSan runtime requires a frozen prepared module, one queue and a dedicated completion for each nonoverlapping launch, so it rejects these application sequences. Observing native completion requires tracking each launch without making the application allocate signals or adding dependencies between its queues.
Add the opt-in
RJ_CONSAN_APPLICATION_PROFILE=1adapter. Reuse the existing native ABI inventory to admit exact original images listed inRJ_CONSAN_NATIVE_IMAGES, matching both their digest and complete bytes. Resolve every entry at executable freeze before publishing bindings, reject kernel-object collisions across modules, and bind dispatches to their queue agent. Support system-memory compute queues created through the core or AMD API before image loading, preserving priority, CU mask and profiling calls. Queue count is governed by ROCR and system resources; ConSan adds no application queue-count cap.For standard and AMD extended format 3 native dispatches with null completions, substitute a fresh runtime-owned signal initialized to
1. Preserve the other packet bytes, including arguments, resource requests, fences, dependencies, cluster geometry and performance hints. Keep coalesced packet order without inserting barriers or dependency edges. Private completion publication adds overhead, so exact timing equivalence is not claimed.Each launch retains its module, queue identity and submission sequence until the observer reads exactly
0from its private completion. Independent launches can retire out of order. Queue and executable destruction wait for their own launches, whilerj_consan_drain()waits for the prefix submitted before the call. Charge the execution budget per dispatch rather than per batch packet, allowing trailing barriers to pass. After admission failure, notify eligible tracked AND/OR barrier completions with-1while retaining signals already owned by pending dispatches.Count successful HSA initialization and shutdown calls through the installed hooks, starting with the installing
hsa_initreference. Automatically finish before releasing the final tracked reference; intermediate shutdown leaves admission open for remaining clients. Calls that bypass the hooks are outside this accounting contract. Keep Runtime ownership untilOnUnloadso HIP exit handlers can still use the hooks, and defer deletion through an enclosing shutdown call. Both Linux plugin variants useNODELETEto keep hook code mapped when ROCR unloads the tool inside that call, retaining the DSO mapping for the process lifetime.Native-only setup requires neither a prepared artifact nor
RJ_CONSAN_CAPTURE_PATH, and produces no selected capture or LDS-analysis coverage. Selected LDS execution retains the controlled queue and dedicated-completion path. A configured selected artifact still requires its capture settings and makes finish fail if its capture never starts.Current limits
The application adapter retains these restrictions; image/module counts and the execution budget are profile policy rather than hardware limits:
| Boundary | Current behavior |
|---|---|
| Images and modules | At most 16 distinct native images, 256 MiB of aggregate original image bytes and 16 native modules. The module-count guard runs before image classification, so loading the optional selected image after 16 native modules is rejected; loading it first permits those native modules. |
| Dispatch budget | At most 1,024 cumulative dispatches per Runtime, including native-only launches. Draining does not replenish the budget. |
| Native resource requests | Private allocation must equal the descriptor's static requirement; group allocation must meet the static minimum and fit within 64 KiB. These checks currently reject legal larger private allocations and larger-LDS requests on capable targets. |
| Empty lifecycle | Native-only finish rejects a run with no dispatches, causing final automatic shutdown to fail despite having no pending work or selected capture. |
| Packet profile | Nonzero application completions and extended format 4 remain unsupported. Application-profile dispatch admission is native-only. |
Example walkthrough
For an illustrative allowed image containing kernel C, create Q0 and Q1 before loading and freezing the image as module M. Submit independent C launches with admitted resource requests and completion handle
0. The runtime creates S0 and S1, each initialized to1:A drain started after both submissions waits for both. If Q1 completes first, observing
S1=0retires sequence 2 and permits Q1 destruction; drain and destruction of shared module M still wait for sequence 1. ObservingS0=0completes that prefix. A C packet with a nonzero application completion is rejected.