d3d12: since 106120ca, a full piece cache re-imports the same GPU page cluster windows until RADV loses the device (RX 6700 XT) #666

Open
opened 2026-12-03 01:03:25 +00:00 by JeffreyBytes · 1 comment
JeffreyBytes commented 2026-12-03 01:03:25 +00:00 (Migrated from github.com)
Contributor

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T01:03:25Z.


On main 106120ca, ProjectScarlett loses the device on my RX 6700 XT (1002:73df, RADV / Mesa 26.3.1, GE-Proton11-15, section-import=substituted) 170-210 s after launch, right after the setup screens. The memory ledger's adapter system memory goes from about 1.5 GiB to 18-27 GiB against a 15.9 GiB budget in under a minute, then:

radv/amdgpu: Not enough memory for command submission.
d3d12_device_mark_as_removed: Device ... is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST").

The game exits with code 3. The kernel log is clean, with no GPU fault or reset. a789a4e4, one commit earlier, stays flat at 1.1-1.5 GiB. TUXBOX_XMEM_PRIVATE_VIEWS=0 also stays flat, but that takes the queue page mappings back to being refused, so it doesn't isolate anything.

The memory is real. I sampled the game's /proc/<pid>/fdinfo from outside, and drm-memory-gtt tracks the ledger (15.9 GiB at the crash).

I think the cause is the pieces cache in PagePools (device/heap/pages.rs). It's a PageCache with LIMIT 4096, and get_or_open doesn't index a new key while all 4096 entries are live. That bound is on purpose: failed_imports_are_not_cached_and_live_entries_are_bounded tests it. Since 106120ca this host takes the private-backing path, so gpu_tile fills that cache with single 64 KiB "GPU page mapping" pieces that GpuTiles keep alive. Once there are more than 4096, a new "GPU page cluster" window from shared_window is opened but never indexed. Every later page in that window opens another import of the whole window, which is 64 KiB-4 MiB each, and each import is its own userptr BO charged in full to GTT.

I measured this with a local trace build. It counts live native heaps by source through a private-data marker on each heap, and logs every new window shared_window picks:

pieces live cluster opens distinct windows adapter system memory
2,632 475 474 1.5 GiB
5,888 1,784 585 5.0 GiB
9,520 4,599 655 9.4 GiB, device lost a few seconds later

In another run, at the crash, the live cluster heaps alone were 17.8 GiB (4,910 heaps), which is more than all the title's pages (7.1 GiB). The single-page imports were 288 MiB.

As a check, I changed get_or_open to always index a new live import. Cluster opens then matched the windows (1,259 opens, 1,269 windows), adapter system memory peaked around 4.5 GiB, and there was no device loss. That run went 432 s and then ended with exit code 5 on the title's watchdog (exe+0x23CF683, #215), which I've seen on older builds too, so I don't think it's related. That change was only a test, since it drops the bound the cache is meant to keep.

I also read the host side (vkd3d-proton OpenExistingHeapFromAddress1, RADV bo_from_ptr, amdgpu userptr) to rule out a per-import overhead. Each import charges its own size and gives it back on free, so the growth is the duplicate imports and not a driver cost.

I haven't tried NVIDIA. I'd guess it doesn't take this path because it imports sections. Someone else saw the same crash on another AMD card, but I don't have their numbers.

Things I haven't figured out yet: why live single-page pieces reach about 12k at once (they do get released, and each one is a BO on every submit), and whether 12k is expected.

I'm working on a fix. My plan is to give the cluster windows their own lookup outside the bounded cache (there are only about 1.3k per run), with a test that fills the cache with 4096 live pages and then expects one import, not two, for two pages of a new window.

