XGameRuntime: drain active task queue monitors on unregister #2836

Closed
CryingLaughing wants to merge 1 commit from upstream-pr/2836 into main
CryingLaughing commented 2026-11-26 17:01:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T17:01:06Z.


XTaskQueueUnregisterMonitor could return while a monitor still used its context. It could also leave a copied notification snapshot able to invoke the removed registration. Native Windows unregister waited for the running callback in the synthetic comparison. Related to #2021, which covers monitor delivery through shared ports.

What is in it

  • Revoke the registration so notification snapshots skip it. Keep it discoverable until its active invocations finish, so concurrent unregister calls can wait for the same drain.
  • Release the queue and registration locks before invoking monitor code. Calls from a monitor callback stack revoke without waiting, preserving XCL’s existing reentrant behavior.
  • Cover an active callback with two concurrent unregister callers, a revoked entry in an older snapshot, and a monitor unregistering itself.

Tested

  • Head 43a4eb9dacbe1cc1e746609f979597d27538979f on 8b957bec6f82495aec940944c6bf47faa02db590. Windows 11 25H2 build 26200.9974, Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11, debug.
  • The native xgameruntime.dll 10.0.26100.9656 probe ran nine trials in three fresh CPU processes. The external unregister caller returned only after the held callback ended in all nine. Every subsequent submission completed without another monitor invocation.
  • The same three focused tests reported 1 passed, 2 failed, 0 ignored on main with the test-only overlay and 3 passed, 0 failed, 0 ignored on the exact head. Both main failures reproduced the intended timing or stale-snapshot condition. The focused cases had zero capability skips.
  • cargo build --workspace --locked -j 4 passed. cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output reported 1,449 passed, 0 failed, 47 ignored across 38 harnesses. The pass count includes 29 capability skips and 10 separate unset optional sample messages.

Regression run

Matched retail smoke is pending.

Not tested

  • Native Windows reentrant monitor management, other Windows runtime versions, and retail-title behavior.
