xmem, xcrdapi, d3d12: fix hybrid private-views aliasing and mixed buffer imports #501

Closed
DrArroway wants to merge 4 commits from upstream-pr/501 into main
DrArroway commented 2026-11-29 17:22:17 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T17:22:17Z.


Summary

Resolves the #456 secondary-alias, xcrdapi, and mixed-buffer import blockers when running hybrid private views (TUXBOX_XMEM_PRIVATE_VIEWS=1), keeping private views opt-in until story-mission verification confirms before considering a default flip (#472).

Rebased onto main (2d6dc338), integrating #495 (MappingMutationGuard) and #508 (write_decoded_output), plus two additional xmem fixes discovered during follow-up testing:

  • xcrdapi (runtime/xcrdapi/src/access.rs, runtime/xcrdapi/src/queue.rs): Route VA destination writes (both decoded payloads via write_decoded_output — including #508's zlib continuation cache path — and plain VA reads, with zero-copy ReadFile when a single contiguous canonical run is resolved) through TuxBoxAcquirePhysicalAccess / TuxBoxReleasePhysicalBacking, while preserving #486's unwritable() check on non-XMem fallback ranges and any run.address == 0 chunks. Moved the XMem physical-access helpers (BackingRun, AccessHold, acquire_physical_access, copy_to_runs) into runtime/xcrdapi/src/access.rs so queue.rs stays under the 1,200-line repository hygiene limit.
  • xmem (runtime/xmem/src/physical_pages/):
    • Eagerly promote unheld pages to SharedSection when a second CPU (0x21) aperture mapping arrives (eager_promote_dual_cpu_aliases, promote_token_to_section), while keeping single-CPU-view + gpu_pool mappings on write-watched MEM_PRIVATE (0 shadows).
    • Have secondary_alias_veh retry briefly when ERROR_BUSY is caused strictly by a transient non-import hold (!has_import_hold && !deferred_unmaps).
    • Mirror unheld secondary-alias read faults (!write) as PAGE_READONLY (mirror_readonly_secondary_alias, tracked in readonly_secondary_aliases) when promotion returns ERROR_BUSY because another alias's canonical span is import-held or has deferred unmaps, while keeping secondary-alias write faults trapping in secondary_aliases.
    • Log [email protected](page_imp=...,span_imp=...,span_held=...,def=...) in log_veh_failure and log_readonly_fallback (blocking_promotion_span / format_blocker) when another alias span blocks promotion.
    • Key BackingOrigin::PrivateView(span_id) by PrivateSpan base in runtime/xmem/src/physical_pages/backing.rs so adjacent 4 MiB OS allocations are never merged into a single cross-VMA backing run.
    • Propagate backing invalidation from map / map_scatter after releasing POOL (integrated with #495's MappingMutationGuard).
    • Remove the sections_only() guards in copy_mappings.rs so hybrid mode handles promoted SharedSection GPU aliases and DeferredKind::SectionPlaceholder cleanly.
  • d3d12 (runtime/d3d12/src/device/heap/): Support per-piece ShadowPages mirroring (open_shadow_piece + BackingGuard::with_parent) in PagePools::import_piece / import_scattered_buffer when a buffer spans mixed MEM_PRIVATE and promoted MEM_MAPPED runs on section-import=substituted hosts instead of failing with E_NOTIMPL (0x80004001).

(Kept TUXBOX_XMEM_PRIVATE_VIEWS=1 opt-in in this PR so testers can verify past the first story mission before changing the default.)

Tested

  • Wine Rust unit tests (GE-Proton11-14, cbb6a2df):
    • tuxbox-xcrdapi --lib: 13 passed, 0 failed (including #486 unwritable-destination and #508 BC6H/zlib/overlapped/GDKX ABI tests).
    • tuxbox-xmem --lib physical_pages: 36 passed, 0 failed, 1 ignored (scan_cost) (including second_cpu_aperture_mapping_eagerly_promotes_unheld_page_to_section, transient_access_hold_does_not_block_secondary_alias_promotion, adjacent_private_views_in_separate_spans_are_not_merged, and secondary_alias_read_succeeds_via_readonly_mirror_while_canonical_span_is_import_held).
    • tuxbox-d3d12 --lib shadow: 5 passed, 0 failed.
  • Repository hygiene (python3 -m unittest tests.test_repository_hygiene): 7 passed, 0 failed.
  • D3D12 buffer regressions with TUXBOX_XMEM_PRIVATE_VIEWS=1 on RX 6900 XT (1002:73bf):
    • buffer-import, buffer-remap, buffer-unmap-alive, buffer-unmap-released, buffer-layout: 5/5 passed.
  • Full tuxbox.py check on RX 6900 XT (1002:73bf, Mesa RADV, GE-Proton11-14, cbb6a2df):
    • Exit 0 — all host code/build checks, 126/126 Lanes + guest fixtures (lanes-benchmark: submit_us=115.1 roundtrip_us=153.4 copy64k_us=162.7 frame_us=256.0 frame_p99_us=463.7 shader_pipeline_us=457.4 dxil_pipeline_us=249.1), 22/22 D3D12 synthetic regression controls, and 66/66 shader translator GPU checks passed.
  • Full tuxbox.py check on AMD Raphael iGPU (1002:164e, Mesa RADV, GE-Proton11-14, cbb6a2df):
    • Exit 0 — all host code/build checks, 125/125 Lanes + guest fixtures (1 skipped; lanes-benchmark: submit_us=67.0 roundtrip_us=128.5 copy64k_us=92.2 frame_us=289.1 frame_p99_us=367.0 shader_pipeline_us=371.8 dxil_pipeline_us=220.9), 22/22 D3D12 synthetic regression controls, and 66/66 shader translator GPU checks passed.
  • ProjectScarlett live run (RX 6900 XT, TUXBOX_XMEM_PRIVATE_VIEWS=1, 2d6dc338 + rebased cbb6a2df, offline):
    • 460.9s across menu -> video -> loading -> 3D world (15,484 total presents; ended only on the pre-existing TCP host-page fault without #389).
    • 0 secondary alias errors, 0 heap import failure, 0 xcrdapi backing failures, and 0 MiB section/shadow buffers (section=0/0.0MiB).
  • Not tested locally: NVIDIA GPU/driver (AMD RADV only on this machine).

Fixes #456 (for TUXBOX_XMEM_PRIVATE_VIEWS=1); related to #472.

<!-- greyfinch-sync:brcly/TuxBox:issue:5553181992 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T17:22:17Z. --- ## Summary Resolves the #456 secondary-alias, `xcrdapi`, and mixed-buffer import blockers when running hybrid private views (`TUXBOX_XMEM_PRIVATE_VIEWS=1`), keeping private views opt-in until story-mission verification confirms before considering a default flip (#472). Rebased onto `main` (`2d6dc338`), integrating #495 (`MappingMutationGuard`) and #508 (`write_decoded_output`), plus two additional `xmem` fixes discovered during follow-up testing: - **`xcrdapi` (`runtime/xcrdapi/src/access.rs`, `runtime/xcrdapi/src/queue.rs`):** Route VA destination writes (both decoded payloads via `write_decoded_output` — including #508's zlib continuation cache path — and plain VA reads, with zero-copy `ReadFile` when a single contiguous canonical run is resolved) through `TuxBoxAcquirePhysicalAccess` / `TuxBoxReleasePhysicalBacking`, while preserving #486's `unwritable()` check on non-XMem fallback ranges and any `run.address == 0` chunks. Moved the XMem physical-access helpers (`BackingRun`, `AccessHold`, `acquire_physical_access`, `copy_to_runs`) into `runtime/xcrdapi/src/access.rs` so `queue.rs` stays under the 1,200-line repository hygiene limit. - **`xmem` (`runtime/xmem/src/physical_pages/`):** - Eagerly promote unheld pages to `SharedSection` when a second CPU (`0x21`) aperture mapping arrives (`eager_promote_dual_cpu_aliases`, `promote_token_to_section`), while keeping single-CPU-view + `gpu_pool` mappings on write-watched `MEM_PRIVATE` (`0` shadows). - Have `secondary_alias_veh` retry briefly when `ERROR_BUSY` is caused strictly by a transient non-import hold (`!has_import_hold && !deferred_unmaps`). - Mirror unheld secondary-alias **read** faults (`!write`) as `PAGE_READONLY` (`mirror_readonly_secondary_alias`, tracked in `readonly_secondary_aliases`) when promotion returns `ERROR_BUSY` because another alias's canonical span is import-held or has deferred unmaps, while keeping secondary-alias **write** faults trapping in `secondary_aliases`. - Log `[email protected](page_imp=...,span_imp=...,span_held=...,def=...)` in `log_veh_failure` and `log_readonly_fallback` (`blocking_promotion_span` / `format_blocker`) when another alias span blocks promotion. - Key `BackingOrigin::PrivateView(span_id)` by `PrivateSpan` base in `runtime/xmem/src/physical_pages/backing.rs` so adjacent 4 MiB OS allocations are never merged into a single cross-VMA backing run. - Propagate backing invalidation from `map` / `map_scatter` after releasing `POOL` (integrated with #495's `MappingMutationGuard`). - Remove the `sections_only()` guards in `copy_mappings.rs` so hybrid mode handles promoted `SharedSection` GPU aliases and `DeferredKind::SectionPlaceholder` cleanly. - **`d3d12` (`runtime/d3d12/src/device/heap/`):** Support per-piece `ShadowPages` mirroring (`open_shadow_piece` + `BackingGuard::with_parent`) in `PagePools::import_piece` / `import_scattered_buffer` when a buffer spans mixed `MEM_PRIVATE` and promoted `MEM_MAPPED` runs on `section-import=substituted` hosts instead of failing with `E_NOTIMPL` (`0x80004001`). *(Kept `TUXBOX_XMEM_PRIVATE_VIEWS=1` opt-in in this PR so testers can verify past the first story mission before changing the default.)* ## Tested - **Wine Rust unit tests (`GE-Proton11-14`, `cbb6a2df`):** - `tuxbox-xcrdapi --lib`: **13 passed**, 0 failed (including #486 unwritable-destination and #508 BC6H/zlib/overlapped/GDKX ABI tests). - `tuxbox-xmem --lib physical_pages`: **36 passed**, 0 failed, 1 ignored (`scan_cost`) (including `second_cpu_aperture_mapping_eagerly_promotes_unheld_page_to_section`, `transient_access_hold_does_not_block_secondary_alias_promotion`, `adjacent_private_views_in_separate_spans_are_not_merged`, and `secondary_alias_read_succeeds_via_readonly_mirror_while_canonical_span_is_import_held`). - `tuxbox-d3d12 --lib shadow`: **5 passed**, 0 failed. - **Repository hygiene (`python3 -m unittest tests.test_repository_hygiene`):** **7 passed**, 0 failed. - **D3D12 buffer regressions with `TUXBOX_XMEM_PRIVATE_VIEWS=1` on RX 6900 XT (`1002:73bf`):** - `buffer-import`, `buffer-remap`, `buffer-unmap-alive`, `buffer-unmap-released`, `buffer-layout`: **5/5 passed**. - **Full `tuxbox.py check` on RX 6900 XT (`1002:73bf`, Mesa RADV, GE-Proton11-14, `cbb6a2df`):** - Exit **0** — all host code/build checks, **126/126** Lanes + guest fixtures (`lanes-benchmark`: `submit_us=115.1 roundtrip_us=153.4 copy64k_us=162.7 frame_us=256.0 frame_p99_us=463.7 shader_pipeline_us=457.4 dxil_pipeline_us=249.1`), **22/22** D3D12 synthetic regression controls, and **66/66** shader translator GPU checks passed. - **Full `tuxbox.py check` on AMD Raphael iGPU (`1002:164e`, Mesa RADV, GE-Proton11-14, `cbb6a2df`):** - Exit **0** — all host code/build checks, **125/125** Lanes + guest fixtures (`1` skipped; `lanes-benchmark`: `submit_us=67.0 roundtrip_us=128.5 copy64k_us=92.2 frame_us=289.1 frame_p99_us=367.0 shader_pipeline_us=371.8 dxil_pipeline_us=220.9`), **22/22** D3D12 synthetic regression controls, and **66/66** shader translator GPU checks passed. - **ProjectScarlett live run (RX 6900 XT, `TUXBOX_XMEM_PRIVATE_VIEWS=1`, `2d6dc338` + rebased `cbb6a2df`, offline):** - **460.9s** across menu -> video -> loading -> 3D world (`15,484` total presents; ended only on the pre-existing `TCP` host-page fault without `#389`). - **0** `secondary alias` errors, **0** `heap import failure`, **0** `xcrdapi` backing failures, and **0 MiB** section/shadow buffers (`section=0/0.0MiB`). - **Not tested locally:** NVIDIA GPU/driver (AMD RADV only on this machine). Fixes #456 (for `TUXBOX_XMEM_PRIVATE_VIEWS=1`); related to #472.
brcly commented 2026-11-29 18:30:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T18:30:48Z.


We merged a batch of eleven PRs into main (now 2d6dc338), and this one was on the list, but it no longer merges cleanly. It conflicts with two PRs that went in:

  • #508 (glovepost) in runtime/xcrdapi/src/queue.rs. That PR's description already flagged that whichever of the two landed second would need a rebase.
  • #495 (yours) in runtime/xmem/src/physical_pages.rs, runtime/xmem/src/physical_pages/private_views.rs and runtime/xmem/src/tests/physical_backing.rs.

I didn't want to resolve your XMem changes by hand, so I left it out. Could you rebase onto main? Once it merges cleanly we'll run the full check on NVIDIA (RTX 4070 Ti SUPER) as well, since your runs so far are AMD only, and then merge it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7260541842 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7260541842). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T18:30:48Z. --- We merged a batch of eleven PRs into `main` (now `2d6dc338`), and this one was on the list, but it no longer merges cleanly. It conflicts with two PRs that went in: - **#508** (glovepost) in `runtime/xcrdapi/src/queue.rs`. That PR's description already flagged that whichever of the two landed second would need a rebase. - **#495** (yours) in `runtime/xmem/src/physical_pages.rs`, `runtime/xmem/src/physical_pages/private_views.rs` and `runtime/xmem/src/tests/physical_backing.rs`. I didn't want to resolve your XMem changes by hand, so I left it out. Could you rebase onto `main`? Once it merges cleanly we'll run the full check on NVIDIA (RTX 4070 Ti SUPER) as well, since your runs so far are AMD only, and then merge it.
gtb-sbe commented 2026-11-29 18:34:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-29T18:34:48Z.


I tested this with TUXBOX_XMEM_PRIVATE_VIEWS=1 on my RX 9060 XT (RDNA 4, 1002:7590, RADV, Mesa 26.2.6, GE-Proton11-14, Linux 6.18.60), Ryzen 7 5800X with dual-channel DDR4-3600, 32 GB RAM.

To avoid a full shader prep I didn't build the branch as is. My base is main 6e2c5dab with #441 (closed since in favour of #389, which has the same root-view change plus an NVIDIA check), with runtime/xmem and runtime/xcrdapi brought up to fd636d09 and this PR (f0dc9d98) on top. The Lanes self-test passes in both modes. Since today's batch merge the branch no longer merges cleanly into main (xcrdapi/src/queue.rs and three XMem files).

What changed

Compared with the default mode on the same base:

  • No shadows at all: 0 ms of shadow sync per batch, and placement sees no section-backed pages.
  • Loading: matched by loading progress (the provider's placement count), 118-130 presents per 10 s against 75-94 in the first phase, 108-119 against 23-39 in the next, and 29-63 against 16-29 while the world loads.
  • World: 1.43 s per frame over the first 4.5 minutes, against 2.1 s per frame over the same span in the default mode, and 2.3 against 3.6 s per frame over the first 8.6 minutes, so about 1.5 times faster. After I moved the window to my other monitor it dropped to 1-3 frames per 11-25 s. I can't tell yet whether that was the move or the scene.
  • Batch time: direct batches took 29 % of wall time in the world instead of 65 %, and placement is now 90 % of what's left.
  • Memory: host memory went up, to 16.8 GiB RSS and 2.4 GiB of swap by the end, against 14.9 GiB and 0.9 GiB.

How it ended

It didn't get past the intro. It reached game time 6:14, and then died on a CPU write through a secondary alias:

TuxBox xmem: secondary alias 0x313ca0000 fault not promoted (err=170, write=true, token=0xc3d30, span=0x313c00000..0x313e00000, page_import_held=false, span_import_held=false, page_held=false, span_held=false, deferred=0)

The access violation followed on the same thread (write of 0x313cacf20 at exe+0x4e95778).

The faulting alias's own span has no hold. So I think the ERROR_BUSY comes from the loop over the token's other views in promote_token_to_section, and is_transient_promotion_hold turned the retry down because one of those spans has an import hold or a deferred unmap. That would mean #456 is still reachable when a page's canonical backing is imported. I haven't confirmed which view blocked it, because the line only covers the faulting span; logging the blocking view's span and hold kind would show it.

For comparison, of my default-mode runs on the same base that got that far, two ended on the title's hang watchdog at game time 3:00, and the third ran 35 minutes in the world until I stopped it.

What the shadow sync was finding (default mode, before #498)

Before that, I had counters inside the old single-threaded sync on the same base:

Phase Live shadows Read per sync Changed 4 KiB pages VirtualQuery Diff
Loading screen 146, 742 MiB 701 MiB 0.004 % 10 ms 45 ms
Loading into the world 7,549, 1,581 MiB 1,180 MiB 0.22 % 236 ms 82 ms
World 9,937, 1,831 MiB 1,867 MiB 0.25 % 105 ms 126 ms

What this says about the default mode:

  • Almost all clean: about 99.75 % of what each sync reads is unchanged since the previous batch.
  • VirtualQuery was half the cost: about half of the old sync in the world, which #498 now removes.
  • Little overlap: the shadows overlap by only about 15 % in the world, with no exact duplicates, so sharing them per range wouldn't help much.
  • Bandwidth-bound: the old diff alone read 28-31 GiB/s (guest plus baseline) on one core here. On this DDR4 host #498's parallel scan will run into a lower bandwidth ceiling than on DDR5; I haven't measured it yet.

So for RADV, not making the shadows, as this PR does, still looks like the real fix.

<!-- greyfinch-sync:brcly/TuxBox:comment:7260594403 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7260594403). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-29T18:34:48Z. --- I tested this with `TUXBOX_XMEM_PRIVATE_VIEWS=1` on my RX 9060 XT (RDNA 4, `1002:7590`, RADV, Mesa 26.2.6, GE-Proton11-14, Linux 6.18.60), Ryzen 7 5800X with dual-channel DDR4-3600, 32 GB RAM. To avoid a full shader prep I didn't build the branch as is. My base is `main` `6e2c5dab` with #441 (closed since in favour of #389, which has the same root-view change plus an NVIDIA check), with `runtime/xmem` and `runtime/xcrdapi` brought up to `fd636d09` and this PR (`f0dc9d98`) on top. The Lanes self-test passes in both modes. Since today's batch merge the branch no longer merges cleanly into `main` (`xcrdapi/src/queue.rs` and three XMem files). ### What changed Compared with the default mode on the same base: - **No shadows at all:** 0 ms of shadow sync per batch, and placement sees no section-backed pages. - **Loading:** matched by loading progress (the provider's placement count), 118-130 presents per 10 s against 75-94 in the first phase, 108-119 against 23-39 in the next, and 29-63 against 16-29 while the world loads. - **World:** 1.43 s per frame over the first 4.5 minutes, against 2.1 s per frame over the same span in the default mode, and 2.3 against 3.6 s per frame over the first 8.6 minutes, so about 1.5 times faster. After I moved the window to my other monitor it dropped to 1-3 frames per 11-25 s. I can't tell yet whether that was the move or the scene. - **Batch time:** direct batches took 29 % of wall time in the world instead of 65 %, and placement is now 90 % of what's left. - **Memory:** host memory went up, to 16.8 GiB RSS and 2.4 GiB of swap by the end, against 14.9 GiB and 0.9 GiB. ### How it ended It didn't get past the intro. It reached game time 6:14, and then died on a CPU write through a secondary alias: ``` TuxBox xmem: secondary alias 0x313ca0000 fault not promoted (err=170, write=true, token=0xc3d30, span=0x313c00000..0x313e00000, page_import_held=false, span_import_held=false, page_held=false, span_held=false, deferred=0) ``` The access violation followed on the same thread (write of `0x313cacf20` at `exe+0x4e95778`). The faulting alias's own span has no hold. So I think the `ERROR_BUSY` comes from the loop over the token's other views in `promote_token_to_section`, and `is_transient_promotion_hold` turned the retry down because one of those spans has an import hold or a deferred unmap. That would mean #456 is still reachable when a page's canonical backing is imported. I haven't confirmed which view blocked it, because the line only covers the faulting span; logging the blocking view's span and hold kind would show it. For comparison, of my default-mode runs on the same base that got that far, two ended on the title's hang watchdog at game time 3:00, and the third ran 35 minutes in the world until I stopped it. ### What the shadow sync was finding (default mode, before #498) Before that, I had counters inside the old single-threaded sync on the same base: | Phase | Live shadows | Read per sync | Changed 4 KiB pages | `VirtualQuery` | Diff | | --- | --- | --- | --- | --- | --- | | Loading screen | 146, 742 MiB | 701 MiB | 0.004 % | 10 ms | 45 ms | | Loading into the world | 7,549, 1,581 MiB | 1,180 MiB | 0.22 % | 236 ms | 82 ms | | World | 9,937, 1,831 MiB | 1,867 MiB | 0.25 % | 105 ms | 126 ms | What this says about the default mode: - **Almost all clean:** about 99.75 % of what each sync reads is unchanged since the previous batch. - **`VirtualQuery` was half the cost:** about half of the old sync in the world, which #498 now removes. - **Little overlap:** the shadows overlap by only about 15 % in the world, with no exact duplicates, so sharing them per range wouldn't help much. - **Bandwidth-bound:** the old diff alone read 28-31 GiB/s (guest plus baseline) on one core here. On this DDR4 host #498's parallel scan will run into a lower bandwidth ceiling than on DDR5; I haven't measured it yet. So for RADV, not making the shadows, as this PR does, still looks like the real fix.
DrArroway commented 2026-11-29 19:21:44 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T19:21:44Z.


@brcly Rebased onto main (2d6dc338), resolved the conflicts with #495 (MappingMutationGuard) and #508 (write_decoded_output, with XMem physical-access helpers moved to runtime/xcrdapi/src/access.rs so queue.rs stays under the 1,200-line hygiene limit), and force-pushed (cbb6a2df).

Re-ran full tuxbox.py check on both RX 6900 XT (1002:73bf: 126/126 Lanes & fixtures, 22/22 D3D12 regressions, 66/66 shader GPU) and AMD Raphael iGPU (1002:164e: 125/125 Lanes & fixtures, 22/22 D3D12 regressions, 66/66 shader GPU), plus the Wine unit tests, TUXBOX_XMEM_PRIVATE_VIEWS=1 buffer controls (5/5), and a 460.9s live ProjectScarlett run on 2d6dc338 (0 shadows, 0 secondary-alias errors, 0 xcrdapi failures). Ready for your NVIDIA check when you have a moment.

@gtb-sbe Thanks a lot for the RX 9060 XT test data and the shadow-sync breakdown — seeing 99.75% of shadow pages unchanged per sync really underlines why avoiding shadows under TUXBOX_XMEM_PRIVATE_VIEWS=1 is the right direction on RADV.

On the ERROR_BUSY secondary-alias fault you hit, I had hit the exact same failure pattern on a secondary-alias read (write=false) on RX 6900 XT, as well as a cross-VMA backing run issue across adjacent 4 MiB PrivateSpan allocations, so this rebased update also includes two fixes from that testing:

  1. PrivateSpan backing-run splitting (e0ea9a05): Keys BackingOrigin::PrivateView(span_id) by PrivateSpan base in runtime/xmem/src/physical_pages/backing.rs so adjacent OS allocations aren't merged into one cross-VMA userptr run.
  2. Read-fault PAGE_READONLY mirror + blocker= diagnostic (09b0ff35): For !write faults where promote_token_to_section returns ERROR_BUSY, mirror_readonly_secondary_alias populates the unheld secondary alias as PAGE_READONLY (keeping it in secondary_aliases so any subsequent write still traps to promote). Both log_veh_failure and log_readonly_fallback now also log the exact blocker view/span and hold kind you asked for: [email protected](page_imp=...,span_imp=...,span_held=...,def=...).

Since TUXBOX_XMEM_PRIVATE_VIEWS=1 stays opt-in here, handling write=true when the canonical span is held (once blocker= confirms whether that exe+0x4e95778 write hit a sibling page in the 4 MiB PrivateSpan with page_imp=false, span_imp=true or a held canonical page with page_imp=true) can cleanly land in a focused follow-up PR without blocking the #495/#508 rebase.

<!-- greyfinch-sync:brcly/TuxBox:comment:7261218479 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7261218479). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T19:21:44Z. --- @brcly Rebased onto `main` (`2d6dc338`), resolved the conflicts with #495 (`MappingMutationGuard`) and #508 (`write_decoded_output`, with XMem physical-access helpers moved to `runtime/xcrdapi/src/access.rs` so `queue.rs` stays under the 1,200-line hygiene limit), and force-pushed (`cbb6a2df`). Re-ran full `tuxbox.py check` on both RX 6900 XT (`1002:73bf`: 126/126 Lanes & fixtures, 22/22 D3D12 regressions, 66/66 shader GPU) and AMD Raphael iGPU (`1002:164e`: 125/125 Lanes & fixtures, 22/22 D3D12 regressions, 66/66 shader GPU), plus the Wine unit tests, `TUXBOX_XMEM_PRIVATE_VIEWS=1` buffer controls (5/5), and a 460.9s live ProjectScarlett run on `2d6dc338` (`0` shadows, `0` secondary-alias errors, `0` `xcrdapi` failures). Ready for your NVIDIA check when you have a moment. @gtb-sbe Thanks a lot for the RX 9060 XT test data and the shadow-sync breakdown — seeing `99.75%` of shadow pages unchanged per sync really underlines why avoiding shadows under `TUXBOX_XMEM_PRIVATE_VIEWS=1` is the right direction on RADV. On the `ERROR_BUSY` secondary-alias fault you hit, I had hit the exact same failure pattern on a secondary-alias **read** (`write=false`) on RX 6900 XT, as well as a cross-VMA backing run issue across adjacent 4 MiB `PrivateSpan` allocations, so this rebased update also includes two fixes from that testing: 1. **`PrivateSpan` backing-run splitting (`e0ea9a05`):** Keys `BackingOrigin::PrivateView(span_id)` by `PrivateSpan` base in `runtime/xmem/src/physical_pages/backing.rs` so adjacent OS allocations aren't merged into one cross-VMA userptr run. 2. **Read-fault `PAGE_READONLY` mirror + `blocker=` diagnostic (`09b0ff35`):** For `!write` faults where `promote_token_to_section` returns `ERROR_BUSY`, `mirror_readonly_secondary_alias` populates the unheld secondary alias as `PAGE_READONLY` (keeping it in `secondary_aliases` so any subsequent write still traps to promote). Both `log_veh_failure` and `log_readonly_fallback` now also log the exact blocker view/span and hold kind you asked for: `[email protected](page_imp=...,span_imp=...,span_held=...,def=...)`. Since `TUXBOX_XMEM_PRIVATE_VIEWS=1` stays opt-in here, handling `write=true` when the canonical span is held (once `blocker=` confirms whether that `exe+0x4e95778` write hit a sibling page in the 4 MiB `PrivateSpan` with `page_imp=false, span_imp=true` or a held canonical page with `page_imp=true`) can cleanly land in a focused follow-up PR without blocking the #495/#508 rebase.
gtb-sbe commented 2026-11-29 19:57:41 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-29T19:57:41Z.


Thanks! The blocker= line is exactly what I was missing. I'll run the rebased branch (cbb6a2df) with TUXBOX_XMEM_PRIVATE_VIEWS=1 on my RX 9060 XT and post the line if the write fault comes back.

For the default mode, there's news on #472: with #474, #475, #495 and #498 on my old base, the intro got past the point where it always died here. Frames went from ~21 s to ~12 s, and the game clock reached 11:28 instead of the watchdog ending it at 3:00. The numbers are in my comment there.

<!-- greyfinch-sync:brcly/TuxBox:comment:7261695266 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7261695266). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-29T19:57:41Z. --- Thanks! The `blocker=` line is exactly what I was missing. I'll run the rebased branch (`cbb6a2df`) with `TUXBOX_XMEM_PRIVATE_VIEWS=1` on my RX 9060 XT and post the line if the write fault comes back. For the default mode, there's news on #472: with #474, #475, #495 and #498 on my old base, the intro got past the point where it always died here. Frames went from ~21 s to ~12 s, and the game clock reached 11:28 instead of the watchdog ending it at 3:00. The numbers are in my comment there.
Kayotic1337 commented 2026-11-29 20:24:15 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-29T20:24:15Z.


Tested on an RX 9070 XT (1002:7550, 16 GB, RDNA 4), RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6, Ryzen 7 9800X3D, 32 GB RAM, with TUXBOX_XMEM_PRIVATE_VIEWS=1. Story save, offline. The host profile reports section-import=substituted.

Build Cache Ran End
fd636d09 without #501, default section backing cold 1842 s in the world at about 0.15 fps, then a GPU fault on a sparse image tile
fd636d09 + #501 before the rebase (f0dc9d98) + #498 warm 248 s title access violation, null read at +0x10 in the title's code; no GPU fault, no vkd3d memory fallback
2d6dc338 + #501 (cbb6a2df) cold 1299 s GPU page fault on a compute ring after vkd3d fell back to system memory
2d6dc338 + #501 (cbb6a2df) warm 185 s GPU hang (signaller_worker wait timed out) after the same fallback, then the title watchdog

What #501 changes here:

  • Menus and loading are fast again (about 300 presents per 10 s, up to 1,600 in the menu), and in the submit profile placement is no longer the limit. Over the last ~4 minutes of the cold run, the direct queue spent about 26 s in batches, 19 s of it in placement, against about 156 s of gap. Without #501, placement was about half of every queue's batch time.
  • The access violation from the pre-rebase head did not come back in the two runs on cbb6a2df. Two runs isn't enough to call it gone.
  • It doesn't keep the world running longer on this card: with a warm cache the run still ends about 3 minutes in, now on memory. In the world it renders a few incomplete frames below 1 fps, and placed texture readback reaches 2.4–3.6 GB per 5 s. Details and numbers are on #292: https://github.com/brcly/TuxBox/issues/292#issuecomment-7261995024
<!-- greyfinch-sync:brcly/TuxBox:comment:7262051926 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7262051926). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-11-29T20:24:15Z. --- Tested on an RX 9070 XT (`1002:7550`, 16 GB, RDNA 4), RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6, Ryzen 7 9800X3D, 32 GB RAM, with `TUXBOX_XMEM_PRIVATE_VIEWS=1`. Story save, offline. The host profile reports `section-import=substituted`. | Build | Cache | Ran | End | | --- | --- | --- | --- | | `fd636d09` without #501, default section backing | cold | 1842 s | in the world at about 0.15 fps, then a GPU fault on a sparse image tile | | `fd636d09` + #501 before the rebase (`f0dc9d98`) + #498 | warm | 248 s | title access violation, null read at +0x10 in the title's code; no GPU fault, no vkd3d memory fallback | | `2d6dc338` + #501 (`cbb6a2df`) | cold | 1299 s | GPU page fault on a compute ring after vkd3d fell back to system memory | | `2d6dc338` + #501 (`cbb6a2df`) | warm | 185 s | GPU hang (`signaller_worker wait timed out`) after the same fallback, then the title watchdog | What #501 changes here: - Menus and loading are fast again (about 300 presents per 10 s, up to 1,600 in the menu), and in the submit profile placement is no longer the limit. Over the last ~4 minutes of the cold run, the direct queue spent about 26 s in batches, 19 s of it in placement, against about 156 s of gap. Without #501, placement was about half of every queue's batch time. - The access violation from the pre-rebase head did not come back in the two runs on `cbb6a2df`. Two runs isn't enough to call it gone. - It doesn't keep the world running longer on this card: with a warm cache the run still ends about 3 minutes in, now on memory. In the world it renders a few incomplete frames below 1 fps, and placed texture readback reaches 2.4–3.6 GB per 5 s. Details and numbers are on #292: https://github.com/brcly/TuxBox/issues/292#issuecomment-7261995024
NickStallman commented 2026-11-29 20:53:58 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T20:53:58Z.


NVIDIA run: full python tuxbox.py check passes on an RTX 5090 (10de:2b85, 620.70.10, GE-Proton11-14, Linux, windows-dxc 1.8.2505.1).

Tree Pass Fail
main 2d6dc338 (control, same card and prefix) 192 0
cbb6a2df (its base is 2d6dc338) 192 0

No GPU errors in the kernel log. That's the default mode; I haven't run TUXBOX_XMEM_PRIVATE_VIEWS=1 here, or the game. Main has moved since (4198b48c); I checked the PR's head, not a merge with that.

<!-- greyfinch-sync:brcly/TuxBox:comment:7262444994 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7262444994). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T20:53:58Z. --- NVIDIA run: **full `python tuxbox.py check` passes** on an RTX 5090 (`10de:2b85`, 620.70.10, GE-Proton11-14, Linux, `windows-dxc` 1.8.2505.1). | Tree | Pass | Fail | |---|---|---| | `main` 2d6dc338 (control, same card and prefix) | 192 | 0 | | cbb6a2df (its base is 2d6dc338) | 192 | 0 | No GPU errors in the kernel log. That's the default mode; I haven't run `TUXBOX_XMEM_PRIVATE_VIEWS=1` here, or the game. Main has moved since (4198b48c); I checked the PR's head, not a merge with that.
DrArroway commented 2026-11-29 21:41:20 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T21:41:20Z.


