Textures: slot eviction lets the table go before it touches a slot (lock ring, watchdog) #1969

Closed
joeypercia wants to merge 1 commit from upstream-pr/1969 into main
joeypercia commented 2026-11-29 04:51:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by joeypercia on 2026-11-29T04:51:28Z.


Part of #1900 and #1936 (stalls that end in the +0x23cf683 watchdog); it fixes one cause of them, which may not be their only one.

What it changes

Slot eviction (slot_evict in resource.rs, which the submitting thread's sweep reaches through let_go_idle) held the texture table TEXTURES from picking its candidates to the end of the call. Under that lock it emptied their view slots (evict_slots → HostHeap::texture_slot_evicted), each under the slot's Made lock. Two other paths take the same locks in the other order, and the three together form a ring:

thread holds waits for
submitting thread: sweep → let_go_idle → slot_evict → evict_slots → texture_slot_evicted TEXTURES a slot's Made lock
view mirror (victory-views-*, victory-aside): HostHeap::mirror_inner → begun_before → placed_texture → texture_at that slot's Made lock PLACED_TEXTURES
list thread: texture_at → create_at_address → hand_out_resource (textures().insert) PLACED_TEXTURES TEXTURES

Once the three meet, nothing presents again, and 30 s later the title's watchdog writes to 0 (+0x23cf683).

Now the candidates are still picked under TEXTURES, but each one is pinned with object::add_ref_alive and Held, the way alias_of keeps a texture alive. One already being released is skipped. The table is then let go before any slot is touched. The slots are emptied and the host copies let go with only their own locks held. The pins are let go at the end, with no lock held, so a last reference can take TEXTURES again. What gets evicted, and when, doesn't change.

How it was tested

  • GPU and profile: RTX 4070 Ti 12 GB, Windows 11 26200, 32 GB RAM; Series X, DLSS off, release build, the retail title into the world with Enter pressed through the menus.
  • Before: on main 568c5e5, one run stalled 150 s in; frames had already reached 7.7–8.9 s before it. Thread stacks taken with cdb 21 s into the stall show the three threads in the table above, in those frames: five victory-records, two victory-views, victory-aside, the list threads and a resource release waiting behind them. The run then ended with the watchdog (0xc0000005 at +0x23cf683).
  • After: the ring is a timing race. A second main run under the same conditions entered the world and ran 4 min without it, so a handful of short runs can't show the fix working. The reason for the change is the stacks and the lock order read in the code, not a measured before/after rate. With this change the ring can't close: the submitting thread no longer waits for a Made lock while holding TEXTURES.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes, cargo test --locked -p victory-gpu on 098400f: 589 passed, 0 failed, 44 ignored.

Not tested: a long session or many runs with the change (to see the stalls stop), AMD, and 8 GB cards, where slot eviction runs much more often (#1644).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Searches for "deadlock", "lock order", texture_slot_evicted, mirror_inner, PLACED_TEXTURES and hand_out_resource found no PR or report of this ring. Related: #1644 (the cost of slot_evict on 8 GB cards) and #1763 (slot eviction on 8 GB), which change what is evicted, not the locks.

Written with Claude Code (Claude Opus 5.5): it took the stacks, traced the lock ring through the code, wrote the change and this description, and ran the tests above.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5547678812 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1969). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-29T04:51:28Z. --- Part of #1900 and #1936 (stalls that end in the +0x23cf683 watchdog); it fixes one cause of them, which may not be their only one. ## What it changes Slot eviction (`slot_evict` in `resource.rs`, which the submitting thread's `sweep` reaches through `let_go_idle`) held the texture table `TEXTURES` from picking its candidates to the end of the call. Under that lock it emptied their view slots (`evict_slots` → `HostHeap::texture_slot_evicted`), each under the slot's `Made` lock. Two other paths take the same locks in the other order, and the three together form a ring: | thread | holds | waits for | |---|---|---| | submitting thread: `sweep` → `let_go_idle` → `slot_evict` → `evict_slots` → `texture_slot_evicted` | `TEXTURES` | a slot's `Made` lock | | view mirror (`victory-views-*`, `victory-aside`): `HostHeap::mirror_inner` → `begun_before` → `placed_texture` → `texture_at` | that slot's `Made` lock | `PLACED_TEXTURES` | | list thread: `texture_at` → `create_at_address` → `hand_out_resource` (`textures().insert`) | `PLACED_TEXTURES` | `TEXTURES` | Once the three meet, nothing presents again, and 30 s later the title's watchdog writes to 0 (`+0x23cf683`). Now the candidates are still picked under `TEXTURES`, but each one is pinned with `object::add_ref_alive` and `Held`, the way `alias_of` keeps a texture alive. One already being released is skipped. The table is then let go before any slot is touched. The slots are emptied and the host copies let go with only their own locks held. The pins are let go at the end, with no lock held, so a last reference can take `TEXTURES` again. What gets evicted, and when, doesn't change. ## How it was tested - GPU and profile: RTX 4070 Ti 12 GB, Windows 11 26200, 32 GB RAM; Series X, DLSS off, release build, the retail title into the world with Enter pressed through the menus. - Before: on `main` `568c5e5`, one run stalled 150 s in; frames had already reached 7.7–8.9 s before it. Thread stacks taken with `cdb` 21 s into the stall show the three threads in the table above, in those frames: five `victory-records`, two `victory-views`, `victory-aside`, the list threads and a resource release waiting behind them. The run then ended with the watchdog (`0xc0000005` at `+0x23cf683`). - After: the ring is a timing race. A second `main` run under the same conditions entered the world and ran 4 min without it, so a handful of short runs can't show the fix working. The reason for the change is the stacks and the lock order read in the code, not a measured before/after rate. With this change the ring can't close: the submitting thread no longer waits for a `Made` lock while holding `TEXTURES`. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes, `cargo test --locked -p victory-gpu` on `098400f`: 589 passed, 0 failed, 44 ignored. **Not tested:** a long session or many runs with the change (to see the stalls stop), AMD, and 8 GB cards, where slot eviction runs much more often (#1644). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Searches for "deadlock", "lock order", `texture_slot_evicted`, `mirror_inner`, `PLACED_TEXTURES` and `hand_out_resource` found no PR or report of this ring. Related: #1644 (the cost of `slot_evict` on 8 GB cards) and #1763 (slot eviction on 8 GB), which change what is evicted, not the locks. Written with Claude Code (Claude Opus 5.5): it took the stacks, traced the lock ring through the code, wrote the change and this description, and ran the tests above.
joeypercia commented 2026-11-29 04:52:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by joeypercia on 2026-11-29T04:52:14Z.


Closing as a duplicate: #1763 already lets the texture table go before evict_slots, which breaks the lock ring described above. The stacks and the lock order are now on #1763. (Claude Code, Claude Opus 5.5.)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7250910102 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1969#issuecomment-7250910102). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-29T04:52:14Z. --- Closing as a duplicate: #1763 already lets the texture table go before `evict_slots`, which breaks the lock ring described above. The stacks and the lock order are now on #1763. (Claude Code, Claude Opus 5.5.)

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
trustno1-coder/VIctory-NVIDIA!1969
No description provided.