<!-- greyfinch-sync:ivall/xcl:issue:5514142098 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2836). Originally posted by [CryingLaughing](https://github.com/CryingLaughing) on 2026-11-26T17:01:06Z. --- `XTaskQueueUnregisterMonitor` could return while a monitor still used its context. It could also leave a copied notification snapshot able to invoke the removed registration. Native Windows unregister waited for the running callback in the synthetic comparison. Related to #2021, which covers monitor delivery through shared ports. **What is in it** - Revoke the registration so notification snapshots skip it. Keep it discoverable until its active invocations finish, so concurrent unregister calls can wait for the same drain. - Release the queue and registration locks before invoking monitor code. Calls from a monitor callback stack revoke without waiting, preserving XCL’s existing reentrant behavior. - Cover an active callback with two concurrent unregister callers, a revoked entry in an older snapshot, and a monitor unregistering itself. **Tested** - Head `43a4eb9dacbe1cc1e746609f979597d27538979f` on `8b957bec6f82495aec940944c6bf47faa02db590`. Windows 11 25H2 build 26200.9974, Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11, debug. - The native `xgameruntime.dll` `10.0.26100.9656` probe ran nine trials in three fresh CPU processes. The external unregister caller returned only after the held callback ended in all nine. Every subsequent submission completed without another monitor invocation. - The same three focused tests reported **1 passed, 2 failed, 0 ignored** on main with the test-only overlay and **3 passed, 0 failed, 0 ignored** on the exact head. Both main failures reproduced the intended timing or stale-snapshot condition. The focused cases had zero capability skips. - `cargo build --workspace --locked -j 4` passed. `cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output` reported **1,449 passed, 0 failed, 47 ignored** across 38 harnesses. The pass count includes 29 capability skips and 10 separate unset optional sample messages. **Regression run** Matched retail smoke is pending. **Not tested** - Native Windows reentrant monitor management, other Windows runtime versions, and retail-title behavior.
MatyEjsr commented 2026-11-26 18:28:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MatyEjsr on 2026-11-26T18:28:23Z.


Independent NVIDIA Windows verification and concurrency review of PR #2836 at exact head 43a4eb9dacbe1cc1e746609f979597d27538979f (currently MERGEABLE onto base main 8b957bec6f82495aec940944c6bf47faa02db590).

Tested

  • Windows 11 Pro for Workstations (build 26200.7171), AMD Ryzen 7 7800X3D, 31.4 GB RAM (32 GB), NVIDIA GeForce RTX 3090 (driver 32.0.16.1742, wave32 only), rustc 1.100.0, DXC 1.9.2602.17.
  • cargo build --workspace -j 8 and cargo build --release --workspace -j 8 on 43a4eb9d: passed.
  • cargo test -p xcl --lib hle::xgameruntime::taskqueue:: -- --nocapture:
    • Base main (8b957bec): 10 passed, 0 failed, 0 ignored, 0 skipped.
    • PR head (43a4eb9d, debug): 13 passed, 0 failed, 0 ignored, 0 skipped (the 3 new monitor drain/revocation tests pass).
    • PR head (43a4eb9d, release, 10 consecutive runs): 10/10 passed (13 passed, 0 failed, 0 ignored, 0 skipped each; 0.25-0.26 s per run).
  • cargo test --workspace -j 8 -- --test-threads=8 --nocapture (43a4eb9d, debug): 1,449 passed, 0 failed, 47 ignored across 38 harnesses; 28 explicit SKIPPED lines (21 no wave64, 3 wave32, per-lane form: refused, 3 missing D3D12 debug layer, 1 no heap windows) and 10 unset optional XCL_SAMPLE_* skips (8 XCL_SAMPLE_RPF, 1 XCL_SAMPLE_TTPF, 1 XCL_SAMPLE_AWC) — reported separately and not counted as coverage.
  • cargo test --release -p xcl --test e2e -- --nocapture (43a4eb9d, release): 4 passed, 0 failed, 0 ignored; 2 D3D12 debug-layer SKIPPED subcases for missing d3d12SDKLayers.dll (not counted as coverage).

Regression run & PR checks

  • scripts/smoke.ps1 -Seconds 60 on PR head 43a4eb9d (default -StartupTimeoutSeconds 120) timed out at 180 s during base 8b957bec's pre-launch shader preparation over 26,503 pack records before reaching guest execution (XCL printed no log path, exit code 1). No xcl-smoke v1 pair was produced.
  • The PR checks / PR description check currently fails on 43a4eb9d because the PR body is missing the **AI use** section and both matched xcl-smoke blocks (main + PR head) under **Regression run**.

Code review & overlap check

  • Concurrency and lock ordering in crates/xcl/src/hle/xgameruntime/taskqueue.rs look sound: Monitor::invoke checks revoked before incrementing running, remove_monitor runs only once revoked && running == 0, and neither q.monitors nor monitor.state is held across callbacks or idle.wait(...).
  • Note on MONITOR_DEPTH: because it is a thread-local nesting counter rather than a per-token set, calling XTaskQueueUnregisterMonitor on a distinct monitor B from inside monitor A's callback takes the non-blocking path and returns without draining B if B is active on another thread. That avoids AB-BA deadlock between two monitors unregistering each other and aligns with the PR's Not tested note on reentrant monitor management.
  • Overlap triage: not a duplicate of any merged or open PR; nvidia-dev does not touch taskqueue.rs. Open PR #1154 (termination callback) is unrelated; open PR #2021 also modifies monitor notification in taskqueue.rs (distinct change; minor rebase coordination if both land); open PR #2806 updates the same README.md feature-table row (trivial rebase conflict for whichever lands second).

Not tested

  • Completed retail xcl-smoke v1 pair (blocked by base 8b957bec startup shader preparation exceeding the default smoke.ps1 timeout), AMD / Intel / native wave64 GPUs, D3D12 debug-layer subcases, heap_window_out_of_memory_falls_back_to_the_switch_form, optional XCL_SAMPLE_* tests, and native Windows reentrant monitor behavior.

AI use

  • Antigravity (agy) with gemini-pro-orchestrator (audited by gemini-pro-orchestrator-argon) ran the build, test, release stress, and smoke checks, reviewed the concurrency diff and PR overlap, and audited this report.
<!-- greyfinch-sync:ivall/xcl:comment:7200501951 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2836#issuecomment-7200501951). Originally posted by [MatyEjsr](https://github.com/MatyEjsr) on 2026-11-26T18:28:23Z. --- Independent NVIDIA Windows verification and concurrency review of PR #2836 at exact head `43a4eb9dacbe1cc1e746609f979597d27538979f` (currently `MERGEABLE` onto base `main` `8b957bec6f82495aec940944c6bf47faa02db590`). **Tested** - Windows 11 Pro for Workstations (build 26200.7171), AMD Ryzen 7 7800X3D, 31.4 GB RAM (32 GB), NVIDIA GeForce RTX 3090 (driver `32.0.16.1742`, wave32 only), `rustc 1.100.0`, DXC `1.9.2602.17`. - `cargo build --workspace -j 8` and `cargo build --release --workspace -j 8` on `43a4eb9d`: passed. - `cargo test -p xcl --lib hle::xgameruntime::taskqueue:: -- --nocapture`: - Base `main` (`8b957bec`): **10 passed, 0 failed, 0 ignored**, 0 skipped. - PR head (`43a4eb9d`, debug): **13 passed, 0 failed, 0 ignored**, 0 skipped (the 3 new monitor drain/revocation tests pass). - PR head (`43a4eb9d`, release, 10 consecutive runs): **10/10 passed** (**13 passed, 0 failed, 0 ignored**, 0 skipped each; 0.25-0.26 s per run). - `cargo test --workspace -j 8 -- --test-threads=8 --nocapture` (`43a4eb9d`, debug): **1,449 passed, 0 failed, 47 ignored** across 38 harnesses; **28 explicit `SKIPPED` lines** (21 `no wave64`, 3 `wave32, per-lane form: refused`, 3 missing D3D12 debug layer, 1 `no heap windows`) and **10 unset optional `XCL_SAMPLE_*` skips** (`8` `XCL_SAMPLE_RPF`, `1` `XCL_SAMPLE_TTPF`, `1` `XCL_SAMPLE_AWC`) — reported separately and not counted as coverage. - `cargo test --release -p xcl --test e2e -- --nocapture` (`43a4eb9d`, release): **4 passed, 0 failed, 0 ignored**; **2 D3D12 debug-layer `SKIPPED` subcases** for missing `d3d12SDKLayers.dll` (not counted as coverage). **Regression run & PR checks** - `scripts/smoke.ps1 -Seconds 60` on PR head `43a4eb9d` (default `-StartupTimeoutSeconds 120`) timed out at 180 s during base `8b957bec`'s pre-launch shader preparation over 26,503 pack records before reaching guest execution (`XCL printed no log path`, exit code 1). No `xcl-smoke v1` pair was produced. - The `PR checks / PR description` check currently fails on `43a4eb9d` because the PR body is missing the `**AI use**` section and both matched `xcl-smoke` blocks (`main` + PR head) under `**Regression run**`. **Code review & overlap check** - Concurrency and lock ordering in `crates/xcl/src/hle/xgameruntime/taskqueue.rs` look sound: `Monitor::invoke` checks `revoked` before incrementing `running`, `remove_monitor` runs only once `revoked && running == 0`, and neither `q.monitors` nor `monitor.state` is held across callbacks or `idle.wait(...)`. - Note on `MONITOR_DEPTH`: because it is a thread-local nesting counter rather than a per-token set, calling `XTaskQueueUnregisterMonitor` on a distinct monitor B from inside monitor A's callback takes the non-blocking path and returns without draining B if B is active on another thread. That avoids AB-BA deadlock between two monitors unregistering each other and aligns with the PR's **Not tested** note on reentrant monitor management. - Overlap triage: not a duplicate of any merged or open PR; `nvidia-dev` does not touch `taskqueue.rs`. Open PR #1154 (termination callback) is unrelated; open PR #2021 also modifies monitor notification in `taskqueue.rs` (distinct change; minor rebase coordination if both land); open PR #2806 updates the same `README.md` feature-table row (trivial rebase conflict for whichever lands second). **Not tested** - Completed retail `xcl-smoke v1` pair (blocked by base `8b957bec` startup shader preparation exceeding the default `smoke.ps1` timeout), AMD / Intel / native wave64 GPUs, D3D12 debug-layer subcases, `heap_window_out_of_memory_falls_back_to_the_switch_form`, optional `XCL_SAMPLE_*` tests, and native Windows reentrant monitor behavior. **AI use** - Antigravity (agy) with gemini-pro-orchestrator (audited by gemini-pro-orchestrator-argon) ran the build, test, release stress, and smoke checks, reviewed the concurrency diff and PR overlap, and audited this report.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2836
No description provided.