kernelx: keep physical page release local to the page ID #608
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!608
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-608"
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?
@Babyhamsta on GitHub · 2026-11-24 02:24 UTC · original
Babyhamsta:fix/physical-page-liveness→main· +112 −29 · 1 files · 1 commits · openFreeing one physical page twice could retire a sibling the title still owned. A freed page could also continue resolving to its home until the last page in the allocation was released. Related PR #187 addressed when XCL returns backing memory.
What is in it
kernelx.rs. Preserve the existing return convention for repeated frees and permit repeated reads of live IDs. Tests cover reads, writes, mapping, and IDs on either side of a bitmap word boundary.Tested
cargo test --workspace -- --test-threads=4 --show-outputreported 686 passed, 0 failed, 41 ignored. Two passes reported SKIPPED for unavailable wave64 execution (gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware).Regression run
Main
PR head
Not tested
AMD or Intel GPUs, playable world loading, and how often retail titles repeat a release.
AI use
Codex (GPT-6.2 Sol) implemented the fix and regression tests. Codex (GPT-6) reviewed the diff, checked related PRs, ran the smoke comparison, and prepared this description.
@MesshM on GitHub · 2026-11-24 03:12 UTC · original
Test run of
2a3c7f4c09ee70667f6dcb39ebef77f38d3ecec3on AMD RDNA4. I merged it onto currentmaindd2ae9alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 692 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 652 passed, 0 failed, 21 ignoredSKIPPED;repeated_physical_page_release_preserves_live_siblingsandphysical_page_liveness_crosses_bitmap_wordspass.Review: The per-block bitmap makes a second free of a page a no-op (
free_pagereturns false andlivedrops once), and a freed page no longer resolves to its home even while siblings in the block are live. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@Kalmarv on GitHub · 2026-11-24 02:50 UTC · original · edited 2026-11-24 04:09 UTC
Tested
2a3c7f4merged onto mainbdab194(merge 6bff65c, no conflicts). The fix does what the description says, and both new tests test it.repeated_physical_page_release_preserves_live_siblings, added alone to mainbdab194, fails atassert!(!read_physical_pages(&[first], 0, &mut bytes)): a page freed twice is still read. It passes on the merge. The other new test usesPhysicalBlock, so it does not compile on main.free_pagecounting a page that is already freed again (main's behaviour), both new tests fail: the bitmap test at!block.free_page(boundary), the other at the read of the sibling.FreeTitlePhysicalPagesnow holdsAWAYandPHYS_BLOCKStogether. Read, write and map takeAWAYfirst andPHYS_BLOCKSinsidepage_home, so the order is the same everywhere.note_mapping_atunder both locks takes only the mirrors' own lock, and nothing under that lock takes these two.One small thing, a question more than a finding: the block that drops a freed page's mapping away from home moved inside the new liveness check, and no kernelx test reaches it. With that block taken out, all 25 kernelx tests still pass, the two new ones included. Could the new test map
siblingat an address of its own before freeing it and checkphysical_page_atafterwards?Tested
RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, debug.
cargo build --workspace, thencargo test --workspace -- --test-threads=4on the merge 6bff65c: 689 passed, 0 failed, 41 ignored. SKIPPED on this card:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).kernelx::tests), 2 runs each, same result both times:bdab194with the one test that compiles there: 23 passed, 1 failed;scripts/pr_check.pyfrom main on the description: ok.Not tested
Title smoke run
cargo build --release -p xcl) from clean checkouts9ce2070eccf436d7bd38601c90407da447df34f3(this PR's base); PR head:2a3c7f4c09ee70667f6dcb39ebef77f38d3ecec3, no uncommitted changesscripts/smoke.ps1 -Game <title folder> -Seconds 60on a retail title, two pairs back to back, main first in each, after one 60 s warm-up run of main; all four runs start from the same learned coherent-window sizeXCL_PRESS_AT). After its first load the title waits on its account picker (a steady 780 draws per 2 s, no file reads) for an A press, and the only presses were by hand at the test machine: the first A came at 32.8 s in the warm-up (next load from 34 s); pair 1 main 29.3 s (from 30 s), PR 57.4 s (from 58 s); pair 2 no press on either side, so both sat on the picker to the 60 s end. The PR's later load in pair 1 is the later hand press, not this PR. Pair 1's peak-commit gap follows it: main's 16496 MB comes after its second load, which the PR reached only at 58 s; in pair 2, where neither side got past the picker, the peaks matchPair 1, main:
Pair 1, PR:
Pair 2, main:
Pair 2, PR:
Not tested: whether the title freed any physical pages in these runs, or freed one twice. It imports
XMemAllocatePhysicalPages,XMemFreePhysicalPages,XMemMapPhysicalPagesandXMemMapPhysicalPagesScatter, which xcl serves through the functions this PR changes, but the log has no count of those calls and noAllocateTitlePhysicalPages(...): no roomline in any run, so these runs do not show the duplicate release this PR guards against. They ran on native Windows on an RTX 5070 Ti only; no AMD GPUs.🤖 Claude Fable 5.2
@raylitebull on GitHub · 2026-11-25 00:56 UTC · original
Diff check on
2a3c7f4:PhysicalBlock::freed(bitset) sofree_pageis idempotent and releases only the requested page ID cleanly fixes double-free / live-sibling corruption inkernelx.RX 9060 XT) and NVIDIA, withPR descriptionpassing.Next step to unblock merge: Please rebase onto current
mainso CI runsBuild and test (Windows, no GPU)on the head.@raylitebull on GitHub · 2026-11-25 01:06 UTC · original
Update: \Build and test (Windows, no GPU)\ is now green on \
2a3c7f4\ (\CLEAN). Before merge, could @Babyhamsta\ follow up on @Kalmarv's test-coverage note above (exercising \physical_page_at\ when freeing a page that was mapped away from home)?@JJAutoCompare on GitHub · 2026-11-25 06:43 UTC · original
Empirical test report (
2a3c7f4c)Hardware / environment
2a3c7f4c09ee70667f6dcb39ebef77f38d3ecec3, verified on a clean, detached HEAD.1.100.0 (0ef1bc386 2026-11-09),x86_64-pc-windows-msvc. DXC1.9.2609.5 (01b62ad47).XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1. Both commands ran directly through Cargo without the Arc GPU mutex wrapper.Commands and results
cargo test --workspace --no-runexited 0. Workspace test binaries built. Test execution counts were 0 passed, 0 failed, 0 ignored, and 0 skipped.cargo test -p xcl --lib physical_pageexited 0. The log reports 6 passed, 0 failed, 0 ignored, 0 skipped and 661 filtered out. The skip count is the number of case-sensitive^SKIPPEDlines.AtomicU32::fetch_updatein XGameRuntime.Observed behavior
Not tested
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr608-focused.log and published.
@thehollowedone on GitHub · 2026-11-25 06:51 UTC · original · edited 2026-11-25 06:56 UTC
I followed up on the requested away-mapping coverage at exact 2a3c7f4. The test-only extension maps a live sibling away from its home, verifies that a duplicate free of another page preserves this mapping, then frees the mapped sibling. It checks that
physical_page_atclears, the former mapped VA retains its byte, and the remaining live sibling still reads correctly.Tested
XCL_ADAPTER=NONE_CPU_ONLY. The focusedcargo test --offline --locked -p xcl --lib physical_page -- --test-threads=1run passed 6, failed 0, ignored 0, skipped 0.away.at.remove(&at)suppressed in a disposable copy, the extendedrepeated_physical_page_release_preserves_live_siblingstest failed at the newphysical_page_atassertion. Restoring the PR code made that exact test pass. The mutation shows the new assertion reaches the previously uncovered cleanup.Test addition
Not tested
Workspace suite, retail title, GPU behavior, or other Windows builds. The test-only patch remains local. The added lines in
repeated_physical_page_release_preserves_live_siblingsare below, so the author can incorporate the requested coverage without reconstructing the fixture.AI use
Codex (GPT-6, exact variant unavailable) wrote and ran the extension and drafted this report.
@raylitebull on GitHub · 2026-11-25 10:43 UTC · original
@Babyhamsta — @thehollowedone shared a tested, ready-to-apply patch for the requested away-mapping physical_page_at coverage on
2a3c7f4. Once folded in and Build and test finishes green, this is ready to merge!@DavidM1911 on GitHub · 2026-11-25 12:55 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.