RDNA2: keep the 2 GB aperture segment from filling (device loss at world load) #127

Closed
MalarkZA wants to merge 0 commits from upstream-pr/127 into main
MalarkZA commented 2026-11-27 13:43:29 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by MalarkZA on 2026-11-27T13:43:29Z.


What

On RDNA2 cards, with submissions sent ahead (VICTORY_RELAY=1/2, the play.ps1
default), the host device is removed at the first world load, ~40-51 s in:
0x887A0007, no work in flight (DRED breadcrumbs empty,
"nothing of ours was running on the card"); with the debug layer on:
"Kernel memory failure. There might be a memory leak." (id 834).

Reproduced here on an RX 6900 XT (driver 32.0.21045.29003, Win11 26300) in
every relayed run; upstream reports match on RX 6700 XT / 6800 / 6950 XT
(kyokyotosh/VIctory-6700XT FINDINGS-6700XT.md; avatarmanz/VIctory-7900XTX #394, #289).

Why (GPU ETW trace, FINDINGS-6700XT.md)

The video memory manager's 2 GB aperture segment holds the driver's command
buffers (1 MB + 64 KB per D3D12 command list), upload scratch and the
D3D12_HEAP_TYPE_CUSTOM write-back buffers. land() kept the newest 64
flights' finished lists (up to ~716 host lists) and every host list carried
its own prelude for life (~950 preludes, ~1 MB of the segment each). Live
lists climbed to ~1,150-1,250 at the world load, the segment ran full,
ReserveResource failed and the kernel scheduler marked the device faulted.
No GPU hang, no page fault, no timed-out packet.

What this PR does

Four commits cherry-picked from kyokyotosh/VIctory-6700XT
(f173347, 018d372, e3c0703, 63a773e), kept attributed:

  1. Host lists of landed flights go back to the pool at once; what they held
    waits the bury lag through retire.
  2. The card's memory segments are read with D3DKMTQueryStatistics and said
    once at the start; while an aperture segment holds more than
    VICTORY_SEGMENT_TIGHT percent (85; 0: never) of its limit, flights sent
    ahead land first.
  3. The back-off holds: looked at on every send, all flights land while tight,
    idle host lists trimmed to 64 (on at 80%, off at 70%).
  4. Preludes come from a pool: taken when a list is first submitted with
    transitions, given back at its reset (128 kept idle, 16 while the segment
    is tight).

Two follow-ups for this tree:

  1. trim_idle matches our three-field Idle (the picked pattern predates
    the retire timestamp our list.rs has).
  2. The old per-list PreludeSlot mechanism and VICTORY_MAX_PRELUDES go with
    the pool that replaces them (the prelude-pool pick left them orphaned here;
    scripts/play-3070.ps1 capped them at 32 - see note below).

Measured (RX 6900 XT, Series X, diag build, this PR's base + relay on)

base with this PR, VICTORY_RELAY=2
world load device removed in every run, 37-51 s in (0x887A0007, nothing in flight) none: full opening sequence, stable 12-15 fps, 5+ min
host lists alive 1,148-1,175 at the removal 975
preludes made 283 by 50 s (~950 upstream) 96 for the whole run
relay dying on it active (17.8 flights/frame landed)

VICTORY_RELAY=0 (the workaround) also survives, at 7-8 fps. Upstream: RX 6700
XT 8.8-12.6 fps at relay 2 with zero removals in 10+ min; RX 6950 XT 18.1 fps
same.

CI notes (diffed against the base; the branch carries pre-existing debt)

  • cargo clippy -D warnings, plain and --all-features: this PR adds zero
    new findings (114 pre-existing on the base, unchanged).
  • cargo test --workspace: identical to the base (4 pre-existing
    victory-gpu lib failures: hlehooks, indirect x2, descriptor).
  • asset policy (xtask::repository_passes_policy): zero new violations from
    this PR (pre-existing: klbf-lab.ico/.rc, klbf_card.png,
    shader_cache.rs, tools/patches/*.patch, tools/ghidra-scripts/*).

Note for the 3070 setup: VICTORY_MAX_PRELUDES=32 no longer exists - the
new pool is capped in code at 128 idle / 16 tight. If the 12 GB 3070's smaller
segment needs a lower cap, that is a follow-up (a pool-shaped knob).

<!-- greyfinch-sync:PastiiJay/klbf-lab:issue:5527648844 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127). Originally posted by [MalarkZA](https://github.com/MalarkZA) on 2026-11-27T13:43:29Z. --- **What** On RDNA2 cards, with submissions sent ahead (`VICTORY_RELAY=1/2`, the `play.ps1` default), the host device is removed at the first world load, ~40-51 s in: `0x887A0007`, no work in flight (DRED breadcrumbs empty, "nothing of ours was running on the card"); with the debug layer on: "Kernel memory failure. There might be a memory leak." (id 834). Reproduced here on an RX 6900 XT (driver 32.0.21045.29003, Win11 26300) in every relayed run; upstream reports match on RX 6700 XT / 6800 / 6950 XT (kyokyotosh/VIctory-6700XT FINDINGS-6700XT.md; avatarmanz/VIctory-7900XTX #394, #289). **Why (GPU ETW trace, FINDINGS-6700XT.md)** The video memory manager's 2 GB aperture segment holds the driver's command buffers (1 MB + 64 KB per D3D12 command list), upload scratch and the `D3D12_HEAP_TYPE_CUSTOM` write-back buffers. `land()` kept the newest 64 flights' finished lists (up to ~716 host lists) and every host list carried its own prelude for life (~950 preludes, ~1 MB of the segment each). Live lists climbed to ~1,150-1,250 at the world load, the segment ran full, `ReserveResource` failed and the kernel scheduler marked the device faulted. No GPU hang, no page fault, no timed-out packet. **What this PR does** Four commits cherry-picked from kyokyotosh/VIctory-6700XT (`f173347`, `018d372`, `e3c0703`, `63a773e`), kept attributed: 1. Host lists of landed flights go back to the pool at once; what they held waits the bury lag through `retire`. 2. The card's memory segments are read with `D3DKMTQueryStatistics` and said once at the start; while an aperture segment holds more than `VICTORY_SEGMENT_TIGHT` percent (85; 0: never) of its limit, flights sent ahead land first. 3. The back-off holds: looked at on every send, all flights land while tight, idle host lists trimmed to 64 (on at 80%, off at 70%). 4. Preludes come from a pool: taken when a list is first submitted with transitions, given back at its reset (128 kept idle, 16 while the segment is tight). Two follow-ups for this tree: 5. `trim_idle` matches our three-field `Idle` (the picked pattern predates the retire timestamp our `list.rs` has). 6. The old per-list `PreludeSlot` mechanism and `VICTORY_MAX_PRELUDES` go with the pool that replaces them (the prelude-pool pick left them orphaned here; `scripts/play-3070.ps1` capped them at 32 - see note below). **Measured (RX 6900 XT, Series X, diag build, this PR's base + relay on)** | | base | with this PR, `VICTORY_RELAY=2` | |---|---|---| | world load | device removed in every run, 37-51 s in (`0x887A0007`, nothing in flight) | none: full opening sequence, stable 12-15 fps, 5+ min | | host lists alive | 1,148-1,175 at the removal | 975 | | preludes made | 283 by 50 s (~950 upstream) | 96 for the whole run | | relay | dying on it | active (17.8 flights/frame landed) | `VICTORY_RELAY=0` (the workaround) also survives, at 7-8 fps. Upstream: RX 6700 XT 8.8-12.6 fps at relay 2 with zero removals in 10+ min; RX 6950 XT 18.1 fps same. **CI notes (diffed against the base; the branch carries pre-existing debt)** - `cargo clippy -D warnings`, plain and `--all-features`: this PR adds zero new findings (114 pre-existing on the base, unchanged). - `cargo test --workspace`: identical to the base (4 pre-existing victory-gpu lib failures: hlehooks, indirect x2, descriptor). - asset policy (`xtask::repository_passes_policy`): zero new violations from this PR (pre-existing: `klbf-lab.ico`/`.rc`, `klbf_card.png`, `shader_cache.rs`, `tools/patches/*.patch`, `tools/ghidra-scripts/*`). **Note for the 3070 setup:** `VICTORY_MAX_PRELUDES=32` no longer exists - the new pool is capped in code at 128 idle / 16 tight. If the 12 GB 3070's smaller segment needs a lower cap, that is a follow-up (a pool-shaped knob).
HandshakeHackin commented 2026-11-27 13:56:45 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-27T13:56:45Z.


One boundary case in segments::tight affects adapters reporting multiple aperture segments. With 80,001/100,000 bytes resident in the first and 160,000/200,000 in the second, both sort to 800 per thousand. The second wins the tie, so back-off stays off even though the first exceeds 80%. Reversing the segments changes the decision. The same case applies at the 70% release threshold.

Patch and two regression tests compare the fractions exactly. The segment source is identical on rdna2-test at eb6feb8 and this PR at 3c825b3. On Windows both tests passed with the patch. Restoring the rounded comparison failed the ordering test. This uses synthetic segment readings. Windows test log

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7220137856 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7220137856). Originally posted by [HandshakeHackin](https://github.com/HandshakeHackin) on 2026-11-27T13:56:45Z. --- One boundary case in `segments::tight` affects adapters reporting multiple aperture segments. With 80,001/100,000 bytes resident in the first and 160,000/200,000 in the second, both sort to 800 per thousand. The second wins the tie, so back-off stays off even though the first exceeds 80%. Reversing the segments changes the decision. The same case applies at the 70% release threshold. [Patch and two regression tests](https://github.com/HandshakeHackin/klbf-lab/commit/966c5629654b558639acdf4b56bfdbbaf05b0c68) compare the fractions exactly. The segment source is identical on `rdna2-test` at `eb6feb8` and this PR at `3c825b3`. On Windows both tests passed with the patch. Restoring the rounded comparison failed the ordering test. This uses synthetic segment readings. [Windows test log](https://github.com/HandshakeHackin/klbf-lab/actions/runs/46010786822/job/140545440369)
PastiiJay commented 2026-11-27 14:04:19 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-27T14:04:19Z.


Thanks @MalarkZA, a careful write-up with DRED and debug-layer evidence, and @HandshakeHackin, good catch on the tie in segments::tight. On the AMD line we port changes ourselves with an A/B bench rather than merging, so this one goes to our list next to the kyokyotosh fix already on rdna2-test, and you'll be credited. Next step: could you fold 966c562 into the PR and attach the console of one relayed run that reaches the world with it?

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7220297027 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7220297027). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-27T14:04:19Z. --- Thanks @MalarkZA, a careful write-up with DRED and debug-layer evidence, and @HandshakeHackin, good catch on the tie in `segments::tight`. On the AMD line we port changes ourselves with an A/B bench rather than merging, so this one goes to our list next to the kyokyotosh fix already on `rdna2-test`, and you'll be credited. Next step: could you fold `966c562` into the PR and attach the console of one relayed run that reaches the world with it?
HandshakeHackin commented 2026-11-27 14:17:27 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-27T14:17:27Z.


I applied the threshold fix to your exact 3c825b3 head. The combined commit d61c030 is one commit ahead of this PR and can be fast-forwarded onto the author branch. Both aperture tests passed on that tree and the Windows diagnostic build compiled. Build and test log

I have no physical Radeon attached here. The remaining check is the console from a relayed world-load run on this combined revision.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7220594641 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7220594641). Originally posted by [HandshakeHackin](https://github.com/HandshakeHackin) on 2026-11-27T14:17:27Z. --- I applied the threshold fix to your exact `3c825b3` head. The [combined commit `d61c030`](https://github.com/HandshakeHackin/klbf-lab/commit/d61c03075adc9ff90c9f2c7c8fc89e3ac69c660d) is one commit ahead of this PR and can be fast-forwarded onto the author branch. Both aperture tests passed on that tree and the Windows diagnostic build compiled. [Build and test log](https://github.com/HandshakeHackin/klbf-lab/actions/runs/46012944352/job/140552773916) I have no physical Radeon attached here. The remaining check is the console from a relayed world-load run on this combined revision.
MalarkZA commented 2026-11-27 14:37:32 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by MalarkZA on 2026-11-27T14:37:32Z.


Folded in: the PR head is now d61c030 (HandshakeHackin's exact-fraction fix + both regression tests, which pass locally on Windows).

Relayed world-load run on d61c030, RX 6900 XT, diag build, default play.ps1 (VICTORY_RELAY=2, exact=true), console attached:

  • no device removal: ~3.5 min, well past the old 37-51 s point; ended by closing the window
  • in the world: 12-15 fps, 971 host lists alive (steady), relay landing ~19 flights/frame
  • segment 1 (2,048 MB aperture) read at the start; the back-off never fired in this run

Note: the early log line "RDNA 2 adapter: VICTORY_RELAY defaults to 0" is printed for any RDNA 2 card, but play.ps1's explicit VICTORY_RELAY=2 overrides it, and the relay lines confirm the relay was on.

pr127-d61c030-rx6900xt-relay2-console.txt

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7221020278 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7221020278). Originally posted by [MalarkZA](https://github.com/MalarkZA) on 2026-11-27T14:37:32Z. --- Folded in: the PR head is now `d61c030` (HandshakeHackin's exact-fraction fix + both regression tests, which pass locally on Windows). Relayed world-load run on `d61c030`, RX 6900 XT, diag build, default `play.ps1` (`VICTORY_RELAY=2`, `exact=true`), console attached: - no device removal: ~3.5 min, well past the old 37-51 s point; ended by closing the window - in the world: 12-15 fps, 971 host lists alive (steady), relay landing ~19 flights/frame - segment 1 (2,048 MB aperture) read at the start; the back-off never fired in this run Note: the early log line "RDNA 2 adapter: VICTORY_RELAY defaults to 0" is printed for any RDNA 2 card, but `play.ps1`'s explicit `VICTORY_RELAY=2` overrides it, and the relay lines confirm the relay was on. [pr127-d61c030-rx6900xt-relay2-console.txt](https://github.com/user-attachments/files/35517259/pr127-d61c030-rx6900xt-relay2-console.txt)
PastiiJay commented 2026-11-27 14:47:00 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-27T14:47:00Z.


Thanks @MalarkZA, 3.5 minutes in the world on relay 2 with no device removal, past the old 40-50 s point, is the result we were hoping for. The note about the RDNA 2 log line is useful too. We'll port it onto the AMD line ourselves, crediting you and HandshakeHackin. Next step, if you have the time: a longer relayed session (10 min or more, with some driving) so we can see whether the back-off ever fires.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7221221865 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7221221865). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-27T14:47:00Z. --- Thanks @MalarkZA, 3.5 minutes in the world on relay 2 with no device removal, past the old 40-50 s point, is the result we were hoping for. The note about the RDNA 2 log line is useful too. We'll port it onto the AMD line ourselves, crediting you and HandshakeHackin. Next step, if you have the time: a longer relayed session (10 min or more, with some driving) so we can see whether the back-off ever fires.
MalarkZA commented 2026-11-27 15:00:04 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by MalarkZA on 2026-11-27T15:00:04Z.


Longer relayed session on the same d61c030, RX 6900 XT, diag build, default play.ps1 (VICTORY_RELAY=2), console attached:

  • ~17 min (14:41-14:58 UTC), no device removal and no errors; ended by closing the window
  • the aperture back-off never fired: no tight/clear line in the whole session
  • in the world: mostly 12-15 fps (median 14), short dips during loading/streaming, up to ~30
  • host lists alive levelled off at ~1,130-1,150 in the second half (971 in the 3.5 min run); the old build lost the device around that count, but here the segment never reached the 80% back-off mark
  • relay active throughout: median ~22 flights/frame landed over the last stretch

pr127-d61c030-rx6900xt-relay2-17min-console.txt

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7221497528 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7221497528). Originally posted by [MalarkZA](https://github.com/MalarkZA) on 2026-11-27T15:00:04Z. --- Longer relayed session on the same `d61c030`, RX 6900 XT, diag build, default `play.ps1` (`VICTORY_RELAY=2`), console attached: - ~17 min (14:41-14:58 UTC), no device removal and no errors; ended by closing the window - the aperture back-off never fired: no tight/clear line in the whole session - in the world: mostly 12-15 fps (median 14), short dips during loading/streaming, up to ~30 - host lists alive levelled off at ~1,130-1,150 in the second half (971 in the 3.5 min run); the old build lost the device around that count, but here the segment never reached the 80% back-off mark - relay active throughout: median ~22 flights/frame landed over the last stretch [pr127-d61c030-rx6900xt-relay2-17min-console.txt](https://github.com/user-attachments/files/35518069/pr127-d61c030-rx6900xt-relay2-17min-console.txt)
PastiiJay commented 2026-11-27 15:06:51 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-27T15:06:51Z.


Thanks @MalarkZA, 17 minutes on relay 2 with no device loss is the proof we needed, and noting that the old build died around the same list count you now hold is a nice touch. That's enough for us to start the port. One last thing whenever convenient: a BM-v1 run on d61c030, so the fix gets an RX 6000 row on the board.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7221641666 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7221641666). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-27T15:06:51Z. --- Thanks @MalarkZA, 17 minutes on relay 2 with no device loss is the proof we needed, and noting that the old build died around the same list count you now hold is a nice touch. That's enough for us to start the port. One last thing whenever convenient: a BM-v1 run on `d61c030`, so the fix gets an RX 6000 row on the board.
MalarkZA commented 2026-11-27 18:16:41 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by MalarkZA on 2026-11-27T18:16:41Z.


Created https://github.com/PastiiJay/klbf-lab/issues/131 to record the BM-v1 run card as per the docs

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7225319859 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7225319859). Originally posted by [MalarkZA](https://github.com/MalarkZA) on 2026-11-27T18:16:41Z. --- Created https://github.com/PastiiJay/klbf-lab/issues/131 to record the BM-v1 run card as per the docs
PastiiJay commented 2026-11-28 11:29:45 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-28T11:29:45Z.


@MalarkZA We've moved all development to stable-amd and retired the old test branches, so this PR was closed as part of that move. Your work is still here: please reopen it against stable-amd and we'll review it for the next version. Thanks for the contribution!

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7238589326 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7238589326). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-28T11:29:45Z. --- @MalarkZA We've moved all development to `stable-amd` and retired the old test branches, so this PR was closed as part of that move. Your work is still here: please reopen it against `stable-amd` and we'll review it for the next version. Thanks for the contribution!
MalarkZA commented 2026-11-28 12:39:19 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by MalarkZA on 2026-11-28T12:39:19Z.


Thanks! I believe this one is already in stable-amd: it was merged as 71f50ab ("Merge the RDNA2 aperture-segment fix (#127, …)") and shipped in v26.11.4, and all seven commits of this branch are in it. So there's nothing to retarget, unless you'd like something else from it.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7239376270 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7239376270). Originally posted by [MalarkZA](https://github.com/MalarkZA) on 2026-11-28T12:39:19Z. --- Thanks! I believe this one is already in `stable-amd`: it was merged as 71f50ab ("Merge the RDNA2 aperture-segment fix (#127, …)") and shipped in v26.11.4, and all seven commits of this branch are in it. So there's nothing to retarget, unless you'd like something else from it.
PastiiJay commented 2026-11-28 13:32:35 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-28T13:32:35Z.


You're right, it's already in v26.11.4, sorry for the noise. Thanks again for it!

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7240010086 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/127#issuecomment-7240010086). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-28T13:32:35Z. --- You're right, it's already in v26.11.4, sorry for the noise. Thanks again for it!

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
PastiiJay/klbf-lab!127
No description provided.