kernelx: physical page homes in window 0 first, from the top, keeping 64 MB free (#2867) #2905

Open
github-bot wants to merge 4 commits from github-bot/gh-2905 into nvidia-dev AGit
Owner

@⁠grahamster2 on GitHub · 2026-11-26 22:21 UTC · original
grahamster2:fix/homes-top-window0 → nvidia-dev · +465 −21 · 2 files · 4 commits · open

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:

  • At the pool's reservation: 4367 MB free, 3911 MB at most in one run (window 0: 357 MB, window 1: 99 MB, window 2: 3911 MB). That was with homes already placed top-down in windows 1+, which is the first commit here.
  • Build 15 put the pool at 0x11f9d00000, in the sparse windows. Build 16 put it in plain write-watched memory (0xa4a690000, 0x94b290000, 0x98cd70000 in three runs).
  • The title faulted about 45 s after world load in 4 of 4 Build 16 runs.

New placement of physical page homes (Uma::sparse_alloc_home, kernelx::alloc_physical_home)

  1. Window 0 first, from the top down, as long as at least 64 MB of window 0 stays free in one run after the home.
  2. If that fails, windows 1+, from the top of the last window down. The title's own reservations (sparse_reserve, first fit from window 1 up) keep one free run between them and the homes.
  3. As a last resort, window 0 past the margin, also from its top. Its low addresses stay free for the title's 32-bit memory.

3292b096 was 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, so XCL_HOME_W0_KEEP_MB overrides 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 adds XCL_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.
  • Review fixes (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 whatever XCL_HOME_W0_KEEP_MB the shell has. There is a new test for a free range that crosses lo_bound in the top-down search. Code comments and commit messages name no title.

Tested

  • RTX 3080 10 GB, 31 GB RAM, Windows 11 Pro 26200, release build.
  • cargo build --release -p xcl: OK.
  • cargo test -p xcl --lib hle::kernelx: 67 passed, 0 failed, 1 ignored (also all passing together with gpu::uma with XCL_HOME_W0_KEEP_MB=300 set in the shell)
  • cargo test -p xcl --lib gpu::uma: 20 passed, 0 failed, 0 ignored
  • Retail title, Series S profile, XCL_UMA_WINDOWS=16, XCL_HEAP_WINDOWS=1, XCL_COHERENT_MB=1024, on the first three commits: the pool is at 0x1101400000 (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-smoke blocks for this head, and I will add them.

main:

PR:

Not tested

  • The review-fix commit (window-0 fallback from the top, the WARN for the first 4 sizes and only after a sparse attempt) was not run in-game. It is only unit-tested. The in-game run above was on the first three commits.
  • The full cargo test --workspace suite. Only the hle::kernelx and gpu::uma unit tests ran.
  • The Series X profile, other titles, and AMD / Intel GPUs.

Interaction with #2886
The two are complementary: #2886 keeps single-window sparse_reserve reservations 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 in gpu/uma.rs, so they will conflict. I'll rebase onto whichever lands first.

AI use

  • Claude Code (Claude Opus 5.5): wrote the code, the tests and this description, and ran the unit tests. The in-game runs were done on the hardware above.
**@⁠grahamster2** on GitHub · 2026-11-26 22:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905) `grahamster2:fix/homes-top-window0` → `nvidia-dev` · +465 −21 · 2 files · 4 commits · open 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: - At the pool's reservation: 4367 MB free, 3911 MB at most in one run (window 0: 357 MB, window 1: 99 MB, window 2: 3911 MB). That was with homes already placed top-down in windows 1+, which is the first commit here. - Build 15 put the pool at `0x11f9d00000`, in the sparse windows. Build 16 put it in plain write-watched memory (`0xa4a690000`, `0x94b290000`, `0x98cd70000` in three runs). - The title faulted about 45 s after world load in 4 of 4 Build 16 runs. **New placement of physical page homes** (`Uma::sparse_alloc_home`, `kernelx::alloc_physical_home`) 1. Window 0 first, from the top down, as long as at least 64 MB of window 0 stays free in one run after the home. 2. If that fails, windows 1+, from the top of the last window down. The title's own reservations (`sparse_reserve`, first fit from window 1 up) keep one free run between them and the homes. 3. As a last resort, window 0 past the margin, also from its top. Its low addresses stay free for the title's 32-bit memory. 3292b096 was 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, so `XCL_HOME_W0_KEEP_MB` overrides 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 adds `XCL_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. - Review fixes (`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 whatever `XCL_HOME_W0_KEEP_MB` the shell has. There is a new test for a free range that crosses `lo_bound` in the top-down search. Code comments and commit messages name no title. **Tested** - RTX 3080 10 GB, 31 GB RAM, Windows 11 Pro 26200, release build. - `cargo build --release -p xcl`: OK. - `cargo test -p xcl --lib hle::kernelx`: 67 passed, 0 failed, 1 ignored (also all passing together with `gpu::uma` with `XCL_HOME_W0_KEEP_MB=300` set in the shell) - `cargo test -p xcl --lib gpu::uma`: 20 passed, 0 failed, 0 ignored - Retail title, Series S profile, `XCL_UMA_WINDOWS=16`, `XCL_HEAP_WINDOWS=1`, `XCL_COHERENT_MB=1024`, on the first three commits: the pool is at `0x1101400000` (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-smoke` blocks for this head, and I will add them. main: PR: **Not tested** - The review-fix commit (window-0 fallback from the top, the WARN for the first 4 sizes and only after a sparse attempt) was not run in-game. It is only unit-tested. The in-game run above was on the first three commits. - The full `cargo test --workspace` suite. Only the `hle::kernelx` and `gpu::uma` unit tests ran. - The Series X profile, other titles, and AMD / Intel GPUs. **Interaction with #2886** The two are complementary: #2886 keeps single-window `sparse_reserve` reservations 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 in `gpu/uma.rs`, so they will conflict. I'll rebase onto whichever lands first. **AI use** - Claude Code (Claude Opus 5.5): wrote the code, the tests and this description, and ran the unit tests. The in-game runs were done on the hardware above.
Build 16 (3292b096) took homes from windows 1+ first-fit, beside the title's
own reservations, which `sparse_reserve` also places first-fit from window 1
up. A home that no longer fits the rest of window 1 goes to the start of
window 2 (homes never straddle a window), and a reservation of nearly a window
then has room on neither side. the retail title's page pool for CopyPageMappingsBatchX
(63632 pages of 64 KiB, 3977 MB) was at 0x11f9d00000 in Build 15 (window 1 +
3997 MB, across into window 2; homes then went to window 0), and plain
write-watched memory at 0xa4a690000 in Build 16 (sparse use 7630 MB instead
of 11607 MB); about 45 s into the world its threads faulted on garbage
pointers.

Homes now come from the top of the last sparse window down (still within one
window, still window 0 only when windows 1+ have no room), so the title's
reservations from window 1 up keep one free run between. Above a window
nothing changes.

A large GPU-visible reservation (256 MB or more, no more than the sparse
windows hold for the title) that goes to plain write-watched memory is now
warned of once, with the free space of each sparse window.
Run 49 (Build 16 + 06376122) warned that the retail title's page pool (63632 pages of
64 KiB, 3977 MB) found no room in the sparse windows: window 0 874 MB free,
window 1 99 MB, window 2 3394 MB at most in one run. The pool needs the rest
of window 1 and 3878 MB of window 2 from its start, and ~600 MB of homes sat
at the top of window 2. In Build 15 the homes went first-fit into window 0
and the pool was at 0x11f9d00000, across windows 1 and 2.

3292b096 moved homes out of window 0 for the title's 32-bit memory there: a
Series S run's 38 MB view heap (1245184 slots) found no room in window 0 after
2.9 GB of sparse GPU heaps and 664 MB of first-fit homes, went to window 1,
which descriptor tables cannot reach, and the title stopped on its own check.
It names no headroom figure.

Homes now come from the top of window 0 down while it keeps a free run of
XCL_HOME_W0_KEEP_MB (default 256 MB) after them (`Uma::sparse_alloc_home`),
otherwise from the top of windows 1+ down as in 06376122. From the top, so
the title's first-fit allocations at the low end of window 0 keep one run.
With the retail title's figures window 0 has 1144 MB after its GPU heaps and takes all the
homes; in the Series S case the 664 MB home would leave 28 MB and goes above.

Tests: run 49's figures place the pool across windows 1 and 2 with the homes
in window 0, and window 0 keeps its margin while homes spill to window 2.
256 MB left the title's 3977 MB page pool 66 MB short of one free run in the
sparse windows (window 0 kept 357 MB, largest run 3911 MB), so it fell to plain
memory and the title faulted about 45 s into the world. With 64 MB the pool
lands in window 1 (0x1101400000) and a 15-minute world run had no fault.
64 MB still covers the 38 MB view heap 3292b096 protects on the Series S
profile. XCL_HOME_W0_KEEP_MB still overrides it.
Review fixes for the homes placement:
- The last resort of `Uma::sparse_alloc_above` (windows 1+ full) took
  window 0 first-fit from the bottom, where the title's 32-bit memory
  goes. It now takes window 0 from its top down too.
- The large plain-fallback WARN fired once per process, so an earlier
  fallback that is by design hid a later one. It now fires once for each
  of the first 4 distinct sizes.
- An `XCL_HOME_W0_KEEP_MB` that does not parse is warned of instead of
  silently using the default, and the tests use the default margin
  whatever the shell sets.
- A test of `take_sparse_top_in` with a free range across `lo_bound`.
- The WARN on the 64 KiB-page fallback only for reservations that tried
  the sparse windows, not committed GPU heaps that never did.
- Comments name no title.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:15:35 +00:00
Author
Owner

@⁠tiagonleal on GitHub · 2026-11-26 22:56 UTC · original

Tested d900644d on 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. With 3292b096 reverted 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-dev ea0698d4 (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, no XCL_UMA_WINDOWS, no XCL_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.

tree pool (63632 pages) at runs of 300 s ends
as above, with 3292b096 0xfd4fe0000 (outside the windows) 3 0xc0000005 in the title at 175 s (+0x5182154, read at 0x3c54a9da013b), 104 s (+0x4e9a62e, read at 0xffffffffffffffff), 93 s (+0x4e735ed, read at 0xc8)
same, first run of the day (coherent window still 512 MB) 0x2cfd90000 1 0xc0000005 at 83 s in nvwgf2umx.dll+0x3b1722 (read at 0xe6d8)
3292b096 reverted 0x5f9d00000 (windows 1 and 2) 4 three reach 300 s, presenting until 266, 299 and 288 s; one 0xc0000005 at 83 s (+0x511e7d9, read at 0xffffffffffffffff)
with 3292b096 + this PR (d900644d) 0x501400000 (window 1) 4 0xc0000005 in the title at 186 s (+0x2215c35, write at 0x0), 97 s (+0x136ab, read at 0x648), 167 s (+0x4e735ed, read at 0xc8), 85 s (+0x7b619c, read at 0x0)
  • The PR does what it says for the pool on this layout: it is back in the sparse windows, and found no room in the sparse windows is not logged in any of the four runs.
  • The pool is not where the reverted tree puts it, though. Reverted, it starts at 0x5f9d00000 and runs into window 2. With the PR it starts at 0x501400000, 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 at 0xc8) appears both with 3292b096 alone and with the PR.
  • No device removal in any run. The three reverted runs that finished were over the video memory budget from about 70 s (16.2 to 16.9 GB local against 15.06 GB).

So on a 3-window layout without XCL_UMA_WINDOWS=16 this 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 another XCL_HOME_W0_KEEP_MB, or with XCL_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.

**@⁠tiagonleal** on GitHub · 2026-11-26 22:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905#issuecomment-7205109945) Tested `d900644d` on 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. With `3292b096` reverted 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-dev` `ea0698d4` (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`, no `XCL_UMA_WINDOWS`, no `XCL_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`. | tree | pool (63632 pages) at | runs of 300 s | ends | |---|---|---|---| | as above, with `3292b096` | `0xfd4fe0000` (outside the windows) | 3 | `0xc0000005` in the title at 175 s (`+0x5182154`, read at `0x3c54a9da013b`), 104 s (`+0x4e9a62e`, read at `0xffffffffffffffff`), 93 s (`+0x4e735ed`, read at `0xc8`) | | same, first run of the day (coherent window still 512 MB) | `0x2cfd90000` | 1 | `0xc0000005` at 83 s in `nvwgf2umx.dll+0x3b1722` (read at `0xe6d8`) | | `3292b096` reverted | `0x5f9d00000` (windows 1 and 2) | 4 | three reach 300 s, presenting until 266, 299 and 288 s; one `0xc0000005` at 83 s (`+0x511e7d9`, read at `0xffffffffffffffff`) | | with `3292b096` + this PR (`d900644d`) | `0x501400000` (window 1) | 4 | `0xc0000005` in the title at 186 s (`+0x2215c35`, write at `0x0`), 97 s (`+0x136ab`, read at `0x648`), 167 s (`+0x4e735ed`, read at `0xc8`), 85 s (`+0x7b619c`, read at `0x0`) | - The PR does what it says for the pool on this layout: it is back in the sparse windows, and `found no room in the sparse windows` is not logged in any of the four runs. - The pool is not where the reverted tree puts it, though. Reverted, it starts at `0x5f9d00000` and runs into window 2. With the PR it starts at `0x501400000`, 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 at `0xc8`) appears both with `3292b096` alone and with the PR. - No device removal in any run. The three reverted runs that finished were over the video memory budget from about 70 s (16.2 to 16.9 GB local against 15.06 GB). So on a 3-window layout without `XCL_UMA_WINDOWS=16` this 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 another `XCL_HOME_W0_KEEP_MB`, or with `XCL_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.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 22:57 UTC · original

Found a fragmented-window case on head d900644d. sparse_alloc_home tries 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=1 and cargo 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
diff --git a/crates/xcl/src/gpu/uma.rs b/crates/xcl/src/gpu/uma.rs
--- a/crates/xcl/src/gpu/uma.rs
+++ b/crates/xcl/src/gpu/uma.rs
@@
-            if let Some(at) = take_sparse_top_in(&mut g, lo, hi, size, align) {
+            let mut search_hi = hi;
+            while let Some(at) = take_sparse_top_in(&mut g, lo, search_hi, size, align) {
                 if free_runs_in(&g, lo, hi).1 >= w0_keep {
                     return Some((at, size));
                 }
                 give_back(&mut g, at);
+                // Moving within this free run cannot leave a larger remainder; try the
+                // next lower run before giving up on window 0.
+                search_hi = *g.0.range(..=at).next_back().unwrap().0;
             }
@@
     fn take_sparse_top_in_a_free_range_across_lo_bound() {
@@
     }

+    #[test]
+    fn physical_home_uses_lower_hole_when_it_preserves_window_0_margin() {
+        let u = Uma::for_runtime(16 << 20).unwrap();
+        let (free0, _) = u.sparse_free_in(0);
+        let low = u.sparse_alloc(32 << 20, GRAIN).unwrap().0;
+        let middle = u.sparse_alloc(free0 - (112 << 20), GRAIN).unwrap().0;
+        assert_eq!(u.sparse_release(low), Some(32 << 20));
+        assert_eq!(u.sparse_free_in(0), (112 << 20, 80 << 20));
+
+        let w1 = u.sparse_reserve(WINDOW).unwrap();
+        let w2_start = u.sparse_reserve(WINDOW - (4000 << 20)).unwrap();
+        assert_eq!(u.window_of(w2_start), Some(2));
+
+        let home = u.sparse_alloc_home(32 << 20, GRAIN, 64 << 20).unwrap().0;
+        assert_eq!(home, low, "lower hole leaves the 80 MB run intact");
+        assert_eq!(u.sparse_free_in(0).1, 80 << 20);
+        let pool = u.sparse_reserve(3977 << 20).expect("page pool still fits window 2");
+        assert_eq!(u.window_of(pool), Some(2));
+
+        for p in [home, middle, w1, w2_start, pool] {
+            assert!(u.sparse_release(p).is_some());
+        }
+        assert_eq!(u.sparse_used(), 0);
+    }

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.

**@⁠thehollowedone** on GitHub · 2026-11-26 22:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905#issuecomment-7205126878) Found a fragmented-window case on [head `d900644d`](https://github.com/xcl-dev/xcl/commit/d900644d90006e08a3fcde630515e339a550f4d5). `sparse_alloc_home` tries 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=1` and `cargo 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. <details><summary>Candidate fix and regression test</summary> ```diff diff --git a/crates/xcl/src/gpu/uma.rs b/crates/xcl/src/gpu/uma.rs --- a/crates/xcl/src/gpu/uma.rs +++ b/crates/xcl/src/gpu/uma.rs @@ - if let Some(at) = take_sparse_top_in(&mut g, lo, hi, size, align) { + let mut search_hi = hi; + while let Some(at) = take_sparse_top_in(&mut g, lo, search_hi, size, align) { if free_runs_in(&g, lo, hi).1 >= w0_keep { return Some((at, size)); } give_back(&mut g, at); + // Moving within this free run cannot leave a larger remainder; try the + // next lower run before giving up on window 0. + search_hi = *g.0.range(..=at).next_back().unwrap().0; } @@ fn take_sparse_top_in_a_free_range_across_lo_bound() { @@ } + #[test] + fn physical_home_uses_lower_hole_when_it_preserves_window_0_margin() { + let u = Uma::for_runtime(16 << 20).unwrap(); + let (free0, _) = u.sparse_free_in(0); + let low = u.sparse_alloc(32 << 20, GRAIN).unwrap().0; + let middle = u.sparse_alloc(free0 - (112 << 20), GRAIN).unwrap().0; + assert_eq!(u.sparse_release(low), Some(32 << 20)); + assert_eq!(u.sparse_free_in(0), (112 << 20, 80 << 20)); + + let w1 = u.sparse_reserve(WINDOW).unwrap(); + let w2_start = u.sparse_reserve(WINDOW - (4000 << 20)).unwrap(); + assert_eq!(u.window_of(w2_start), Some(2)); + + let home = u.sparse_alloc_home(32 << 20, GRAIN, 64 << 20).unwrap().0; + assert_eq!(home, low, "lower hole leaves the 80 MB run intact"); + assert_eq!(u.sparse_free_in(0).1, 80 << 20); + let pool = u.sparse_reserve(3977 << 20).expect("page pool still fits window 2"); + assert_eq!(u.window_of(pool), Some(2)); + + for p in [home, middle, w1, w2_start, pool] { + assert!(u.sparse_release(p).is_some()); + } + assert_eq!(u.sparse_used(), 0); + } ``` </details> 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.
Author
Owner

@⁠tiagonleal on GitHub · 2026-11-27 00:07 UTC · original

Correction to my comment above: the "3 of 4 runs reached 300 s with 3292b096 reverted" 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:

run driver blob absent compiles 2 s activity windows with 0 presents and 0 submits end
reverted s1 11 94 reached 300 s
reverted s2 1 5 0xc0000005 at 83 s
reverted s3 18 65 reached 300 s
reverted s4 14 79 reached 300 s
PR d900644d s1 to s4 1 each 20, 5, 6, 6 0xc0000005 in all four

So 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 eae01502 to eff3bcab): 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.

**@⁠tiagonleal** on GitHub · 2026-11-27 00:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905#issuecomment-7206190996) Correction to my comment above: the "3 of 4 runs reached 300 s with `3292b096` reverted" 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: | run | `driver blob absent` compiles | 2 s activity windows with 0 presents and 0 submits | end | |---|---|---|---| | reverted s1 | 11 | 94 | reached 300 s | | reverted s2 | 1 | 5 | `0xc0000005` at 83 s | | reverted s3 | 18 | 65 | reached 300 s | | reverted s4 | 14 | 79 | reached 300 s | | PR `d900644d` s1 to s4 | 1 each | 20, 5, 6, 6 | `0xc0000005` in all four | So 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 `eae01502` to `eff3bcab`): 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.
Author
Owner

@⁠LocranKing on GitHub · 2026-11-27 03:56 UTC · original

Independent paired verification on an 8 GB RTX 3060 Ti (Series S / lockhart profile): reproduces #2867 on nvidia-dev (ecc0bb57) and confirms #2905 fixes it.

Setup

  • Machine: Windows 11 Home build 26300, AMD Ryzen 5 5500 (6C/12T), 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8 GB, driver 621.40, nvprofile shader heap 2048 MB), DXC 1.9.2602.17.
  • Title & cache: Retail title 9cc6a39e, release builds, both runs starting from identical copies of a warm lockhart cache snapshot (1,296 used pipelines, 3,206 driver blobs), 250 s each.
  • Env: 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_AT sequence (18:A..74:A).
  • PR build note: pr-2905-head (d900644d) merged cleanly with origin/nvidia-dev (ecc0bb57; only a test change over eae01502).

