Repository navigation
kernelx: with XCL_PAGE_ALIAS=1 the queue's page mappings show real pages - #2308
adiologydev wants to merge 7 commits into
Conversation
…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.
…GPU-view page shows Queue method xcl-dev#31 (xcl-dev#29 of the older layout) maps pages of the title's memory into GPU views; it was a stub. Its batches are now decoded and checked against the batch count and the pool, and each 64 KiB page of a GPU view records the pool page it was given and the physical page the title had mapped there (kernelx::mirrors). A bad call records nothing; releasing a view drops its pages. XCL keeps a physical page's data where it was mapped last, and the title maps most streamed pages into the CPU view behind the GPU view too, so `mapped_source` answers where that page is now (`page_now`), else the pool page itself. Each title mapping is remembered per address (Away::title), written once the page is in place and forgotten when the reservation goes; a page freed while its allocation lives is no longer looked for (Away::freed). Nothing reads the record yet: textures are unchanged; the queue logs its counts. (xcl-dev#1031) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`mirrors::decode_batches` checks and decodes one call of the queue's CopyPageMappingsBatchX into (GPU-view page, pool page or unmapped) pairs; `apply_batches` records them as before. No change in behaviour: the next commit maps the decoded pages for real when physical pages alias.
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.
|
Wine/vkd3d-proton lane: this PR's own new test fails deterministically here, in both switch states, and with the switch on one pre-existing main test breaks on the branch too. Tested: heads Switch off (default):
Switch on (
The alias tests are in-process unit tests (finish in 0.03 s), and the failures are identical across reruns, so this does not look like timing flakiness; it looks like a real behavior gap for the physical-page-upload invariants on the Wine/vkd3d-proton lane. Whether the root is in the top two commits or in an unmerged ancestor layer I cannot separate from outside the stack; the queue-mapping test failure at least is in code this PR adds. Not tested: native Windows CI (upstream CI presumably sees these green, so the delta is lane-specific); NVIDIA lane (parked); 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. |
|
Native Windows check of exact head Tested
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, compared the two heads and wrote this report. |
…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).
|
Independent test and 60 s smoke report for head Tested
Regression run (
PR With Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window. AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting. |
|
Reviewed
AI use: Antigravity (Gemini 4 Carbon) assisted with tracing |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Doc-only step-92 audit header in rdna2.rs (full per-entry table in .ralph/specs/linux-port/progress.md, untracked by design): all 9 keep files MISSING-verified at 43838a1; true gaps queued as R1/V1/X1/X2/T1; d3d12/media/dxil-LATER gated, xcl-dev#2308 already step-94.
Stacked on #2307 and on #1055; only the top two commits (
31fe59c,64ad64c) belong here.4f34c8dis #1055's commit (@Xeltax's, unchanged apart from one conflict with today'smaininVirtualFree: bothmirrors::released(a)andforget_title_mappings(a, n)kept). Fourth part of the plan on #1031.The queue's
CopyPageMappingsBatchXmaps 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. #1055 decodes the calls and keeps a record of them. WithXCL_PAGE_ALIAS=1(#2307) the GPU view is a reservation of views, so the decoded mappings can be made for real.What is in it
31fe59ccrates/xcl/src/hle/kernelx.rs:mirrors::decode_batches– kernelx: queue CopyPageMappingsBatchX records the physical page each GPU-view page shows #1055's checked decoding, apart from its record (apply_batchesrecords as before). No change in behaviour.64ad64ckernelx/alias.rs,d3d12x/real.rs,kernelx.rs: with the switch, the queue method makes each GPU-view page a view of the physical page mapped at its pool page now, or unmaps it (kind 2, or nothing at the pool page), and bumps the GPU-view generation so textures there look again.title_texturesalready reads a texture at its own address when a physical page is mapped there. Without the switch the call is recorded as in kernelx: queue CopyPageMappingsBatchX records the physical page each GPU-view page shows #1055. Test: a page written through the CPU view reads back in the GPU view, one pool page at two GPU-view pages, a write in the GPU view uploads every view of the page, and a later change of the pool page leaves the GPU view on the page it was given.Tested
XCL_DXC_DIR), debug tests, release runs.cargo test --workspace -- --test-threads=4on64ad64c: 1118 passed, 4 failed, 26 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState→E_OUTOFMEMORYon this card, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905);main568e7db fails the same 4 here (1094 passed, 4 failed, 26 ignored). SKIPPED (23, the same onmain): 20 need 64-lane waves ("no wave64"), 3 per-lane f16 refusals inlower_dxil::tests::{f16,f32}_programs_on_the_gpu.XCL_PAGE_ALIAS=1, 300 s into its world: 256 calls by 170 s, 31 196 GPU-view pages mapped to a physical page, 3 137 unmapped, none pointing at an empty pool page; no crash or device removal (before, every one of these mappings was dropped).Regression run (the switch off, as the PR checks run it)
scripts/smoke.ps1 -Game <retail title> -Seconds 60, no input,mainfirst, same machine (each run'sxcl.exebuilt from a clean checkout of its commit):Not tested
AI use
31fe59cand64ad64c, the test and this description, and made the runs above on this hardware.4f34c8dis @Xeltax's kernelx: queue CopyPageMappingsBatchX records the physical page each GPU-view page shows #1055. I read every line of the diff and checked it.