kernelx: physical page homes in window 0 first, from the top, keeping 64 MB free (#2867) #2905
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2905"
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?
Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-26T22:21:16Z.
Fixes #2867.
On the Series S profile with GPU heaps in the sparse windows, Build 16 crashes about 45 s into the world. Build 15 does not. The cause is
3292b096, which moved physical page homes out of window 0 and into windows 1+ (first fit). The retail title then reserves a pool of 63632 pages of 64 KiB (3977 MB). That pool needs nearly all of windows 1 and 2, and it no longer fits:0x11f9d00000, in the sparse windows. Build 16 put it in plain write-watched memory (0xa4a690000,0x94b290000,0x98cd70000in three runs).New placement of physical page homes (
Uma::sparse_alloc_home,kernelx::alloc_physical_home)sparse_reserve, first fit from window 1 up) keep one free run between them and the homes.3292b096was protecting a 38 MB view heap that had to fit in window 0 after the homes. The 64 MB margin covers that case, and the tests check that a 38 MB view heap still fits in window 0 after the homes. The figure is empirical: 256 MB left this title's pool 66 MB short, and 64 MB fits it. It was fitted to one title, soXCL_HOME_W0_KEEP_MBoverrides it. A value that does not parse logs a warning and uses the default.What is in it
kernelx: physical page homes come from the top of windows 1+ down(gpu/uma.rs,hle/kernelx.rs):take_sparse_top_in(top-down, never straddles a 4 GiB boundary) and a WARN when a GPU-visible reservation of 256 MB or more, small enough to fit the sparse windows, goes to plain memory. The WARN gives the free bytes and the largest run of each window, so this failure shows in a log.kernelx: physical page homes go to the top of window 0 while it keeps 256 MB(gpu/uma.rs,hle/kernelx.rs):Uma::sparse_alloc_home, window 0 first, with a margin.kernelx: physical page homes keep 64 MB of window 0 free, not 256(hle/kernelx.rs): sets the default margin and addsXCL_HOME_W0_KEEP_MB. Its test rebuilds the failing layout: 256 MB gives the 99 / 3911 MB split above and no room for the pool, and 64 MB puts the pool at window 1 + 20 MB.gpu/uma.rs,hle/kernelx.rs): the last-resort fallback takes window 0 from its top, not first fit from the bottom. The WARN fires for the first 4 distinct sizes instead of once per process, so an earlier fallback that is by design no longer hides a later one. On the 64 KiB-page fallback path it fires only for reservations that tried the sparse windows, not for committed GPU heaps that never did. The tests use the default margin whateverXCL_HOME_W0_KEEP_MBthe shell has. There is a new test for a free range that crosseslo_boundin the top-down search. Code comments and commit messages name no title.Tested
cargo build --release -p xcl: OK.cargo test -p xcl --lib hle::kernelx: 67 passed, 0 failed, 1 ignored (also all passing together withgpu::umawithXCL_HOME_W0_KEEP_MB=300set in the shell)cargo test -p xcl --lib gpu::uma: 20 passed, 0 failed, 0 ignoredXCL_UMA_WINDOWS=16,XCL_HEAP_WINDOWS=1,XCL_COHERENT_MB=1024, on the first three commits: the pool is at0x1101400000(window 1 + 20 MB, in the sparse windows). A 15-minute world run had no fault (2.1M draws, 0 skipped).Regression run
Not run yet. There are no
xcl-smokeblocks for this head, and I will add them.main:
PR:
Not tested
cargo test --workspacesuite. Only thehle::kernelxandgpu::umaunit tests ran.Interaction with #2886
The two are complementary: #2886 keeps single-window
sparse_reservereservations inside one window. #2886 alone does not fit this case, though. Window 2 had 3911 MB free and the pool needs 3977 MB, so the pool has to cross windows 1 and 2, and that only works if the homes leave that run free. Both PRs change the same tests ingpu/uma.rs, so they will conflict. I'll rebase onto whichever lands first.AI use
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-26T22:56:00Z.
Tested
d900644don a 16 GB card with the default window layout (3 sparse windows, no view windows). Here the pool lands inside the sparse windows again and the new warning never fires, but the title still crashed in 4 of 4 runs. With3292b096reverted instead, 3 of 4 runs reached the 300 s limit.Setup: retail title of #505, Series S profile, RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, release, shaders precompiled, 300 s limit per run. Tree:
nvidia-devea0698d4(one commit behind this PR's base; the PR's diff applies cleanly) + #2590 + #684 + #2551, plus a local 12-line working-set cap (XCL_WS_MAX_MB=13000, taken from MacieGx's lab branch) without which my 1 GB free-RAM guard ends every run at about 90 s. Env:XCL_DEVICE_TYPE=lockhart XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=1 XCL_GFX_PSO_WAIT_MS=200 XCL_PREPARE=0 XCL_PSO_PRELOAD=0 XCL_NETWORK=0, noXCL_UMA_WINDOWS, noXCL_COHERENT_HEAPS. UMA line in every run below except the first:3 sparse VRAM window(s) (12 GiB VA) + 1 coherent window(s) (3407 MB) + 0 view window(s) for GPU views at 0x400000000.3292b0960xfd4fe0000(outside the windows)0xc0000005in the title at 175 s (+0x5182154, read at0x3c54a9da013b), 104 s (+0x4e9a62e, read at0xffffffffffffffff), 93 s (+0x4e735ed, read at0xc8)0x2cfd900000xc0000005at 83 s innvwgf2umx.dll+0x3b1722(read at0xe6d8)3292b096reverted0x5f9d00000(windows 1 and 2)0xc0000005at 83 s (+0x511e7d9, read at0xffffffffffffffff)3292b096+ this PR (d900644d)0x501400000(window 1)0xc0000005in the title at 186 s (+0x2215c35, write at0x0), 97 s (+0x136ab, read at0x648), 167 s (+0x4e735ed, read at0xc8), 85 s (+0x7b619c, read at0x0)found no room in the sparse windowsis not logged in any of the four runs.0x5f9d00000and runs into window 2. With the PR it starts at0x501400000, 20 MB into window 1, and ends where the reverted one starts. I have not looked at what takes the first 3,977 MB of window 1 in the reverted tree, or where that goes with the PR. That may be the difference on this layout, or the crash here may have a second cause that the revert also removes.+0x4e735ed(read at0xc8) appears both with3292b096alone and with the PR.So on a 3-window layout without
XCL_UMA_WINDOWS=16this PR alone did not stop the crash for me, while the revert mostly did. I can run a variant if you want one tested (for example anotherXCL_HOME_W0_KEEP_MB, or withXCL_UMA_WINDOWS=16).Not tested: the PR on its exact base
eae01502; the tree without the working-set cap (the runs do not live long enough here);XCL_UMA_WINDOWS=16; the Series X profile; more than four runs per row; AMD.AI use: Claude Code with Claude Fable 5.2 ran the builds and runs, read the logs and wrote this; I checked it.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T22:57:11Z.
Found a fragmented-window case on head
d900644d.sparse_alloc_hometries only the highest fitting hole in window 0 before applying the 64 MB largest-free-run check. If that hole fails the check, a lower hole may still preserve the margin; the current code spills the home into windows 1–2 instead.I reproduced this with only XCL's synthetic UMA reservations: window 0 has a lower 32 MB hole and an upper 80 MB hole; window 1 is occupied, and window 2 has 4000 MB free. A 32 MB home placed in the lower hole leaves the upper 80 MB intact, so a subsequent 3977 MB pool fits in window 2. On the unmodified PR head, the home instead goes into window 2 and the pool has only 3968 MB there. The new regression fails on that head (0 passed, 1 failed, 0 ignored, 0 skipped). A local change that retries lower free runs after a margin rejection makes it pass. The relevant physical-home tests then pass 8/8, and
gpu::uma::tests::passes 21/21 (0 failed, 0 ignored, 0 skipped for both).Commands:
cargo test --offline --locked -p xcl --lib physical_home -- --test-threads=1andcargo test --offline --locked -p xcl --lib gpu::uma::tests:: -- --test-threads=1. Windows 11 build 26300, Ryzen 7 9800X3D; this test uses synthetic address-space reservations and does not call the GPU. I did not run the full workspace suite or a retail title. The existing retail crash report above is a separate observation; this case does not establish its cause.Candidate fix and regression test
AI use: Codex (GPT-6.2 Sol) investigated, wrote and ran the regression, tested the candidate change, and drafted this report; Codex (GPT-6.2 Astra) assisted with the initial static review.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-27T00:07:29Z.
Correction to my comment above: the "3 of 4 runs reached 300 s with
3292b096reverted" row does not support what I concluded from it, and I withdraw the comparison.I went back through the logs of those runs. The three reverted runs that reached 300 s were the ones where the driver's shader cache was cold for that build:
driver blob absentcompiles0xc0000005at 83 sd900644ds1 to s40xc0000005in all fourSo the survivors spent 130 to 190 of their 300 s blocked on compute PSO compiles, with no submits and no streaming, and did far less work than the runs that crashed. The one reverted run without that blocking crashed like the others. The PR runs came later, when the cache was warm.
Since then I ran 13 more reverted runs with a warm cache (same profile, same cap, four base commits from
eae01502toeff3bcab): 12 ended in an access violation in the title between 106 and 221 s, and one stopped on a breakpoint in the title at 195 s. So on this machine the revert does not stop the crash either, and my runs say nothing about this PR against the revert. The crash I see with the default 3-window layout looks independent of where the pool lands.The part about the PR itself stands: the pool goes back into the sparse windows and the warning is not logged.
AI use: Claude Code with Claude Fable 5.2 read the logs and wrote this; I checked it.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T03:56:44Z.
Independent paired verification on an 8 GB RTX 3060 Ti (
Series S/lockhartprofile): reproduces #2867 onnvidia-dev(ecc0bb57) and confirms #2905 fixes it.Setup
621.40,nvprofileshader heap 2048 MB), DXC1.9.2602.17.9cc6a39e, release builds, both runs starting from identical copies of a warmlockhartcache snapshot (1,296used pipelines,3,206driver blobs),250 seach.XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PSO_WAIT_MS=50 XCL_GFX_PSO_WAIT_MS=200 XCL_CS_PSO_WAIT_MS=50 XCL_PREPARE_GRAPHICS=0 XCL_DRED=1+XCL_PRESS_ATsequence (18:A..74:A).pr-2905-head(d900644d) merged cleanly withorigin/nvidia-dev(ecc0bb57; only a test change overeae01502).Results (250 s paired runs)
nvidia-dev(ecc0bb57)181.5 s(0xc0000005read at0xffffffffffffffffingame_scarlett_master.exe+0x51822b3; ended186.1 s)1,732presents inreport.jsonbefore crash)#2905(d900644d+ecc0bb57)0x0(no crash, no device removal)presents per 2 s: 1 0 1)Not tested:
XCL_COHERENT_HEAPS=sparse:1024, Series X (anaconda) profile, multiple runs per arm.Imported from ivall/xcl. Originally posted by pr1sm-dev on 2026-11-27T08:19:21Z.
Test of
d900644don an 8 GB card (RTX 3070): the pool is back in the sparse windows, but both runs lost the device on the loading screen, and with the GPU heaps in the sparse windows another reservation no longer fits. One run per row, so these are data points.Setup: RTX 3070 8 GB, driver 621.40, 64 GB RAM, Windows 11 26300, release build. Tree:
nvidia-deveae01502+ this PR's four commits (d900644d), nothing else. Series S profile,XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_TWO_PASS_MB=3072 XCL_GFX_PSO_WAIT_MS=100 XCL_PREPARE_GRAPHICS=0 XCL_NETWORK=0, NVIDIA shader heap 2048 MB (#2590), warm caches (every compute pipeline of the pack built ahead), A pressed every 10 s. UMA line in both runs: 3 sparse windows, 1 coherent window, 6 view windows.XCL_COHERENT_HEAPSsparse:10240x887a000643 s after the title started, on the loading screen (1,018 presents)0x887a000628 s after the title started, on the loading screen (607 presents)a GPU-visible reservation of 1811 MB (0x71380000 bytes) found no room in the sparse windows (41 MB free, 41 MB at most in one run; window 0: 41 MB, 41 MB in one run, window 1: 0 MB, 0 MB in one run, window 2: 0 MB, 0 MB in one run). The sparse windows held 11,734 MB right after it. Without the PR, same settings, the windows grew by 1,880 MB at the same stage (7,689 to 9,569 MB), which I read as that reservation fitting while the pool was outside. With the two GPU heaps (1162 + 1277 MB) in the windows as well, the pool, the heaps and this reservation together need about 1.8 GB more than the 12 GiB of sparse windows. Run 2 takes the heaps out of the windows and the WARN is gone (sparse windows 11,106 MB).0x887a0004: DRED is not on with the launch preparation, #2920). Local video memory was 10.2 GB (run 1) and 8.4 GB (run 2) on a 7.1 GB budget. The last draws recorded are the loading screen's (10 and 8 pipelines).eae01502without the PR, 1 of 7 runs ended with0x887a0006and state 7 on the loading screen (69 s after the title started; the one run that hadXCL_DRED=1and the graphics prebuild on). Two more ended there with0x887a0005at 97 to 98 s, before the shader-heap profile was installed; the other four got to the world load. With3292b096reverted instead, one0821b12, none of 3 runs did, and withsparse:1024the title then stayed in the world for 523 s and 801 s (I will put those on #2867). The revert runs are on a newer base, so this is not a clean pair.Not tested: more than one run per row; this PR on
e0821b12;XCL_HOME_W0_KEEP_MBother than the default; the Series X profile; a run with DRED really on (XCL_PREPARE=0).AI use: Claude Code (Claude Fable 5.2) ran the runs, read the logs and wrote this under my direction; I reviewed it.
Imported from ivall/xcl. Originally posted by kole07139 on 2026-11-27T20:58:38Z.
RTX 3070 8 GB without Resizable BAR, 32 GB RAM, Series S, default window layout, warm caches: with
d900644dthe title reached the first playable section in 4 of 6 runs (in the last one I moved the character on screen); 2 of the 6 runs held, to the 1,200 s limit and to 694 s when I stopped it, and 4 ended in the title's own code at 201–838 s, each at a different place. Without this PR the same base tree ended at 313 s. One run without the PR, six with it, on two trees, so these are data points. It adds runs longer than the 250 s of @LocranKing's check, on the default layout (@pr1sm-dev's runs were withXCL_UMA_WINDOWS=16), and on 32 GB of RAM.Setup
nvidia-devd1be8103+ #609 (held presses). Tree A: base + this PR (d900644d). Tree B: base + this PR + @Kalmarv's #3007 headda9c69f7(which carries #3003–#3006). Both merged cleanly.XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072 XCL_PREPARE=0 XCL_NETWORK=0 XCL_FRAME_DUMP=120, A every 4 s held 3.5 s, defaultXCL_COHERENT_HEAPSand layout (3 sparse windows, coherent window 3407 MB). Every compute pipeline and graphics shader of the pack precompiled with the same build; each run on its own copy of that cache.Results
0xc0000005at 313.8 s,title+0x4ea302e, read at0x466768c00xc0000005at 563.0 s,title+0x4e334e6, read at0x8d340xc0000005at 838.4 s,title+0x5035cd1, read at0x508e3a2a0xc0000005at 201.5 s,title+0x8655c1, read at0x50on 4 threads0xc0000005at 233.8 s,title+0x4e2aacd, write at0x8a GPU-visible reservation of … found no room in the sparse windows) is in none of the logs.0x400000000). Four of the six are reads or writes near zero (0x8,0x50,0x8d34), and no two are at the same place. I found no issue with any of these offsets.Log lines (the title's exe name shortened to
title)Not tested: more runs per arm; N with a 1,200 s limit; Series X;
XCL_COHERENT_HEAPS=sparse; a machine with more RAM; the test suite on these trees.AI use: Claude Code (Claude Opus 5.5) built the trees, ran the runs, read the logs and the frame dumps and wrote this; I watched the last run, checked the report and posted it.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:02:02Z.
Review (head
d900644d, diff read, not a merge-check; it conflicts with main, so not built or run):237b7181) changes behaviour. Main still puts physical page homes first-fit in windows 1+ (3292b096) and #2867 is open. Butsparse_reservenow tries to fit a reservation in one window first, so this PR'sphysical_homes_in_window_0_leave_room_for_the_page_pool(expects the pool attitle + 3997 MB,kernelx.rs~5412) would see it wholly in window 2, and main'ssparse_reserve_keeps_single_window_reservations_inside_one_window(uma.rs~1595) expects homes in window 1 where top-down puts them in window 2. The in-game pool address (0x1101400000) was measured without #2886 and needs a new run.3292b096failure again. Series X and the default 4-window layout weren't run.XCL_HOME_W0_KEEP_MB; CONTRIBUTING asks for the diagnostic and the switch as separate PRs. No xcl-smoke blocks and no full test run.Fine:
take_sparse_top_in(window-boundary handling,lo_boundand its test), thefree_runs_inrefactor, tests ignoring the shell's margin, and the WARN limited to the 64 KiB-page path.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.