<!-- greyfinch-sync:brcly/TuxBox:issue:6758042088 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/666). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T01:03:25Z. --- On main `106120ca`, ProjectScarlett loses the device on my RX 6700 XT (`1002:73df`, RADV / Mesa 26.3.1, GE-Proton11-15, `section-import=substituted`) 170-210 s after launch, right after the setup screens. The memory ledger's adapter system memory goes from about 1.5 GiB to 18-27 GiB against a 15.9 GiB budget in under a minute, then: ```text radv/amdgpu: Not enough memory for command submission. d3d12_device_mark_as_removed: Device ... is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST"). ``` The game exits with code 3. The kernel log is clean, with no GPU fault or reset. `a789a4e4`, one commit earlier, stays flat at 1.1-1.5 GiB. `TUXBOX_XMEM_PRIVATE_VIEWS=0` also stays flat, but that takes the queue page mappings back to being refused, so it doesn't isolate anything. The memory is real. I sampled the game's `/proc/<pid>/fdinfo` from outside, and `drm-memory-gtt` tracks the ledger (15.9 GiB at the crash). I think the cause is the `pieces` cache in `PagePools` (`device/heap/pages.rs`). It's a `PageCache` with `LIMIT` 4096, and `get_or_open` doesn't index a new key while all 4096 entries are live. That bound is on purpose: `failed_imports_are_not_cached_and_live_entries_are_bounded` tests it. Since 106120ca this host takes the private-backing path, so `gpu_tile` fills that cache with single 64 KiB "GPU page mapping" pieces that GpuTiles keep alive. Once there are more than 4096, a new "GPU page cluster" window from `shared_window` is opened but never indexed. Every later page in that window opens another import of the whole window, which is 64 KiB-4 MiB each, and each import is its own userptr BO charged in full to GTT. I measured this with a local trace build. It counts live native heaps by source through a private-data marker on each heap, and logs every new window `shared_window` picks: | pieces live | cluster opens | distinct windows | adapter system memory | |---|---|---|---| | 2,632 | 475 | 474 | 1.5 GiB | | 5,888 | 1,784 | 585 | 5.0 GiB | | 9,520 | 4,599 | 655 | 9.4 GiB, device lost a few seconds later | In another run, at the crash, the live cluster heaps alone were 17.8 GiB (4,910 heaps), which is more than all the title's pages (7.1 GiB). The single-page imports were 288 MiB. As a check, I changed `get_or_open` to always index a new live import. Cluster opens then matched the windows (1,259 opens, 1,269 windows), adapter system memory peaked around 4.5 GiB, and there was no device loss. That run went 432 s and then ended with exit code 5 on the title's watchdog (`exe+0x23CF683`, #215), which I've seen on older builds too, so I don't think it's related. That change was only a test, since it drops the bound the cache is meant to keep. I also read the host side (vkd3d-proton `OpenExistingHeapFromAddress1`, RADV `bo_from_ptr`, amdgpu userptr) to rule out a per-import overhead. Each import charges its own size and gives it back on free, so the growth is the duplicate imports and not a driver cost. I haven't tried NVIDIA. I'd guess it doesn't take this path because it imports sections. Someone else saw the same crash on another AMD card, but I don't have their numbers. Things I haven't figured out yet: why live single-page pieces reach about 12k at once (they do get released, and each one is a BO on every submit), and whether 12k is expected. I'm working on a fix. My plan is to give the cluster windows their own lookup outside the bounded cache (there are only about 1.3k per run), with a test that fills the cache with 4096 live pages and then expects one import, not two, for two pages of a new window.
brcly commented 2026-12-03 01:06:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-12-03T01:06:32Z.


Yeah this issue seems to only affect AMD atm.

Open a PR when ready and I'll have a look and make sure it doesn't affect nvidia, which is suffering a different issue related to raytracing atm.

<!-- greyfinch-sync:brcly/TuxBox:comment:7363959645 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/666#issuecomment-7363959645). Originally posted by [brcly](https://github.com/brcly) on 2026-12-03T01:06:32Z. --- Yeah this issue seems to only affect AMD atm. Open a PR when ready and I'll have a look and make sure it doesn't affect nvidia, which is suffering a different issue related to raytracing atm.
Sign in to join this conversation.
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
brcly/TuxBox#666
No description provided.