kernelx: queue CopyPageMappingsBatchX records the physical page each GPU-view page shows #1055
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1055
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1055"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Xeltax on GitHub · 2026-11-24 10:58 UTC · original
Xeltax:queue-page-mappings→main· +367 −8 · 2 files · 1 commits · openQueue method #31 of the newer layout (#29 of the older),
CopyPageMappingsBatchX, maps pages of the title's memory into GPU views. It was a stub. This PR decodes its batches and records, for each 64 KiB page of a GPU view, the physical page it shows. It can then say where XCL keeps that page's data now. Nothing reads that record yet, so textures are unchanged. First of the PRs planned in #1031 (see the correction there).What is in it
crates/xcl/src/hle/kernelx.rs,mirrors:apply_batches(count, batches, pool, pool_pages)decodes one call:kind, start, count(u32 each). Kind 0 mapscountpool pages fromstart; kind 1 maps pool pagestartat each ofcountpages; kind 2 unmaps; kind 3 keeps.pool_pages, the kind must be known, and the call may name at most 2^20 pages. A bad call records nothing.Shown).mapped_source(va)answers what the method put underva:Some(Some(a)):ais where XCL keeps that physical page now (page_now), or the pool page itself when the title had mapped none there;Some(None): the page is unmapped;None: the method never touched the page.releasednow also drops a released view's recorded pages.crates/xcl/src/hle/kernelx.rs, physical pages:Away::titleremembers, per address, the page the title mapped there last.move_away).page_now(page)gives where the page's data is: its address away from home, else its home. For a page the title freed while the rest of its allocation lives (Away::freed), it gives nothing.crates/xcl/src/hle/d3d12x/real.rs: queue #29 (older numbering) callsapply_batchesand returnsS_OKas the stub did. It logs its totals at the first call and at powers of two, including how many mapped pages had a physical page, and warns once on a bad call.page_mappings_point_gpu_view_pages_at_pool_pages: synthetic batches covering:a_gpu_view_page_shows_the_physical_page_where_it_is_kept: a real physical page is mapped into a pool and given to a GPU-view page. The page shows the pool. Once the page is also mapped at another address, the GPU-view page shows that address, with the same data.a_freed_page_is_read_at_its_pool_page(from the review): one page of a two-page allocation is freed. The GPU-view page then reads the pool page, which keeps its bytes, and a later call records no physical page behind it.On the retail title (the one in #505;
main67a3735+ this change, RTX 4080, A pressed throughXCL_PRESS_AT; the run ends at+0x23cf683as onmain)Every call decodes, and every page lands in the title's one GPU view (
0xdffff0000, the view of0x7ffff0000). Log line from the run ofc8d5020:Where XCL keeps the physical pages. A local tracker, not part of this PR, followed each page. This was a separate run, on
924b55cplus the tracker. After 256 calls (at 84 s), of 34,872 mapped GPU-view pages:mirrors::source), whichtitle_texturesreads today, is right.How textures sit on the map (local count, another run, 111 s, 22,353 textures in the view):
The next PR has
title_texturesread GPU-view textures page by page throughmapped_source. It will re-check only the textures on pages that changed: the existing re-check of all GPU-view textures took 225 ms over 64k textures at 111 s, and there were 256 calls by 84 s.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4onf532d33: 738 passed, 0 failed, 41 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
main:
PR:
Not tested
Reference
The batch and range layout comes from VIctory's description of this method (
crates/victory-gpu/src/queue.rs). I read it as a reference only; no code was taken. The decode matches what the retail title passes (#1031).AI use
🤖 Generated with Claude Code
@thehollowedone on GitHub · 2026-11-24 11:34 UTC · original
Independent Windows 11 check at c8d5020. The offline workspace build and both stock page-mapping tests passed.
I extended the physical-page fixture to reuse the vacated pool address for a second page with different bytes. The original GPU view still resolved to the first page at its new address, and a new mapping resolved to the second page. A
keeprange preserved both mappings, including the address at the last byte of the first view page. Releasing the view removed both records.These checks exercise the mapping functions directly. AI-assisted. Codex (GPT-6) extended and ran the synthetic fixture.
@Xeltax on GitHub · 2026-11-24 12:55 UTC · original
Thanks @pvfreis, both findings were right. I pushed
f532d33, one commit as you suggested.1. A page freed alone.
page_nownow answers nothing for such a page:Away::freedholds the pages freed while their allocation lives, andpage_homeis no longer asked about them. Page numbers are never handed out again, and the entries go when the whole block goes.mapped_sourcethen answers the pool page, which keeps the bytes.a_freed_page_is_read_at_its_pool_pagedoes your scenario: it frees one page of a two-page allocation and checks that the GPU-view page reads the pool page with its bytes.2.
Away::title.map_pagesnow writes the entry only once the page is in place (the moved, lazy and committed paths), after clearing whatever was mapped at the address. A failed map leaves nothing behind.apply_batches(Away::title_page), so it is not counted as "to a physical page".Your questions.
Yes, the numbers come from different runs:
c8d5020;924b55c.The 15,064 / 34,872 split comes from that tracker run only. I've labelled each number with its run in the description.
On #979: agreed. A DirectStorage destination in a GPU-view page the method pointed at a pool page should follow
mapped_source. I'll look at it once this and #1102 have settled, so the three don't conflict.Tested so far on
f532d33:cargo test -p xcl --lib -- kernelx title_textures: 49 passed, 0 failed. The full suite and a new regression run on this head come next. I'll put both in the description, with the counts per run labelled, and say so here.#1102 is rebased onto
f532d33(c387de2). A freed page now also counts as a change there, so the textures on it are read again.AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and the title, and wrote this reply.
@Xeltax on GitHub · 2026-11-24 13:02 UTC · original
The full suite and a regression run on
f532d33are in the description now:cargo test --workspace --no-fail-fast -- --test-threads=4: 738 passed, 0 failed, 41 ignored.main67a3735; peak commit 16,665 MB against 16,549 MB.Each figure in the description now names the run it comes from, and I removed the wrong sentence about freed pages.
@pvfreis on GitHub · 2026-11-24 13:09 UTC · original
Thanks, both are fixed at
f532d33as far as I can see by reading it (nothing built or run here):page_nowreturnsNonefor a page inAway::freed(kernelx.rs:972-981), somapped_sourcefalls back to the pool page, anda_freed_page_is_read_at_its_pool_pagechecks exactly that, including that a later batch records no physical page.FreeTitlePhysicalPagesdrops thefreedentries when the whole block goes (:1376-1378).Away::title:map_pagesremoves the entry for each address first and writes it only on the three paths where the page is in place (:1443,:1456,:1476,:1496), so a failed map leaves nothing;title_pageignores freed pages; releasing a graphics or sparse reservation forgets its range (forget_title_mappings,:559,:578).Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@raylitebull on GitHub · 2026-11-25 00:58 UTC · original
Code review on
f532d33:queue_dispatcharm29(#31in the newer layout viaslot - 2) cleanly dispatchesq_copy_page_mappings->mirrors::apply_batches.apply_batchesvalidatescount,batches,ranges_n,ranges, pool bounds (checked_add),MOST(1 << 20) page cap,at.checked_add, andkind(0..=3) before mutatingPAGES. Lock acquisition order (AWAYdropped beforeSTATE->PAGES, andPAGESdropped beforepage_nowtakesAWAY) has no inversion.@pvfreisfindings are resolved inf532d33(Away::freed+ block cleanup inFreeTitlePhysicalPages, post-placementaway.title.insertinmap_pages,forget_title_mappingsonVirtualFree, anda_freed_page_is_read_at_its_pool_page).PR descriptionis green and the PR is cleanlyMERGEABLEagainstmain.What is still needed before merge:
Build and test (Windows, no GPU)needs to run onf532d33(currently unrun / awaiting workflow approval or a rebase onto currentmain).#1055(the RX 7900 XT test so far ran#1055+#1102together).@raylitebull on GitHub · 2026-11-25 01:06 UTC · original
Update: \Build and test (Windows, no GPU)\ is now green on \532d33\ (\CLEAN). Isolated AMD verification on \532d33\ is the only remaining item before merge.
@CharlyRien on GitHub · 2026-11-25 09:00 UTC · original
A reader for this record beyond textures (#1102): the title's buffer views and root views in the GPU view. Making them readable is what gets the world's geometry rasterised here. Result: #697 ; the per-page census with this PR's map is on #1031 (#1031).
Setup in short (the full block is in the linked comment):
main689f2db+ #1329 (+ #1326, #1327), #1448, #1323, #889, #684, #929, #640, #1850, #765, #1982, #1405, #1464, three allocator-lifetime commits fromwondercrash/xcl, then #541, #2092's3442b58state, #1887, #1803, plus local changes;XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1; RTX 3090 24 GB (driver 616.56), Windows 11 22631; one clean run and one partial run. The census runs were on an older tree with this PR's decode-and-record part ported by hand.mapped_sourcerather thanmirrors::sourceonce they rebase GPU-view addresses.AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the ports and the runs) did this and drafted the comment.
@DavidM1911 on GitHub · 2026-11-25 09:04 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main(crates/xcl/src/hle/kernelx.rs) — needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.