Results (250 s paired runs)

tree result frames shown peak commit local / non-local VRAM peak
nvidia-dev (ecc0bb57) crash at 181.5 s (0xc0000005 read at 0xffffffffffffffff in game_scarlett_master.exe+0x51822b3; ended 186.1 s) none logged (1,732 presents in report.json before crash) 25,994 MB 9,022 / 4,708 MB
PR #2905 (d900644d + ecc0bb57) exit 0x0 (no crash, no device removal) 1,977 (presents per 2 s: 1 0 1) 29,327 MB 12,333 / 5,055 MB
xcl-smoke v1
commit: ecc0bb57976b1bc94854199ddf4f915fd00e0a59
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 250
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 2
peak commit: 25994 MB
xcl-smoke v1
commit: d900644d90006e08a3fcde630515e339a550f4d5
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 250
exit: 0x0
frames shown: 1977 (PresentX 1977)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 29327 MB

Not tested: XCL_COHERENT_HEAPS=sparse:1024, Series X (anaconda) profile, multiple runs per arm.

**@⁠LocranKing** on GitHub · 2026-11-27 03:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905#issuecomment-7209395048) Independent paired verification on an **8 GB RTX 3060 Ti** (`Series S` / `lockhart` profile): reproduces **#2867** on `nvidia-dev` (`ecc0bb57`) and confirms **#2905** fixes it. **Setup** - **Machine:** Windows 11 Home build 26300, AMD Ryzen 5 5500 (6C/12T), 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8 GB, driver `621.40`, `nvprofile` shader heap 2048 MB), DXC `1.9.2602.17`. - **Title & cache:** Retail title `9cc6a39e`, release builds, both runs starting from identical copies of a warm `lockhart` cache snapshot (`1,296` used pipelines, `3,206` driver blobs), `250 s` each. - **Env:** `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_AT` sequence (`18:A..74:A`). - **PR build note:** `pr-2905-head` (`d900644d`) merged cleanly with `origin/nvidia-dev` (`ecc0bb57`; only a test change over `eae01502`). **Results (250 s paired runs)** | tree | result | frames shown | peak commit | local / non-local VRAM peak | |---|---|---:|---:|---:| | `nvidia-dev` (`ecc0bb57`) | **crash** at `181.5 s` (`0xc0000005` read at `0xffffffffffffffff` in `game_scarlett_master.exe+0x51822b3`; ended `186.1 s`) | none logged (`1,732` presents in `report.json` before crash) | 25,994 MB | 9,022 / 4,708 MB | | **PR `#2905`** (`d900644d` + `ecc0bb57`) | **exit `0x0` (no crash, no device removal)** | **1,977** (`presents per 2 s: 1 0 1`) | 29,327 MB | 12,333 / 5,055 MB | ```text xcl-smoke v1 commit: ecc0bb57976b1bc94854199ddf4f915fd00e0a59 gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 250 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 2 peak commit: 25994 MB ``` ```text xcl-smoke v1 commit: d900644d90006e08a3fcde630515e339a550f4d5 gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 250 exit: 0x0 frames shown: 1977 (PresentX 1977) presents per 2 s (last 3): 1 0 1 device removals: 0 crashes: 0 peak commit: 29327 MB ``` **Not tested:** `XCL_COHERENT_HEAPS=sparse:1024`, Series X (`anaconda`) profile, multiple runs per arm.
Author
Owner

