Repository navigation
Conversation
…U range copy_page_mappings (queue slot 31, CopyPageMappingsBatchX) mirrors every page it maps or unmaps at a GPU-only destination onto the paired CPU range (title_gpu_views::to_cpu). It did so even where the title had mapped that CPU page itself with XMemMapPhysicalPages or XMemMapPhysicalPagesScatter: a copy replaced the title's page, and an unmap (kind 2) left the title's CPU page reserved. The title's next read of it faulted, and the run ended. The console's CopyPageMappingsBatchX edits only the GPU-only range's page table, so a CPU page holding a mapping of the title's (physical, scatter or a slot-31 copy onto that address) is now left as it is. Pages the mirror made itself, zero plants and pages with no mapping still follow the GPU-only range, so the D3D12 layer's reads at the CPU view keep working. Each page kept is counted and the first ones are logged. The unmaps these paths make are now labelled in the read-fault report (CopyPageMappingsBatchX unmap / paired CPU page / remap / hole, XMemMapPhysicalPagesScatter unmap / remap) instead of the default "unmap". xmem_test: test_copy_page_mappings_cpu_view now checks that a copy onto, and an unmap of, a GPU-only page whose paired CPU page the title mapped keep the title's bytes at the CPU page. Both checks fail on the old code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Retail result for this in the world phase (RTX 5080, NVIDIA 621.24, Windows 11), with A helper of mine came to the same function from the logs and wrote a version with a clock instead of the owner check (keep only pages the title mapped after the remap was queued); yours was open first and is simpler, so I use yours and will not send mine. In the runs that failed, the log counted deferred remaps (7, 8 and 4 in three of them, 0 in the runs that did not fail), which fits a remap that runs late. |
…plit-view write-tracking, trim on xmem OOM, map DispatchMesh slot 129 - xmem: port ProjectLeonida/mandy#1972 (GPL-3.0, author kurrutako): track MapOwner (physical/scatter/slot31/mirror) on MappedPage, add trivial-POD UnmapCause labels on XMemMapPhysicalPagesScatter and copy_page_mappings, and add title_mapped_twin() so CopyPageMappingsBatchX leaves title-owned paired CPU mappings untouched on copy and unmap. - xmem: preserve PageTrack (views, locked, armed, stamp) and read-only protection across coalesced-view splits in unmap_range(), fixing the title_shadow_sync_test split-unmap regression (now 85/85). - xmem: on _aligned_malloc OOM in title_block(), invoke leonida::working_set::maybe_trim_process_working_set(), retry once, and emit a rate-limited OOM diagnostic if still null. - d3d12_xs: map console command-list slot 129 -> PC GCL6 slot 79 (ID3D12GraphicsCommandList6::DispatchMesh) with mock routing coverage for both 60-slot refusal and GCL6/GCL7 (x, y, z) forwarding. - d3d12_vulkan: mark staging_pool_* mutable and trim_staging_pool()/ destroy_staging_entry() const so allocate() const compiles cleanly. - Verified Marvisak/VIctory#2618 (XAsyncGetResultSize) is already handled by vendored libHttpClient AsyncLib.cpp (writes 0 on pending, failed, taken). AI-assisted: implemented and verified with Ninja RelWithDebInfo build and CTest (9/9 passed under LEONIDA_VK_VALIDATION=1 on RTX 3080).
|
Second retail boot with this change, same setup: it ran 1,739 s with the game still submitting (about 30,000 submissions in all) until I closed the window, and the process exited with code 0. It logged no title read faults and 9 faults left to the title. The five boots before the change ended by themselves after 210 to 1,308 s. |
|
Thanks for the review. Two points I checked in the code:
I'll add a regression through the queue proxy's default adapter (no hook installed) that covers the case you describe: the source backed only through its CPU alias, a title-owned page at the destination's CPU twin, then a copy and an unmap. If the list-value fences can be held in that test, I'll cover the deferred order too. AI-assisted. |
|
Tested on an RX 7900 XTX (RADV, Mesa 26.3.1, Wine) with the retail game, two runs each, same settings:
So the mirror seems to keep something on the GPU side consistent too. We're tracing which data goes stale; until then, this probably shouldn't merge as is. AI-assisted (Claude Code, Claude Opus 5.5). |
…ail route queue_copy_page_mappings logs once whether CopyPageMappingsBatchX goes to an installed batch hook or to the default adapter over xmem's range callback (copy_page_mappings_fn), so a boot's read-fault reports can be matched to the implementation the tests cover. Nothing in the runtime installs a hook, so a retail run takes the default adapter. d3d12_xmem_placed_test gains queue_remap_default_route, for that route: no hook, a legacy-paired GPU-only destination, and a GPU-only pool backed only through its CPU alias. The title maps a page of its own at one CPU twin while the remap waits behind queue work (deferred with list values, waited for with LEONIDA_LIST_VALUES=0), so ownership is checked when the remap is applied. After the copy the GPU-only pages hold the pool's bytes, the other twin follows them and the title's page keeps its bytes; after an unmap the GPU-only pages and the mirrored twin are reserved and the title's page still holds its bytes. On the code before this pull request the title's page check fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed 28fc026, as said above:
AI-assisted. |
|
Thanks for the new test. It shows the mechanism we suspect behind the device losses: after a copy, the GPU-only pages change while the paired CPU page keeps the title's bytes. But the layer reads the title's GPU-only memory through that CPU view ( A way to keep your protection of the title's pages without this: give the layer a private copy of each pair that the title never sees, with every slot-31 copy and unmap mapped there, and point AI-assisted (Claude Code, Claude Opus 5.5). |
|
Agreed, that is a real gap: with this PR, a layer read through A private layer view per pair fits both: it has every slot-31 copy and unmap at the GPU address, and the CPU twin's page wherever slot 31 has mapped nothing (the legacy pairs, read through the CPU view today). Before that, I'll make the "left the title's mapping" log say whether the title's page holds the same physical page as the copy, so a boot shows how often they really diverge. In the boots in the description every kept page was a |
|
I measured how often the kept CPU page really differs, using a logging-only patch on top of this PR (head Setup: a retail boot on the Ryzen 7000 iGPU (gfx1036, RADV, Mesa 26.3.1, Wine), headless. So far it has run 25 minutes and about 35,000 submissions, and it is still running.
So the gap is real but rare in this boot. A private layer view per pair, as you describe, covers both cases. Please go ahead with it in this PR; we aren't writing it. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Closing for now under the new rule of one open PR until two are merged; I am keeping #1722 open. The private layer view discussed above is written, but in my retail boots it moved the faults left to the title into the GPU-only range, and one boot ended in a device loss. I will reopen this once I have found out why. Thanks for the measurements and the review. AI-assisted (Claude Code, Claude Opus 5.5). |
…itle's own mappings at the paired CPU range (RT-SLOT31-CPU-TWIN-TITLE-PAGES) Head 28fc026. Closed by its author as incomplete; merged because world run 41 had it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you, @kurrutako. Although you closed this, its commits went into The gap discussed above is still open: a layer read through the CPU twin can see the title's page where slot 31 mapped a different one. Your private-layer-view follow-up, or another fix for that gap, is welcome as a new PR. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
Claimed in the coordination issue as: RT-SLOT31-CPU-TWIN-TITLE-PAGES
What and why
copy_page_mappings(queue slot 31,CopyPageMappingsBatchX) mirrors every page it maps or unmaps at a GPU-only destination onto the paired CPU range (title_gpu_views::to_cpu, from 255f170). It did this even where the title had mapped that CPU page itself. A copy replaced the title's page, and an unmap (kind 2) left the title's CPU page only reserved. The title's next read of it was a fault in a window, left to the title, and the run ended. The commit that added the mirror names this risk: if the pairing is wrong, "the mirror replaces the title's own mappings in that CPU range".The console's
CopyPageMappingsBatchXedits only the GPU-only range's page table. So a CPU page that holds one of the title's own mappings (XMemMapPhysicalPages,XMemMapPhysicalPagesScatter, or a slot-31 copy onto that address) is now left as it is. Pages the mirror made itself, zero plants and pages with no mapping still follow the GPU-only range, so the D3D12 layer's reads at the CPU view still work. Each page left alone is counted, and the first ones are logged.The unmaps on these paths now carry their own label in the read-fault report, instead of the default
unmap:CopyPageMappingsBatchX: unmap, paired CPU page, remap, holeXMemMapPhysicalPagesScatter: unmap, remapTested
xmem_test(MSVC, RelWithDebInfo):test_copy_page_mappings_cpu_viewgains two checks. A copy onto, and an unmap of, a GPU-only page whose paired CPU page the title mapped must keep the title's bytes at the CPU page. Both checks fail on the old code and the whole test passes with the fix.Retail boot, own copy, RTX 5070: current
mainplus d3d12: LEONIDA_HOST_IMAGE_COPY switch; auto leaves host image copies off on NVIDIA #1851, d3d12: title images use the staged upload on a device without host image copies (RT-TITLE-STAGED-NO-HOST-COPY) #1827, d3d12: changed console heap slots are fixed without a time limit by default, not given to shaders as null (RT-CONSOLE-FIX-BUDGET-NULL) #1849, rdna2spirv: restore the dot4 inline op_sel_hi under exact re-anchoring too (SHADER-FSPX-DOT4-EXACT) #1862 and d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT) #1886, Series S device type, same switches every time.scattermappingsBefore the change, each read fault's report matched a default-cause unmap of the same page 0.7–1.9 s earlier. The screen stays black at about 0.4 frames/s at this stage, as it did before the change. One boot is not proof that the crash is gone, but none of these reads came back.
GPUs tested: NVIDIA RTX 5070
AI-assisted.
Checklist
mainand merges cleanly.🤖 Generated with Claude Code