Repository navigation
Conversation
|
Review (head 625dba5, diff read, not a merge-check):
Fine: the AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check claim |
|
merge-check |
…event AB-BA deadlock
625dba5 to
c34d052
Compare
|
Updated to |
|
Follow-up review (head c34d052, since 625dba5, diff read, not a merge-check):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check claim |
|
merge-check |
|
merge-check claim withdrawn Withdrawn: we have no AMD hardware to check this amd-dev PR against. Sorry for the noise; the slot is free. |
|
Source follow-up on current head The remaining cycle has a concrete lock edge. The follow-up needs to move the remaining mapping-queue operations outside AI use: OpenAI Codex (GPT-6 Sol) traced the current lock and callback paths. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of c34d052a: 3 finding(s) (1 critical, 2 medium), most severe first.
- Critical
crates/xcl/src/hle/d3d12x/vram.rs:2091:flush_zero_tiles_unlockedstill callsnative_queue_signal(ID3D12CommandQueue::Signal, which enters D3D12Core) while holding PAGES.lock(), so the AB-BA deadlock this PR targets can still happen on the recycled-tile zero-fill path. (inline) - Medium
crates/xcl/src/hle/d3d12x/vram.rs:2042:ActiveFlushGuardis created only afterflusher.state.lock().unwrap()succeeds, so if the mutex is poisoned, theactiveincrement made inbefore_executeis never undone. (inline) - Medium
crates/xcl/src/hle/d3d12x/vram.rs:2097: Not certain about this one: when the zero-fill has executed but the device's Pages entry is gone (removed or replaced between the unlocked ExecuteCommandLists and the final PAGES block, which the new test itself does), nothing is signall.... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| } | ||
| if executed { | ||
| pages.value += 1; | ||
| let _ = super::real::native_queue_signal(&pages.queue, &pages.fence, pages.value); |
There was a problem hiding this comment.
Critical: flush_zero_tiles_unlocked still calls native_queue_signal (ID3D12CommandQueue::Signal, which enters D3D12Core) while holding PAGES.lock(), so the AB-BA deadlock this PR targets can still happen on the recycled-tile zero-fill path. Thread A finishes the unlocked ExecuteCommandLists, takes PAGES to install buffers and bump pages.value, then calls Signal and blocks on D3D12Core's internal lock. Thread B is inside D3D12Core holding that lock and calls res_release -> forget_for_recycle -> forget_pages -> PAGES.lock(), and both threads hang. It's the same lock pair, now through Signal instead of alloc.Reset. Signalling after PAGES is released, then recording the value under PAGES, would close it.
| ) { | ||
| // Declare `ring_guard` before `_active_guard` so `_active_guard` decrements `flusher.active` | ||
| // while `flusher.state` is still held; `ZeroFlushStep::Wait` waiters then see `active == 0`. | ||
| let mut ring_guard = flusher.state.lock().unwrap(); |
There was a problem hiding this comment.
Medium: ActiveFlushGuard is created only after flusher.state.lock().unwrap() succeeds, so if the mutex is poisoned, the active increment made in before_execute is never undone. After any earlier panic while state was held (e.g. a D3D12 wrapper panic), the next Drain panics at lock().unwrap() with active stuck at 1 or more. From then on every before_execute on that device takes the Wait branch, and its own flusher.state.lock().unwrap() panics on every title submit. Creating the guard before taking the lock (or recovering the poisoned guard) would avoid it.
| None | ||
| } | ||
| } else { | ||
| stale_bufs.extend(created.into_iter().map(|(_, _, b)| b)); |
There was a problem hiding this comment.
Medium: Not certain about this one: when the zero-fill has executed but the device's Pages entry is gone (removed or replaced between the unlocked ExecuteCommandLists and the final PAGES block, which the new test itself does), nothing is signalled and ring.slots[slot_idx].fence_val isn't updated. The slot looks free while its allocator is still in use on the GPU, so the next flush on that ring calls alloc.Reset() on an executing allocator (a D3D12 error or device removal), and the ZeroFlusher Arc can drop the ring's allocator and list while their work is in flight. Signalling the ring's own fence regardless of whether Pages still exists would keep the slot honest.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
|
merge-check |
Moves recycled-tile zero-fill D3D12 recording and submission (
ZeroRing::new,CreatePlacedResource,fence::wait,kept_bufs.clear,ID3D12CommandAllocator::Reset,ID3D12GraphicsCommandList::Reset,ExecuteCommandLists) andPoolHeaps::take_heap's cachedzero_bufCOM release outsidePAGES.lock(), breaking the live AB-BA deadlock observed betweenvram::before_execute→flush_zero_tiles→ID3D12CommandAllocator::Reset(holdingPAGES, waiting onD3D12Coreinternal lock) andD3D12Core→res_release→forget_for_recycle→forget_pages(holdingD3D12Corelock, waiting onPAGES).TL;DR — Before vs After
origin/amd-dev41aa60ce)c34d052a)alloc.Reset/ExecuteCommandListsPAGES.lock()(AB-BA deadlock withres_release→forget_pages)PAGES.lock()via per-deviceZeroFlusher(PAGES.try_lock()asserted beforealloc.Reset)zero_bufCOM release on heap reclaimPAGES.lock()take_heapand dropped outsidePAGES.lock()41aa60cevsc34d052a)1,654frames /15,902 MB(0crashes)1,636frames /16,164 MB(0crashes)Scope note on remaining
PAGES.lock()calls: This PR fixes the observed recycled-tile zero-fill andzero_bufdrop deadlock path;native_queue_signalafter flush,UpdateTileMappings/SignalinPages::map/unmap_range, andCreateHeapinbind_rangeremain underPAGES.lock()and are intentionally left out of scope for this PR. Diff is+516/-142in a single file (vram.rs: ~370 runtime lines replacing the inline flush path + ~145 test lines) because theZeroFlusherextraction,before_executewait/drain handoff, andtake_heapunlocked drop must land together to avoid leaving a partial lock-order state.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:ZeroFlusher(state: Mutex<Option<ZeroRing>>,active: AtomicUsize,failed: AtomicBool) sobefore_executedrains coalesced tile runs underPAGES.lock(), runsZeroRing::new/CreatePlacedResource/fence::wait/kept_bufs.clear/alloc.Reset/list.Reset/ExecuteCommandListsunlocked inrecord_and_execute_zero_runs, and blocks heap reclaim while a flush is active.PoolHeaps::take_heapto extractslotsbeforezero_bufs(preventing early-return drop insidePAGES) and return(ID3D12Heap, Option<ID3D12Resource>)for unlocked release.bind_rangeauto-flush (which also ran underplacements::REGISTRY).before_execute_zero_fills_recycled_tiles_without_holding_pages_lock(assertsPAGES.try_lock().is_ok()directly insiderecord_and_execute_zero_runsimmediately beforeslot.alloc.Reset()during a realbefore_executecall, plus GPU readback verifying zero-fill) andpool_heaps_take_heap_returns_zero_buffer_for_unlocked_drop.Tested
32.0.21045.29003), AMD Ryzen 7 5700X, Windows 11 x64,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2,960 passed, 13 failed, 49 ignored. All 13 failures reproduce identically on cleanorigin/amd-dev41aa60ce(2,954 passed, 17 failed, 49 ignored: 3 pre-existing RDNA2 f32/NaN tests, 6 parallelsparse/title_texturesshared-global contention tests,test_title_runs_and_game_folder_is_untouched, andtwo_pass_driver_cache_e2e).SKIPPED(7): 4×f16_programs_on_the_gpu, 2× heap-window tests, 1×pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off).cargo test -p xcl --lib -- hle::d3d12x::vram::tests --test-threads=1: 75 passed, 0 failed, 1 ignored, 0 skipped (includinga_recycled_page_is_zeroed_before_a_new_texture_uses_it,before_execute_zero_fills_recycled_tiles_without_holding_pages_lock, andpool_heaps_take_heap_returns_zero_buffer_for_unlocked_drop).Regression run
Base (
main, required bypr_check.py):Base (
origin/amd-devmerge base):PR head (
c34d052a):Not tested
AI use
take_heapearly-return fix and deterministicPAGES.try_lock()check beforealloc.Reset(), ran the workspace GPU test suite and 60 s smoke, and updated this description.