Skip to content

kernelx: XCL_PAGE_ALIAS=1 shows a physical page at every address it is mapped at - #2307

Open
adiologydev wants to merge 4 commits into
xcl-dev:mainfrom
adiologydev:kernelx/page-alias
Open

adiologydev wants to merge 4 commits into
xcl-dev:mainfrom
adiologydev:kernelx/page-alias

Conversation

@adiologydev

@adiologydev adiologydev commented Nov 25, 2026 •

Copy link
Copy Markdown

Stacked on #2294; only the top commit (f30ca3f) belongs here. Third part of the plan on #1031: behind XCL_PAGE_ALIAS=1 (off by default), a physical page shows at every address the title maps it at.

Measured in a traced run of a retail title first (local logging, not in the PR): it allocates 3 blocks of physical pages (11 360, 2 960 and 99 776 pages), and in 150 s makes 131 072 map calls, nearly all single pages, into its plain reservations of 64 KiB pages (the CPU view of its 24 GB pair and its 6.2 GB pool) – never at a page's home, and it never commits memory of its own inside them. 5 calls (2 960 pages) go into a placeholder region it made in a sparse window.

What is in it (f30ca3f)

  • crates/xcl/src/hle/kernelx/alias.rs (new), with XCL_PAGE_ALIAS=1:
    • a block of physical pages is a section (kernelx: physical pages as section slices that can be mapped at many addresses #2293) with a view of its own, through which XCL reads and writes pages by number (DirectStorage); homes are plain address space, not the sparse windows, since the title never maps a page there;
    • the title's reservations of 64 KiB pages with no commit (CPU view, GPU view, pool) are placeholders; a page mapped there is a view of its slice, guarded (kernelx: catch CPU writes to the views of physical pages, page by page #2294), so a write through one view is uploaded at all of them;
    • a page mapped anywhere else is moved there and back with its bytes, as without the switch;
    • whether a page is committed is a bit per page: asking Windows walked the rest of a fresh block, and 100 000 single-page maps delayed the first frame by 20 s;
    • 5 unit tests.
  • crates/xcl/src/hle/kernelx.rs: the switch in VirtualAlloc / VirtualFree(Ex), Allocate/Free/MapTitlePhysicalPages, XMemMapPhysicalPagesScatter, read/write_physical_pages, physical_page_at; a commit inside such a reservation is refused (never seen) with a warning.
  • d3d12x/title_textures.rs: the guarded pages join what the write watch found. lazy.rs: a view the lazy handler commits sets its bit. sections.rs: release_all.

Tested

  • NVIDIA GeForce RTX 5090 32 GB (driver 621.40), AMD Ryzen 9 7950X, 64 GB RAM, Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2609 (XCL_DXC_DIR), debug tests, release runs.

  • cargo test --workspace -- --test-threads=4 on f30ca3f: 1114 passed, 4 failed, 26 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState → E_OUTOFMEMORY on this card, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905); main 568e7db fails the same 4 here (1094 passed, 4 failed, 26 ignored). SKIPPED (23, the same on main): 20 need 64-lane waves ("no wave64"), 3 per-lane f16 refusals in lower_dxil::tests::{f16,f32}_programs_on_the_gpu.

  • The retail title with XCL_PAGE_ALIAS=1, against main 568e7db, the same route into its world (pad A at the account prompt, A A at the title screen), 240 s each, runs interleaved (the pipeline cache warms with every run):

    run (in order) frames in 240 s peak commit last frame before the cold pipeline compiles ([OFFICIAL] Swarm: cold PSO compilation to first playable frame #2088) crashes / device removals
    XCL_PAGE_ALIAS=1 (f30ca3f) 4 516 23 525 MB 180 s 0 / 0
    main 568e7db 5 001 30 813 MB 192 s 0 / 0
    main 568e7db 4 085 31 855 MB 160 s 0 / 0
    XCL_PAGE_ALIAS=1 (f30ca3f) 4 252 24 341 MB 168 s 0 / 0

    About 7 GB less peak commit with the switch; frames and the time of the last frame are within the run-to-run spread (an earlier single pair showed more frames with the switch; it did not hold up here).

Regression run (the switch off, as the PR checks run it)
scripts/smoke.ps1 -Game <retail title> -Seconds 60, no input, main first, same machine (each run's xcl.exe built from a clean checkout of its commit):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5090
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1015 (PresentX 1015)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16257 MB
xcl-smoke v1
commit: f30ca3f037e474fe1ca1720835313db161b36004
gpu: NVIDIA GeForce RTX 5090
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1530 (PresentX 1530)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15857 MB

Not tested

AI use

  • Claude Code (Claude Opus 5.5): wrote the code, the tests and this description, and made the runs above on this hardware. I read every line of the diff and checked it.

…addresses

On the console a physical page mapped at several addresses is one page. XCL
keeps a page at one address at a time and copies it when the title maps it
elsewhere (`move_away`), so the other addresses go stale; a retail title maps
its streamed pages into a pool, into the CPU view of a 24 GB reservation and
into that reservation's GPU view (xcl-dev#1031).

`kernelx::sections` is the base for real aliasing: a block of physical pages
is one pagefile-backed SEC_RESERVE section, and a page is mapped as a view of
its 64 KiB slice into a placeholder (MapViewOfFile3 with
MEM_REPLACE_PLACEHOLDER). Every view of a slice is the same memory and a page
takes commit once, when it is committed through any view. Unmapping leaves a
placeholder for the next view. Ordinary reserved memory (write-watched if
asked) can replace part of a placeholder and go back to one.

Nothing calls it yet. Measured in a standalone program on Windows 11 26200
over 200 000 pages: map 2.2 us, unmap 2.75 us, commit 0.9 us a page.
GetWriteWatch refuses a range that holds a view (error 87), and one call
cannot span two neighbouring reservations either.
The upload of title memory to video memory (`d3d12x::sparse`) and the
textures kept in step with title memory learn what the CPU wrote from the
write watch, and a view of a section (`kernelx::sections`) cannot be
write-watched: GetWriteWatch refuses any range that holds one.

`kernelx::guards` keeps the views of a physical page read-only. The first
write through any of them faults; a vectored handler makes that view
writable, notes the page and lets the write go on. `take_dirty` hands over
the pages of every view of each page written – a write through one view is
a write to all of them – and guards those views again before their bytes are
read, so a later write is caught again and an earlier one is in what is read.

Kernel calls do not fault into the handler, they fail: `lazy::ensure`, which
XCL already calls before a kernel call or its own code writes title memory,
opens the guards there first and counts the write. A view committed by the
lazy handler is writable and counts as written. Both take no lock until a
view has been watched.

Nothing watches a view yet.
… fault

A guarded view of a physical page (`kernelx::guards`) is read-only until it
is written. Code of XCL's own that writes there faults into the guard and
goes on, but a kernel call does not fault: ReadFile into such a view fails.
`lazy::ensure` opened the views first, yet the submit thread's `take_dirty`
could guard them again before the write – between DirectStorage's check of
its destination and the copy, or before the kernel wrote a ReadFile buffer.

`guards::open` now returns `Opened`, which keeps its views writable until it
is dropped; `take_dirty` uploads a pinned view but does not guard it again,
and the end of the write counts as a write. `lazy::ensure` returns it and its
callers hold it across their write: the routed ReadFile for a synchronous
read, and the destination checks of DirectStorage and the CPU-side
bottom-of-pipe writes. An overlapped ReadFile writes after the call returns:
its views stay open until its OVERLAPPED is no longer STATUS_PENDING, which
`take_dirty` reads without faulting (the title may free it once done). A
retail title reads 271 MB that way into the CPU view of its 24 GB
reservation 8.5 s after start.

`guards::written` counts a page as written through all its views when XCL
writes it by page number.

Nothing watches a view yet, so nothing changes without views.
…s mapped at

Without it XCL keeps a physical page at one address at a time and copies it
when the title maps it elsewhere; the console shows the page at every
address it is mapped at. A retail title maps its streamed pages into a pool,
into the CPU view of a 24 GB reservation and into that reservation's GPU
view (xcl-dev#1031).

With `XCL_PAGE_ALIAS=1` (`kernelx::alias`):
- a block of physical pages is a section (`kernelx::sections`) with a view
  of its own, through which XCL reads and writes pages by number
  (DirectStorage); the title never maps a page there;
- the title's reservations of 64 KiB pages with no commit (its CPU view, GPU
  view and pool) are placeholders, and a page mapped there is a view of its
  slice, guarded (`kernelx::guards`) so that a write through one view is
  uploaded at all of them; `title_textures` adds those pages to what the
  write watch found;
- a page mapped anywhere else (a placeholder region the title made in a
  sparse window) is moved there and back with its bytes, as before.

Pages are committed on first use as before (`kernelx::lazy`); whether a page
is committed is a bit per page: asking Windows walked the rest of a fresh
block, and a title mapping 100 000 new pages one at a time took 20 s longer
to its first frame.

Measured in a traced run of a retail title: 3 blocks (11 360, 2 960 and
99 776 pages), 131 072 map calls in 150 s, nearly all single pages into its
plain reservations, none at a page's home, no commit inside them.
@SlopTart

SlopTart commented Nov 25, 2026 •

Copy link
Copy Markdown

Tested: head f30ca3f merged onto current origin/main (auto-merge, clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). Note the branch carries its open ancestors (#2294, #2293) on top of main, same as it will when reviewed.

Default (switch off): gpu_ suite 141 passed / 4 failed / 1 ignored. Three are the rig's known baseline (fuzz seed 1003 of #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed); the fourth, gpu_geometry_wave32_prefix_count_over_a_mask, is this rig's known flaky family: solo reruns 3/3 green on this branch, and plain origin/main reproduces the same failure under the same conditions. Not attributable to this change.

With XCL_PAGE_ALIAS=1: the alias tests added by the top commit fail on this lane, deterministically (2/2 reruns, --test-threads=1):

  • a_page_mapped_into_two_spaces_is_one_page_and_writes_reach_both FAILED
  • a_page_moved_outside_the_spaces_goes_and_comes_back_with_its_bytes FAILED
  • pages_read_and_written_by_number_are_the_pages_the_title_sees FAILED
  • a_page_not_from_the_title_is_refused ok, remapping_an_address_shows_the_new_page_and_keeps_the_old_one ok

On the #2308 branch, which carries these same alias tests unmodified apart from one added test, flag-off runs also fail at real assertion lines (alias.rs:452, alias.rs:495, alias.rs:518), so this is not just switch gating. These are in-process unit tests (0.03 s), not timing-sensitive game runs, so the red looks like a real behavior difference on the Wine/vkd3d-proton lane rather than flakiness.

Not tested: native Windows CI behavior (upstream CI presumably sees these green, so the delta is lane-specific); retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@nnonno91

Copy link
Copy Markdown

Native Windows check of f30ca3f037e474fe1ca1720835313db161b36004. The alias unit tests pass here. The existing mirror upload test stops at a write-watch setup assertion when aliasing is enabled.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62, SDK DXC/DXIL 1.8.2502.11.
  • cargo test --locked -p xcl --lib hle::kernelx::alias::tests:: -- --nocapture --test-threads=1 with XCL_PAGE_ALIAS unset and 1 in separate processes gave 5 passed, 0 failed each.
  • Same command with filter gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes and XCL_ADAPTER=AMD Radeon. Unset: 1 passed, 0 failed. With 1: 0 passed, 1 failed at title_textures.rs:1287, fallback must be write-watched. The log confirmed the Radeon. The assertion is in the test reservation setup, before the texture readback. No skips or ignores.

Not tested

A mirror readback using an alias-aware fixture, Wine, retail smoke, and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@tiagonleal

Copy link
Copy Markdown
Contributor

Tested: PR #2307 at head f30ca3f037e474fe1ca1720835313db161b36004, release build, Newer Retail Game, 6 guarded runs of 300 s on one Windows machine, XCL_PAGE_ALIAS unset (A) vs XCL_PAGE_ALIAS=1 (B), n=3 each. In short: peak process commit 25.0 to 25.7 GB with the switch against 30.2 to 32.4 GB without, total system commit only about 1 GB lower, no device removal or crash in either, and the one run my memory guard cut was without the switch.

Setup

  • Windows 11 Pro 10.0.26300, Developer Mode on, NVIDIA GeForce RTX 5070 Ti 16 GB, driver 617.42 (32.0.16.1742), Ryzen 7 9800X3D, 32 GB RAM.
  • One binary (cargo build --release -p xcl at the head above), copied under a new exe name for every run (the driver keeps a shader cache per exe name).
  • Env, the same for all six except the switch: XCL_DIRECT_DXIL=1 XCL_PSO_PRELOAD=0 XCL_FRAME_DUMP=60 XCL_PRESS_A_AT=15,22,25,30,35,40,50,60,80,100, XCL_DXIL_CACHE = the same warm cache folder; B adds XCL_PAGE_ALIAS=1. The log also shows XCL_NETWORK=0.
  • Memory guard (my own, outside XCL): it kills the process if free physical RAM drops below 1.0 GB, process commit goes above 70 GB, free commit below 6 GB, or the NVIDIA driver logs a reset event.
  • Order: A1, B1, B2, A2, A3, B3. An earlier attempt was discarded because of a bug in my launcher; it is not in the table. Read-only sampler every 1 to 2 s (memory, GPU memory), process census every 5 s.

Results (MB unless noted; times are seconds from the start of the run; "process commit" = the memory: log line, "private" and "WS" = sampler)

Run Free RAM at start System commit at start Peak process commit Peak private Peak WS Min free RAM (at s) Peak system commit Peak local VRAM Ended Frames shown Presents/s, 60 s to end Last present (s) First ListX #101 (s)
A1 17948 24688 31269 31298 16479 1467 (303) 56604 13891 300 s 1362 0.61 68 65.9
B1 18821 24709 25160 25113 14928 1940 (293) 55648 12726 300 s 1480 0.99 74 71.5
B2 19106 24810 25041 25112 15101 1649 (291) 56356 12544 300 s 1419 0.75 70 67.8
A2 19016 24843 30171 (to 156 s) 30211 15559 974 (155) 57701 13889 cut by guard at 156 s n/a 1.49 (60 to 150 s) 66 49.2
A3 19414 24352 32401 32147 17289 1401 (294) 57007 13820 300 s 1318 0.38 66 64.2
B3 19756 24273 25659 25694 15738 1978 (301) 55791 12484 300 s 1413 0.77 70 65.0

All six: 0 device removals, 0 crashes, 0 driver events, no ERROR lines. Peak private working set (not in the table): A 16317 / 15400 / 17122, B 11315 / 11595 / 12091.

Not a measure of "world entry": the title never got past loading in any run. All six stop presenting between about 66 and 74 s and show 0 presents for the rest of the 300 s. I use the first ListX #101 stub line as the marker; the log's "target pages above 5 GB" line is at 48.0 s in all six runs, so it does not separate anything.

Log content: the same 25 to 26 WARN types in every run, no type present only in A or only in B. Counts: 80 / 77 (cut at 156 s) / 79 WARN lines in A, 77 / 79 / 77 in B. 40 "mesh pipeline ... refused" lines in each run. DirectStorage "request failed" lines: A 3 / 0 / 2, B 0 / 2 / 0 (different files each run). No log line mentions the switch; the 16 "CreatePlacedResourceX ... aliases an earlier resource" lines are in A and B alike.

Reading

  • With the switch, peak process commit was 25.0 to 25.7 GB against 30.2 to 32.4 GB without; the ranges do not overlap (n=3 each). Private working set and local VRAM peak were also lower (VRAM 12.5 to 12.7 GB against 13.8 to 13.9 GB).
  • Total system commit only dropped by about 1 GB (55.6 to 56.4 GB against 56.6 to 57.7 GB). The one process census I looked at with the switch on (B1) shows about 188,000 mapped section views holding about 12.4 GB of commit, so part of the process saving moves into mapped sections.
  • Lowest free RAM was 1.65 to 1.98 GB with the switch and 0.97 to 1.47 GB without. Run A2 was cut by my guard at 156 s because free RAM fell to 0.94 GB, under my own 1 GB threshold on this 32 GB machine; that says nothing about a machine with more RAM or a different threshold.
  • The title kept presenting until 66 to 68 s (A) and 70 to 74 s (B), then stopped in every run, within a few seconds of its first ListX #101 call. I do not read anything into that difference with n=3.

Frames: I looked at the frame dumps of all six runs (XCL_FRAME_DUMP=60). They show a loading-screen artwork slideshow and black frames; same frame number is not the same moment of the slideshow. Picture not compared.

Not tested

  • Full workspace test suite. Only cargo test -p xcl --lib kernelx -- --test-threads=4: 60 passed, 0 failed, 1 ignored (scatter_timing), 0 skipped. That filter does not include the GPU mirror upload tests, which another tester reported failing with the switch on.
  • Picture (see above), AMD, runs longer than 300 s, anything past the loading screen.
  • Current main: it has moved by more than 100 commits since the base this branch was built on (568e7db); I ran the head as it is.
  • One machine, order fixed (not randomised), n=3 per variant.

Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…sing stack)

Integrates upstream PR stack xcl-dev#2293 -> xcl-dev#2294 -> xcl-dev#2307 -> xcl-dev#2308 (opt-in real section-slice physical page aliasing across virtual views via XCL_PAGE_ALIAS=1).
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@claudetools-gh

claudetools-gh commented Nov 25, 2026 •

Copy link
Copy Markdown

@adiologydev a data point from the retail title on an RTX 5070 Ti that may point at this PR. With XCL_PAGE_ALIAS=1, the title hits an int3 in its resource pointer fix-up; without it, the same run got past that point. One run each, so treat it as a lead, not a proof.

What the int3 is. It is at game_scarlett_master.exe+0x4da6315. The function there takes a table of {base, size, delta} ranges and one pointer value. It returns the delta of the range the pointer falls in. If the pointer falls in none of them, it executes int3 and returns 0.

Its caller fixes up a pointer that sits inside a loaded resource. Its value should be a resource-relative address: 0x5xxxxxxx for virtual or 0x6xxxxxxx for physical. At the crash, r11 is the first range's base (0x50000000 or 0x60000000). The pointer being fixed up was garbage:

run crashed at pointer value
1 197 s 0xCBCBCBCB… (in rdx and rdi)
2 129.7 s 0x799171
3 158 s 0xb2ac626837eab3e

So the resource's bytes are not what was read from the file when the title walks them. Either they were never written, or they were written where the CPU is not looking. Our game crash logs put it during the intro's streaming ("Prestream").

The A/B. The tree is main 2898511 + #2372 + #2404 + #2426 + #2384 + local GPU-view windows. Common settings: XCL_DIRECT_DXIL=1 XCL_UMA_SHADOW=1 XCL_NETWORK=0; RT resolve programs refused.

XCL_PAGE_ALIAS=1 XCL_TEXTURE_LEVEL_PAGES=1 neither switch
int3 above at 129.7 s, right after world geometry first reached the depth target none by 265 s
world on the 2560×1440 targets depth 50 %, G-buffer 38–41 % (122 s) depth 84 %, G-buffer 66 % (151 s)
local video memory also over budget: 21 GB at 120 s, peaks of 29 GB (two later runs with the same settings; I first wrote "in budget" here without having checked) 27 GB at 116 s, 36 GB at 256 s, against a 14.7 GB budget

Without the switches, the over-budget video memory went into system RAM. I stopped the run at 265 s with 0.4 GB of RAM free; a repeat was stopped at 134 s at 35 GB. With the switches the run is over budget too, but system RAM held: a later run lasted 304 s.

The earlier runs with the same int3 (158 s and 197 s) also had XCL_PAGE_ALIAS=1.

Update: a later run with XCL_PAGE_ALIAS=1 XCL_TEXTURE_LEVEL_PAGES=1 and the same settings went 304 s with no int3. It ended in a different title crash, a write to address 0. Two more stopped earlier, on device removals at 88 s and 120 s. So the int3 comes and goes, and one run without the switches is not enough to pin it on this PR. I am logging the page history at the crash and will post that when the int3 shows again.

What I have not checked:

  • which of the two switches matters;
  • whether the bad resource came in through DirectStorage (its requests here go to "physical pages" destinations) or through a plain file read;
  • whether the CPU sees a page that was mapped again after the request was queued.

If you have a trace switch for "a page shown at an address got new contents through another mapping", I can run it.

AI-assisted.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2307 at head f30ca3f037e474fe1ca1720835313db161b36004 (4 commits stacked on PR #2293 + PR #2294: 03ceddb0be3d06287ca21ae800dbb0d7f98049e7 -> 6602a7020122f508f72fed942286f488e3bd1bb9 -> d660e3070bef6e3ae095393dc134ecd517ab4a35 -> f30ca3f037e474fe1ca1720835313db161b36004; exact parent & merge-base: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (f30ca3f0)

Command Result
cargo test --release -p xcl --lib hle::kernelx::alias:: -- --test-threads=1 --nocapture (default env, 3 runs) 5 passed; 0 failed; 0 ignored; 1139 filtered out × 3 (0.02s × 3, 0 skipped: a_page_mapped_into_two_spaces_is_one_page_and_writes_reach_both, a_page_moved_outside_the_spaces_goes_and_comes_back_with_its_bytes, a_page_not_from_the_title_is_refused, pages_read_and_written_by_number_are_the_pages_the_title_sees, remapping_an_address_shows_the_new_page_and_keeps_the_old_one)
cargo test --release -p xcl --lib hle::kernelx:: -- --test-threads=1 (default env, 3 runs) 58 passed; 0 failed; 1 ignored; 1085 filtered out × 3 (1.15s, 1.14s, 1.15s, 0 skipped)
XCL_PAGE_ALIAS=1 cargo test --release -p xcl --lib hle::kernelx:: -- --test-threads=1 (opt-in env, 3 runs) 49 passed; 9 failed; 1 ignored; 1085 filtered out × 3 (0.97s, 0.98s, 0.98s; all 5 alias::, 8 guards::, 7 sections::, and 2 lazy:: tests pass; see note below on the 9 pre-existing UMA-home unit tests)
cargo build --release -p xcl Clean build (1m 14s, exit 0, 0 new warnings in non-test build; inherits 1 unused_assignments #[cfg(test)] warning from stacked #2294 at crates/xcl/src/hle/kernelx/guards.rs:366:9)

Observation on hle::kernelx:: under process-wide XCL_PAGE_ALIAS=1: All 58/58 tests pass 3/3 in the default environment. With XCL_PAGE_ALIAS=1 set process-wide, all 22 alias::/guards::/sections::/lazy:: tests pass 3/3, while 9 pre-existing UMA-home tests in hle::kernelx::tests:: fail deterministically (3/3): 7 (a_home_decommitted_in_the_same_call_is_asked_again, a_page_away_at_another_home_goes_home_with_it, a_page_away_from_home_is_committed_once, mapping_fresh_pages_does_not_query_each_page, mapping_lazy_pages_again_does_not_query_each_page, pages_mapped_again_at_another_address_keep_what_was_written, pages_mapped_again_at_the_same_address_keep_what_was_written) panic on page_home(...).unwrap() returning None (because XCL_PAGE_ALIAS=1 backs physical pages with section slices instead of UMA homes), and 2 (physical_pages_in_uma at kernelx.rs:2371 and scatter_matches_a_model_of_physical_pages at kernelx.rs:2624) expect MapTitlePhysicalPages(NULL, ...) to return a UMA-home address.

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (568e7db7729c8fa6c8f0f4b32d798faaf11462bb, cached baseline on the same machine):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14527 MB

PR #2307 (f30ca3f037e474fe1ca1720835313db161b36004, default flags — XCL_PAGE_ALIAS unset):

xcl-smoke v1
commit: f30ca3f037e474fe1ca1720835313db161b36004
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14515 MB

PR #2307 (f30ca3f037e474fe1ca1720835313db161b36004, opt-in XCL_PAGE_ALIAS=1):

xcl-smoke v1
commit: f30ca3f037e474fe1ca1720835313db161b36004
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1558 (PresentX 1558)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13150 MB

Observations & limits of coverage

  • Both default (XCL_PAGE_ALIAS unset) and opt-in (XCL_PAGE_ALIAS=1) 60 s retail smokes on title: 29640639 exited 0x0 with 0 device removals, 0 crashes, and steady 60 60 60 presents per 2 s; under XCL_PAGE_ALIAS=1, peak process commit dropped from 14515 MB to 13150 MB (-1365 MB, -9.4% vs. default run on the same commit f30ca3f0).
  • Frame-count variance (1558 vs. 1608) between single 60 s runs was not multi-run profiled; visual texture correctness under extended gameplay beyond the 60 s startup/streaming window was not separately inspected.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@ZekkJJ

ZekkJJ commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Independent test on Windows 11 build 26200, Ryzen 7 8845HS, RTX 4060 Laptop 8 GiB (driver 32.0.16.1656), 16 GiB RAM, Rust 1.98.1 MSVC. I integrated the exact #2307 head f30ca3f037e474fe1ca1720835313db161b36004 with main 6089122a1c96dff16e93b6fdf04c8ed20cfb6102. Two small follow-ups use the original dependency commits.

  • kernelx: preserve null scatter unmaps with physical aliases #3074 restores the null scatter-unmap behavior of kernelx: XMemMapPhysicalPagesScatter with no page array unmaps #495 on the section-backed branch. The merge otherwise preserves the null check in the conventional path while the alias path still advances the pointer. The historical retail crash resolved to map_aliased <- XMemMapPhysicalPagesScatter. The new two-entry regression and 22 other focused checks passed with aliases enabled. I reproduced the write-watch fixture setup failure reported above with aliasing enabled. The same GPU fixture passed byte-exact readback in conventional mode.
  • kernelx: check section page liveness for DirectStorage #3075 recognizes section-backed page IDs when DirectStorage validates the updated destination list. The existing regression failed on 785d7dc5 with aliasing enabled: the request returned success and the intended 256 bytes remained zero. On cfe04f43 it passed byte-for-byte, including the stack snapshot case. The 7 alias and 19 DirectStorage tests passed with no explicit skips.

Historical evidence from a separate earlier integration on this RTX 4060 Laptop at an exact matched Series S checkpoint (4,200 DirectStorage requests, 262 MiB, zero storage failures on both):

MiB Conventional Section aliases
Private process commit 14,558 6,727
System commit growth since first sample 9,426 1,985
DXGI local 4,551 767
DXGI non-local 5,172 5,265
Native sparse backing 3,846 289

The system commit growth difference was 7,441 MiB. Both historical runs subsequently crashed in separate paths, one during a concurrent texture decommit and the other in the null scatter-unmap. World entry was unverified. These measurements belong to that integration. No fresh smoke block was generated. The clean Series S preflight expired at 3205 MiB free RAM and 13200 MiB free commit. The guarded runner requires 6,600 MiB RAM and 18,000 MiB free commit at startup. The last idle check still showed 4129 MiB RAM and 13941 MiB free commit. Series X was deferred.

AI use: Codex (GPT-6 family, exact runtime variant unavailable) recovered the private historical artifacts, compared sources, ran the focused tests, and drafted this comment.

jessenic pushed a commit to jessenic/xcl that referenced this pull request Nov 28, 2026
The alias path must forward a null page array as an unmap, as the conventional path does after xcl-dev#495. Advancing the null pointer makes the second entry look like an array at address 0x8.

Test a two-entry scatter unmap, surviving aliases, swapped remapping, and release through the section-backed path from xcl-dev#2307.

Assisted-by: Codex (model version not exposed)
(cherry picked from commit 785d7dc)

Lab port: applied unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jessenic pushed a commit to jessenic/xcl that referenced this pull request Nov 28, 2026
The worker rereads late-filled destination lists, but the conventional liveness index never recognizes an alias allocation. Use section-backed IDs in alias mode and remember individual releases while their backing block remains open.

Recover the liveness correction from the historical section-alias integration on top of xcl-dev#2307. Verify a partially released block and the existing late-filled DirectStorage request in alias mode.

Assisted-by: Codex (model version not exposed)
(cherry picked from commit cfe04f4)

Lab port: applied unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jessenic pushed a commit to jessenic/xcl that referenced this pull request Nov 28, 2026
The queue's CopyPageMappingsBatchX maps pool pages into GPU views; on the
console a GPU-view page then shows the physical page mapped at its pool page
at the time of the call. xcl-dev#1055 decodes the calls and keeps a record of them;
with physical pages aliasing (`kernelx::alias`) the GPU view is a reservation
of views, so the decoded mappings are made for real: each GPU-view page
becomes a view of the physical page mapped at its pool page now, or is
unmapped (kind 2, or nothing mapped at the pool page). Textures in the GPU
view then read the page at their own address (`title_textures` prefers an
address with a physical page mapped), and a write through any view of the
page is uploaded at all of them.

Without the switch nothing changes: the call is recorded as in xcl-dev#1055.

(cherry picked from commit 64ad64c)

Lab port: fitted onto the follow-ups of xcl-dev#3074/xcl-dev#3075, which this commit's parent (xcl-dev#2307) did not have: apply_page_mappings holds the mapping lock for the call and passes it to map_one (now a Result), with the pool page looked up under it; a pool page whose view outlived its freed page counts as an empty pool page instead of ending the call midway (test added). The textures on the mapped pages are named to title_textures through the lab's per-page changed list (mirrors::note_changed, after the pages are in place) instead of upstream's note_gpu_view_mapping, which bumps the generation and has every texture's source read again: the title's calls come by the hundred.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jessenic added a commit to jessenic/xcl that referenced this pull request Nov 28, 2026
… stand down, and the log says which is at work

Lab port of the upstream alias stack (xcl-dev#2293, xcl-dev#2294, xcl-dev#2307, xcl-dev#2308, xcl-dev#3074,
xcl-dev#3075). The lab's two stopgaps for a physical page at more than one address
keep the page at ONE address and move it (bring_page / bring_range,
XCL_PAGE_BRING) or its video memory (sparse::share_page, XCL_PAGE_SHARE=1).
With real aliases a page is at every address the title mapped it at, outside
the sparse windows, and an address it is not at was unmapped by the title:
both stand down when XCL_PAGE_ALIAS=1. With the switch not set they are as
they were.

One line at start-up (the first time the switch is asked) names which of the
three is at work; with aliases, a line at the first view and at each power
of two from 1024 on says how many pages are shown at how many addresses and
how many of them at more than one (guards::view_counts).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@KOLESNiii

Copy link
Copy Markdown
Contributor

Review finding for f30ca3f (#3211 workstream B), with a regression test that fails here and passes with a one-line fix. I tested it at #3075's head 4fdd282, where map_one has the same branch.

With XCL_PAGE_ALIAS=1, a page that already holds bytes is not uploaded when it is mapped at a new address.

  • map_one calls guards::watch(page, at), which guards the view but marks nothing dirty. Only a page that was never committed gets lazy::mark.
  • Views cannot be write-watched, so title_textures::refresh learns about that address only through guards::take_dirty.
  • So a second view of a written page, or an address remapped from one page to another, keeps whatever its textures and sparse GPU tiles held before, until the page is written again.
  • The conventional path copies the bytes into place, and the write watch catches that copy.
  • Related: guards::forget drops the page's dirty record when its last view goes. A write, an unmap and a remap all before the next submit are therefore never uploaded either. The fix below covers that case too, because the remap marks the page again.

Test (alias.rs):

  1. Map p0 at s and write to it.
  2. Write p1 by number.
  3. Take the dirty list.
  4. Map p0 at s + PAGE and expect s + PAGE in take_dirty.
  5. Map p1 at s and expect s.

Results:

  • At 4fdd282 it fails: the new view of a written page is uploaded.
  • With guards::written(page) for a committed page in map_one it passes. That marks every view of the page; marking only at would upload less.
Patch (fix + test)
@@ unsafe fn map_one(at: usize, page: usize, _mapping: &std::sync::MutexGuard<'_, (
         if !committed(page) {
             // a page never used: committed at its first touch here (or through its home)
             lazy::mark(at);
+        } else {
+            // the address shows the page's bytes from now on: uploaded there like a write
+            guards::written(page);
         }
         return Ok(());
     }
@@ mod tests {
+    #[test]
+    fn a_page_with_bytes_mapped_at_a_new_view_is_uploaded_there() {
+        let _g = SERIAL.lock().unwrap_or_else(|e| e.into_inner());
+        let p = pages(2);
+        let s = reserve_space(3 * PAGE).unwrap();
+        unsafe {
+            assert!(map(s, &[p[0]]));
+            write64(s, 11);
+            assert!(write(&[p[1]], 0, &22u64.to_le_bytes()));
+            dirty();
+            // a second view of a page that holds bytes: that address now shows them
+            assert!(map(s + PAGE, &[p[0]]));
+            assert_eq!(read64(s + PAGE), 11);
+            assert!(dirty().contains(&(s + PAGE)), "the new view of a written page is uploaded");
+            // an address that showed one page shows another that holds bytes
+            assert!(map(s, &[p[1]]));
+            assert_eq!(read64(s), 22);
+            assert!(dirty().contains(&s), "a view remapped to a written page is uploaded");
+            free_space(s, 0, mem::MEM_RELEASE);
+            free(&p);
+        }
+    }

Tested (RTX 2070 SUPER, Windows 11, debug, cargo test -p xcl --lib hle::kernelx:: -- --test-threads=1, with this patch and the one in my #3075 comment): 68 passed, 0 failed, 1 ignored. With XCL_PAGE_ALIAS=1: 59 passed, 9 failed. The same 9 conventional-path tests fail without the patch.

Whether this explains any of the zero-sampled textures in #505 is not established. This is a static finding plus a unit test, with no retail run.

Not tested: retail title, AMD, GPU-side readback (the test checks what is handed to the upload, not what the GPU holds).

AI use: Claude Code (Claude Opus 5.5) found the issue and wrote the test and fix; the comment was checked by @KOLESNiii before posting.

@claudetools-gh

Copy link
Copy Markdown

On main fa20459 with this series on top (#2307 f30ca3f → #3074 785d7dc → #3075 4fdd282, unchanged except for conflict context), XCL_PAGE_ALIAS=1 leaves every GPU-view page that CopyPageMappingsBatchX names unmapped. Whatever the title reads through those views is zeros; in a retail title the loading-screen artwork comes out black.

The queue CopyPageMappingsBatchX: line at the end of each run (same exe, same title and scene):

run XCL_PAGE_ALIAS calls GPU-view pages mapped "named a pool page with no page mapped there" moved with their physical page upload pages "where the mapping put the page"
A 0 481 62931 0 13477 119589
B 1 328 0 50564 0 0
C 1 571 0 86088 0 0
D 0 1010 118373 0 31797 279094

My reading of the code:

  • mirrors::apply_batches resolves each pool page through Away::title (kernelx.rs, away.as_ref().and_then(|a| a.title.get(&pool))) and then calls place_of.
  • With the alias on, MapTitlePhysicalPages goes to map_aliased → alias::map. That keeps the mapping in alias's own state, but nothing fills Away::title: only map_pages, the non-alias path, inserts into it.
  • AllocateTitlePhysicalPages doesn't put the pages in PHYS_BLOCKS either, so page_home finds nothing.
  • So every page resolves to 0 and is counted as "named a pool page with no page mapped there", which ends up as Shows::Nothing.

The mirrors code reached main after this series was written, which would explain why the series never accounted for it.

What I think a fix needs:

  • in apply_batches, when alias::enabled(), resolve the pool address through alias: the physical page, and the address where its bytes live;
  • alias::map / unmap / move should call mirrors::page_at / page_placed the way the non-alias path does, so that GPU views follow their physical page;
  • a decision on whether those homes can be tiled or must be copied, since an alias home is a section view outside the GPU-visible windows.

Not tested: a fix; AMD. RTX 5070 Ti, driver 621.40, Windows 11.
AI use: Claude Code with Claude Opus 5.5 ran the runs, traced the code and wrote this. AI-assisted.

@brainhay5

Copy link
Copy Markdown

Triage note: this no longer merges with current main (mergeable=false), so it cannot be built or tested as it stands.

Why I am asking rather than just noting it: we have run fifteen mergeable candidates on the retail title on an RTX 5070 Ti, and every one still stops presenting at 50–80 s (device removed, surfacing ~88 s later on the next allocation). The PRs whose descriptions actually match that symptom are the ones that no longer apply — this is one of them. A rebase would make it testable again, and we will run it and report the numbers.

If it has been superseded by merged work, saying so is enough and it can be closed.

AI use: an agent posted this triage note.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head f30ca3f

Stacked on #2294 / #2293 (only f30ca3f belongs here). #2308 builds on it, and #3074 / #3075 (another author) merge this branch and add fixes on top, so they are follow-ups, not duplicates.
Points to handle on rebase, both already fixed in #3074 / #3075:

  • main now accepts a null pages in XMemMapPhysicalPagesScatter (unmap). The alias branch's pages.add(i) would then pass 0x8, 0x10, … to map_aliased, which dereferences them.
  • alias::State::page only checks i < section.pages(), so a freed page ID in a block that still has live pages can still be mapped and read. Also, free can release a block's home while bytes_of / move_to copy from it on another thread, because they run outside the lock.
    The feature is off by default (XCL_PAGE_ALIAS).
    Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.