Repository navigation
D3D12.X: the sparse state is replaced outside its lock - #443
Conversation
|
Test run of Tested
Review of the change: in Not tested: no retail title or regression run (I have no unpacked game), no Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Tested RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, Pass: 677 passed, 0 failed, 41 ignored. SKIPPED: only the 2 Run and written with Claude Code (Claude Opus 5.5). |
shdann
left a comment
There was a problem hiding this comment.
crates/xcl/tests/sparse_reinit.rs:33 assumes that the second initialization creates at least one window. On 16fc79d, the Windows CI worker completed the call within the timeout and returned zero windows. The test then failed at this assertion. Please check that the adapter can create the second set of windows before using this integration test as the deadlock check. A separate test with a destructor that takes the same lock can cover the lock order on every worker. Failed CI job. Reviewed the diff and CI log with OpenAI Codex (GPT-6).
|
Test report for Tested
The hang without this PR, on this machine
Reviewed (read the whole diff)
Not tested
AI use
|
|
Two points not covered above:
On an RTX 4070 SUPER (621.24) this tree passed 4 of 4 plain suite runs (677 / 0 / 41), while trees without it hung in the #344 chain in 6 of 11 runs, matching throny's stacks. AI-assisted review (Claude Code, Claude Opus 5.5). |
sparse::init installed its state with *STATE.lock() = Some(s): the state it replaced was dropped while the guard was held. Once used, that state holds the last references to buffers of its own (readback, staging, zeros), all made through the adopted device; their release goes through real::res_release, which calls sparse::forget_buffer, which locks STATE again - the thread waited for itself, and every later user of the sparse windows behind it. The windows are set up again when two first real::init calls overlap, as GPU tests starting together do: a suite run hung in four GPU tests until it was killed. The old state is now taken out under the lock and dropped after it. Fixes xcl-dev#344 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
16fc79d to
d96812a
Compare
|
Ampere 8 GB (RTX 3070, driver 610.88) targeted and full workspace run on exact PR head Tested
Not tested
AI use
|
|
Thanks, @QemmHD. Point 1 was right, and it's fixed in
🤖 Claude Opus 5.5 |
|
Regression run on a retail title, as asked under Regression run. Tested
Regression run
this PR's head: Not tested
AI use
|
|
Repeated runs on a machine that hits the #344 hang often, since the check above that the fix removes it was one suite run. Tested
Not tested
AI use
|
…, xcl-dev#490, xcl-dev#347) The fork keeps its own pso_async (short waits, all compute pipelines built ahead); xcl-dev#690 upstream is its used-pipelines part. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
d3d12x::sparse::initinstalled its state with*STATE.lock().unwrap() = Some(s), so the state it replaced was dropped while the guard was held. A state that has been used holds the last references to buffers of its own: readback, staging and zeros, made lazily through the adopted device (sparse.rs830–896). Their release goes throughreal::res_release, which callssparse::forget_buffer, which locksSTATEagain. The thread waits for itself, and every later user of the sparse windows waits behind it. The old state is now taken out under the lock and dropped after it, as planned in the issue.Fixes #344
The windows get set up again when two first
real::init()calls overlap.real::initreturns early only onceDEVICEis set, andDEVICEis set afteropen_uma→sparse::init, so GPU tests that start together can both get there. That is how the hang in the issue came about: the issue's suite run stopped in four GPU tests until it was killed. One correction to the issue: what matters is not placed buffers in general but the state's own last-referenced buffers, which is why the test reads back a block before setting the windows up again.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs,sparse::init:STATE.lock().unwrap().replace(s), and the old state is dropped after the guard.crates/xcl/tests/sparse_reinit.rs,the_sparse_state_is_replaced_outside_its_lock, in its own process:real::init(), then a 64 KiB sparse block, written and read back (readback_now), which gives the state its readback buffer;sparse::initagain with the same device, on a second thread. The test waits 60 s for it, so on main it fails instead of hanging the suite;real::init()(real::uma_gpu_va() == 0, as on WARP and the no-GPU CI runner), it skips (no GPU UMA), aspredication_e2e.rsdoes.Tested
cargo test --workspace -- --test-threads=4ond96812a(this PR, on maina6f5f7a): 677 passed, 0 failed, 41 ignored (thexcllibrary: 636 passed, 21 ignored). SKIPPED GPU tests: 2, bothno wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).d96812a, 3 runs each:sparse.rsas on maina6f5f7a: 3 of 3 failed withsparse::init did not return within 60 s;XCL_ADAPTER=warp: the first set-up opens no sparse window (CreateReservedResource:E_OUTOFMEMORY), and the test printsSKIPPED the_sparse_state_is_replaced_outside_its_lock: no GPU UMAand passes, with this change and with main'ssparse.rs. At16fc79dit failed there atsparse_reinit.rs:33in 0.13 s, as on the CI runner.16fc79d.scripts/test.ps1: 677 passed, 0 failed, 41 ignored, no SKIPPED GPU tests. Withsparse.rsfrommainand the new test kept, the test fails after 60.33 s (1 run).16fc79dmerged ontomain2997c9a.cargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored; SKIPPED only the 2no wave64tests.16fc79dmerged ontomain2997c9a.cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored;sparse_reinit3 of 3 pass, and fails after 60 s withinitas onmain. Without this PR their suite stopped in the D3D12.X: replacing the sparse state deadlocks when the old state still holds placed buffers #344 hang in 8 runs; their thread stacks show the chain above.16fc79d.cargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored; SKIPPED the 2no wave64tests and 2no D3D12 debug layertests;sparse_reinitpasses 3 of 3.scripts/smoke.ps1 -Seconds 90,main508a0c7againstd96812a, each run twice and the second run kept: 2361 and 2342 frames, peak commit 15674 and 15698 MB, no device removal or crash in any run.d96812amerged ontomain508a0c7, on a machine that hits D3D12.X: replacing the sparse state deadlocks when the old state still holds placed buffers #344 often.cargo test -p xcl --lib -- --test-threads=4, 180 s limit a run:mainhung in 1 of 5 runs,mainwith D3D12.X: a console MS in the AS slot is translated as the mesh shader it is #541 in 4 of 7, and this PR finished all 10 (640 passed, 0 failed, 21 ignored each). Every hang stopped at the same four tests as the stacks above.Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.
main:
PR:
Not tested
sparse::inittwice: not throughreal::init, which outside tests onlybackend()'s one-time initializer calls (checked on2997c9a); other routes are not checked. The smoke runs above are a regression check only.real::init()calls that really overlap. The test callssparse::inita second time directly, with the device it already has.sparse::initand keeps the drop under the guard (*state = Some(s)whilestateis the guard), so whichever merges second needs a rebase.AI use
🤖 Generated with Claude Code