@⁠pr1sm-dev on GitHub · 2026-11-27 08:19 UTC · original

Test of d900644d on 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-dev eae01502 + 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.

run XCL_COHERENT_HEAPS pool (63632 pages) the new WARN end
1 sparse:1024 in the sparse windows, window 1 + 20 MB as in the PR fired 16 s after the title started 0x887a0006 43 s after the title started, on the loading screen (1,018 presents)
2 not set (coherent window 3407 MB, 3008 MB used) same place did not fire 0x887a0006 28 s after the title started, on the loading screen (607 presents)
  • The WARN in run 1: 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).
  • Both removals: XCL logs DRED device state 7 and no breadcrumbs (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).
  • For comparison on this card: on eae01502 without the PR, 1 of 7 runs ended with 0x887a0006 and state 7 on the loading screen (69 s after the title started; the one run that had XCL_DRED=1 and the graphics prebuild on). Two more ended there with 0x887a0005 at 97 to 98 s, before the shader-heap profile was installed; the other four got to the world load. With 3292b096 reverted instead, on e0821b12, none of 3 runs did, and with sparse:1024 the 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_MB other 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.

**@⁠pr1sm-dev** on GitHub · 2026-11-27 08:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2905#issuecomment-7213406415) **Test of `d900644d` on 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-dev` `eae01502` + 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. | run | `XCL_COHERENT_HEAPS` | pool (63632 pages) | the new WARN | end | |---|---|---|---|---| | 1 | `sparse:1024` | in the sparse windows, window 1 + 20 MB as in the PR | fired 16 s after the title started | `0x887a0006` 43 s after the title started, on the loading screen (1,018 presents) | | 2 | not set (coherent window 3407 MB, 3008 MB used) | same place | did not fire | `0x887a0006` 28 s after the title started, on the loading screen (607 presents) | - **The WARN in run 1:** `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). - **Both removals:** XCL logs DRED device state 7 and no breadcrumbs (`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). - **For comparison on this card:** on `eae01502` without the PR, 1 of 7 runs ended with `0x887a0006` and state 7 on the loading screen (69 s after the title started; the one run that had `XCL_DRED=1` and the graphics prebuild on). Two more ended there with `0x887a0005` at 97 to 98 s, before the shader-heap profile was installed; the other four got to the world load. With `3292b096` reverted instead, on `e0821b12`, none of 3 runs did, and with `sparse:1024` the 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_MB` other 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2905/head:github-bot/gh-2905'
git switch 'github-bot/gh-2905'

Merge

Merge the changes and update on Forgejo.
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2905'
git switch 'github-bot/gh-2905'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2905'
git switch 'github-bot/gh-2905'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2905'
git switch 'nvidia-dev'
git merge --squash 'github-bot/gh-2905'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2905'
git switch 'nvidia-dev'
git merge 'github-bot/gh-2905'
git push origin 'nvidia-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.