@NickStallman Thanks for running the RTX 5090 tuxbox.py check verification on cbb6a2df (192/192 pass)!

@gtb-sbe @brcly We also caught the exact blocker= diagnostic for that write=true #456 secondary-alias fault on RX 6900 XT (after running 584.7s / 15,653 presents with 0 GPUVM faults and 0 shadows under TUXBOX_XMEM_PRIVATE_VIEWS=1):

TuxBox xmem: secondary alias 0x878580000 read mirrored as PAGE_READONLY (token=0x74610, [email protected](page_imp=false,span_imp=true,span_held=true,def=0))
TuxBox xmem: secondary alias 0x878580000 fault not promoted (err=170, write=true, token=0x74610, span=0x878540000..0x878800000, page_import_held=false, span_import_held=false, page_held=false, span_held=false, deferred=0, [email protected](page_imp=false,span_imp=true,span_held=true,def=0))

Note the blocker span 0xf00200000..0x1085e00000: it is a 6.09 GiB single PrivateSpan created by map_private_contiguous (runtime/xmem/src/physical_pages/private_views.rs), which uses private_span_bounds without splitting multi-chunk contiguous ranges into PRIVATE_SPAN_CHUNK (4 MiB) spans. As a result, a single GPU import hold anywhere inside that 6.09 GiB contiguous reservation holds the entire PrivateSpan (span_imp=true) and blocks promoting an unheld page (page_imp=false) at 0xf3c900000.

Chunking map_private_contiguous into PRIVATE_SPAN_CHUNK spans (plus isolating/handling held canonical pages if needed) looks like the clean follow-up once #501 lands.

<!-- greyfinch-sync:brcly/TuxBox:comment:7263071809 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7263071809). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T21:41:20Z. --- @NickStallman Thanks for running the RTX 5090 `tuxbox.py check` verification on `cbb6a2df` (192/192 pass)! @gtb-sbe @brcly We also caught the exact `blocker=` diagnostic for that `write=true` `#456` secondary-alias fault on RX 6900 XT (after running 584.7s / `15,653` presents with `0` GPUVM faults and `0` shadows under `TUXBOX_XMEM_PRIVATE_VIEWS=1`): ```text TuxBox xmem: secondary alias 0x878580000 read mirrored as PAGE_READONLY (token=0x74610, [email protected](page_imp=false,span_imp=true,span_held=true,def=0)) TuxBox xmem: secondary alias 0x878580000 fault not promoted (err=170, write=true, token=0x74610, span=0x878540000..0x878800000, page_import_held=false, span_import_held=false, page_held=false, span_held=false, deferred=0, [email protected](page_imp=false,span_imp=true,span_held=true,def=0)) ``` Note the blocker span `0xf00200000..0x1085e00000`: it is a **6.09 GiB** single `PrivateSpan` created by `map_private_contiguous` (`runtime/xmem/src/physical_pages/private_views.rs`), which uses `private_span_bounds` without splitting multi-chunk contiguous ranges into `PRIVATE_SPAN_CHUNK` (4 MiB) spans. As a result, a single GPU import hold anywhere inside that 6.09 GiB contiguous reservation holds the entire `PrivateSpan` (`span_imp=true`) and blocks promoting an unheld page (`page_imp=false`) at `0xf3c900000`. Chunking `map_private_contiguous` into `PRIVATE_SPAN_CHUNK` spans (plus isolating/handling held canonical pages if needed) looks like the clean follow-up once `#501` lands.
brcly commented 2026-11-29 22:13:28 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T22:13:28Z.


Merged as 22e529cb on main (squashed into one commit). The full check passed on an RTX 4070 Ti SUPER and a Radeon 610M. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7263503692 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/501#issuecomment-7263503692). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T22:13:28Z. --- Merged as 22e529cb on `main` (squashed into one commit). The full check passed on an RTX 4070 Ti SUPER and a Radeon 610M. Thanks!

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
brcly/TuxBox!501
No description provided.