kernelx: handle self-home/reused-home mappings in map_pages and unmap away pages on VirtualFree #2544

Open
github-bot wants to merge 1 commit from github-bot/gh-2544 into main AGit
Owner

@⁠Decodere on GitHub · 2026-11-25 22:32 UTC · original
Decodere:fix-kernelx-map-pages-virtualfree → main · +252 −3 · 1 files · 1 commits · open

Fixes two physical-page mapping bookkeeping bugs in crates/xcl/src/hle/kernelx.rs: self-home / reused-home decommits and UB in map_pages, and dangling AWAY / LAZY entries left behind when VirtualFree decommits or releases sparse UMA or plain MEM_PRIVATE reservations. Part of #1833, Part of #1566, Part of #697.

What is in it

  • crates/xcl/src/hle/kernelx.rs (map_pages): resolve page_home(p) safely right after skipping p == 0; when a non-consecutive multi-page mapping places a page at its own home (at == home), commit the home via commit_homes(home, 1), drop home from away.gone, unmap any prior away mapping directly back to home, and skip the away-copy path (avoiding ptr::copy_nonoverlapping(home, home, ...) UB, bogus (home, p) AWAY insertion, and subsequent give_back_homes decommit).
  • crates/xcl/src/hle/kernelx.rs (map_pages): remove at from away.gone whenever another page is mapped onto at (across move_away, the lazy path, and the commit/copy path before move_home_away) so give_back_homes never decommits a reused home within the same multi-page or XMemMapPhysicalPagesScatter call.
  • crates/xcl/src/hle/kernelx.rs (VirtualFree, unmap_away_with, unmap_away_in, unmap_away_range, plain_free_range, unmap_away_for_plain_free): detach overlapping AWAY/LAZY pages (copying committed bytes back to home and clearing lazy marks) before decommitting or releasing sparse UMA reservations or validated plain MEM_PRIVATE reservations without calling release_at() for the full PHYS_PAGE (64 KiB), so native VirtualFree retires only the exact requested 4 KiB OS pages and preserves neighboring committed host pages on sub-64 KiB MEM_DECOMMIT; validate plain MEM_PRIVATE MEM_DECOMMIT ranges at 4 KiB OS-page granularity (req_start..req_end instead of m.BaseAddress) with a zero-syscall fast path when no away candidate overlaps so invalid calls and adjacent committed away pages in the same MBI region leave unrelated AWAY entries intact.
  • crates/xcl/src/hle/kernelx.rs (hle::kernelx::tests): added 4 pure-CPU 0-skip unit tests:
    • map_pages_at_own_home_preserves_data_without_away_entry
    • scatter_reusing_moved_home_does_not_decommit_new_mapping
    • virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations
    • plain_subpage_decommit_preserves_neighbor_pages_and_home_copy (verifying middle-4 KiB MEM_DECOMMIT on a committed 64 KiB away page inside a two-page contiguous MEM_PRIVATE reservation leaves neighboring 4 KiB pages MEM_COMMIT with sentinels intact, detaches only the affected away page while leaving the adjacent away page in the same MBI run untouched, and preserves the full 64 KiB home snapshot on remap).

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: Windows 11 Home (build 26200), NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F (6C/12T), 32 GB RAM, rustc 1.100.0, DXC 1.9.2609.5, --release.
  • Failing-first on unmodified e1d84b7d: all 3 initial hle::kernelx::tests failed cleanly (0 passed; 3 failed: self-home page must remain committed, reused home (from home) must stay committed, partial plain MEM_DECOMMIT must unmap away page).
  • Post-fix targeted cargo test --release -p xcl --lib -- hle::kernelx::tests:: --test-threads=1 --nocapture: 44 passed, 0 failed, 1 ignored (scatter_timing), 0 skips on both WARP (XCL_ADAPTER=warp, 1.54 s) and RTX 4060 (1.48 s).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 37 test binaries, 1439 passed, 0 failed, 47 ignored (SKIPPED GPU/host tests: 29 pre-existing on 32-lane RTX 4060 without D3D12 debug layer — 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in hle::kernelx::tests).

Regression run

main (origin/main ancestor 889ef3e8aa7f267323ab4879e735e65da6bcef10, ancestor of b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):

xcl-smoke v1
commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1550 (PresentX 1550)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13981 MB

PR:

xcl-smoke v1
commit: c9743291468a625b0c5be41cac08bd6bcfaf4996
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1558 (PresentX 1558)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13991 MB

Not tested

  • 64-lane AMD hardware (wave64 GPU tests skipped on 32-lane RTX 4060) and D3D12 debug-layer tests (SDK layers DLL not installed on host).
  • scatter_timing (#[ignore] benchmark test in hle::kernelx::tests) and the 47 #[ignore] workspace tests.

AI use

  • Google Antigravity (Gemini 4 Neon) implemented the map_pages and VirtualFree fixes (including sub-page MEM_DECOMMIT preservation and 4 KiB OS-page range bounds), added the 4 unit tests, verified failing-first and post-fix test suites and paired 60 s smoke runs, and drafted this PR description.
**@⁠Decodere** on GitHub · 2026-11-25 22:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544) `Decodere:fix-kernelx-map-pages-virtualfree` → `main` · +252 −3 · 1 files · 1 commits · open Fixes two physical-page mapping bookkeeping bugs in `crates/xcl/src/hle/kernelx.rs`: self-home / reused-home decommits and UB in `map_pages`, and dangling `AWAY` / `LAZY` entries left behind when `VirtualFree` decommits or releases sparse UMA or plain `MEM_PRIVATE` reservations. Part of #1833, Part of #1566, Part of #697. **What is in it** - `crates/xcl/src/hle/kernelx.rs` (`map_pages`): resolve `page_home(p)` safely right after skipping `p == 0`; when a non-consecutive multi-page mapping places a page at its own home (`at == home`), commit the home via `commit_homes(home, 1)`, drop `home` from `away.gone`, unmap any prior away mapping directly back to `home`, and skip the away-copy path (avoiding `ptr::copy_nonoverlapping(home, home, ...)` UB, bogus `(home, p)` `AWAY` insertion, and subsequent `give_back_homes` decommit). - `crates/xcl/src/hle/kernelx.rs` (`map_pages`): remove `at` from `away.gone` whenever another page is mapped onto `at` (across `move_away`, the lazy path, and the commit/copy path before `move_home_away`) so `give_back_homes` never decommits a reused home within the same multi-page or `XMemMapPhysicalPagesScatter` call. - `crates/xcl/src/hle/kernelx.rs` (`VirtualFree`, `unmap_away_with`, `unmap_away_in`, `unmap_away_range`, `plain_free_range`, `unmap_away_for_plain_free`): detach overlapping `AWAY`/`LAZY` pages (copying committed bytes back to home and clearing lazy marks) before decommitting or releasing sparse UMA reservations or validated plain `MEM_PRIVATE` reservations without calling `release_at()` for the full `PHYS_PAGE` (64 KiB), so native `VirtualFree` retires only the exact requested 4 KiB OS pages and preserves neighboring committed host pages on sub-64 KiB `MEM_DECOMMIT`; validate plain `MEM_PRIVATE` `MEM_DECOMMIT` ranges at 4 KiB OS-page granularity (`req_start..req_end` instead of `m.BaseAddress`) with a zero-syscall fast path when no away candidate overlaps so invalid calls and adjacent committed away pages in the same MBI region leave unrelated `AWAY` entries intact. - `crates/xcl/src/hle/kernelx.rs` (`hle::kernelx::tests`): added 4 pure-CPU `0`-skip unit tests: - `map_pages_at_own_home_preserves_data_without_away_entry` - `scatter_reusing_moved_home_does_not_decommit_new_mapping` - `virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations` - `plain_subpage_decommit_preserves_neighbor_pages_and_home_copy` (verifying middle-4 KiB `MEM_DECOMMIT` on a committed 64 KiB away page inside a two-page contiguous `MEM_PRIVATE` reservation leaves neighboring 4 KiB pages `MEM_COMMIT` with sentinels intact, detaches only the affected away page while leaving the adjacent away page in the same MBI run untouched, and preserves the full 64 KiB home snapshot on remap). **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: Windows 11 Home (build 26200), NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F (6C/12T), 32 GB RAM, `rustc 1.100.0`, DXC `1.9.2609.5`, `--release`. - Failing-first on unmodified `e1d84b7d`: all 3 initial `hle::kernelx::tests` failed cleanly (`0 passed; 3 failed`: `self-home page must remain committed`, `reused home (from home) must stay committed`, `partial plain MEM_DECOMMIT must unmap away page`). - Post-fix targeted `cargo test --release -p xcl --lib -- hle::kernelx::tests:: --test-threads=1 --nocapture`: `44 passed, 0 failed, 1 ignored` (`scatter_timing`), `0` skips on both WARP (`XCL_ADAPTER=warp`, `1.54 s`) and RTX 4060 (`1.48 s`). - `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: `37` test binaries, `1439 passed, 0 failed, 47 ignored` (SKIPPED GPU/host tests: 29 pre-existing on 32-lane RTX 4060 without D3D12 debug layer — 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in `hle::kernelx::tests`). **Regression run** main (`origin/main` ancestor `889ef3e8aa7f267323ab4879e735e65da6bcef10`, ancestor of `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`): ``` xcl-smoke v1 commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1550 (PresentX 1550) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13981 MB ``` PR: ``` xcl-smoke v1 commit: c9743291468a625b0c5be41cac08bd6bcfaf4996 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1558 (PresentX 1558) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13991 MB ``` **Not tested** - 64-lane AMD hardware (wave64 GPU tests skipped on 32-lane RTX 4060) and D3D12 debug-layer tests (SDK layers DLL not installed on host). - `scatter_timing` (`#[ignore]` benchmark test in `hle::kernelx::tests`) and the 47 `#[ignore]` workspace tests. **AI use** - Google Antigravity (Gemini 4 Neon) implemented the `map_pages` and `VirtualFree` fixes (including sub-page `MEM_DECOMMIT` preservation and 4 KiB OS-page range bounds), added the 4 unit tests, verified failing-first and post-fix test suites and paired 60 s smoke runs, and drafted this PR description.
Fix two physical-page bookkeeping bugs in kernelx:

1. map_pages self-home and reused-home handling:
   - In non-consecutive multi-page MapTitlePhysicalPages calls where a page maps
     to its own home (at == home), commit the home, clear it from away.gone, and
     unmap any prior away mapping directly back to home instead of falling into
     ptr::copy_nonoverlapping(home, home, ...) and queuing the live home in
     away.gone for decommit.
   - Whenever a page is mapped onto an address at (via move_away, lazy, or the
     commit/copy path before move_home_away), clear at from away.gone so
     give_back_homes never decommits a home reused within the same multi-page
     or scatter call.

2. VirtualFree unmapping of away-mapped physical pages:
   - Unmap overlapping AWAY/LAZY entries (preserving committed bytes back to
     home and clearing lazy marks) before decommitting or releasing sparse UMA
     or plain MEM_PRIVATE reservations.
   - Validate plain MEM_PRIVATE ranges with a zero-syscall fast path when no
     away candidate overlaps, so invalid VirtualFree calls leave AWAY intact.

Part of #1833
Part of #1566
Part of #697

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:24 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 22:46 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!

**@⁠DavidM1911** on GitHub · 2026-11-25 22:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#issuecomment-7176778481) 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!
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-25 22:52 UTC · original · edited 2026-11-25 22:56 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 19abb35 (on its base e1d84b7).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1414 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: map_pages_at_own_home_preserves_data_without_away_entry, scatter_reusing_moved_home_does_not_decommit_new_mapping, virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1425 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main e1d84b7 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-25 22:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#issuecomment-7176879333) · edited 2026-11-25 22:56 UTC Full-suite run, since this PR has no test report yet. Tested exact head `19abb35` (on its base `e1d84b7`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **1414 passed, 0 failed, 44 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `dispatch_chain_native_wave64_builds_whole`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `map_pages_at_own_home_preserves_data_without_away_entry`, `scatter_reusing_moved_home_does_not_decommit_new_mapping`, `virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **1425 passed, 0 failed, 46 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `e1d84b7` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-25 22:57 UTC · original

Test run on exact head 19abb35 (19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df, on its base e1d84b7, current main), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib map_pages_at_own_home: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • map_pages_at_own_home_preserves_data_without_away_entry: ok
    • scatter_reusing_moved_home_does_not_decommit_new_mapping: ok
    • virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1152 (PresentX 1152)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14791 MB

No crash or device removal; frames 106 % of main's, peak commit 100 %.

Not tested

  • Whether the title maps pages at their own home or reuses a moved home in this run: a regression check only
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
**@⁠xpatfussy69x** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#issuecomment-7176974611) Test run on exact head `19abb35` (`19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df`, on its base `e1d84b7`, current `main`), clean tree. **Tested** - NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs - `cargo test --workspace -- --test-threads=4`: 1426 passed, 0 failed, 46 ignored - SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` (on `main` too) - `cargo test -p xcl --lib map_pages_at_own_home`: 1 passed, 0 failed - This PR's new tests in the workspace run: - `map_pages_at_own_home_preserves_data_without_away_entry`: ok - `scatter_reusing_moved_home_does_not_decommit_new_mapping`: ok - `virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations`: ok **Regression run** (60 s, default settings, a retail title) main: ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1091 (PresentX 1091) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14814 MB ``` this PR: ``` xcl-smoke v1 commit: 19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1152 (PresentX 1152) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14791 MB ``` No crash or device removal; frames 106 % of `main`'s, peak commit 100 %. **Not tested** - Whether the title maps pages at their own home or reuses a moved home in this run: a regression check only - AMD / native wave64 **AI use** - Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 23:24 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of map_pages_at_own_home_preserves_data_without_away_entry, scatter_reusing_moved_home_does_not_decommit_new_mapping, virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations: 3 passed. CPU-side, fine under the Wine lane.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 23:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#issuecomment-7177528837) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `map_pages_at_own_home_preserves_data_without_away_entry`, `scatter_reusing_moved_home_does_not_decommit_new_mapping`, `virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations`: 3 passed. CPU-side, fine under the Wine lane. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:02 UTC · original · reviewed

Could the plain MEM_DECOMMIT path preserve host pages outside the requested range? With a committed 64 KiB away mapping in a plain MEM_PRIVATE reservation, VirtualFree(base + 4096, 4096, MEM_DECOMMIT) now selects the enclosing away page. unmap_away calls release_at, which decommits the full PHYS_PAGE (64 KiB) before the wrapper forwards the original 4 KiB call. On main, the plain path forwards that call directly to native VirtualFree.

I checked the Windows granularity separately: decommitting only the middle 4 KiB of a committed 64 KiB reservation left the 0/4K/8K offsets MEM_COMMIT / MEM_RESERVE / MEM_COMMIT; decommitting the full 64 KiB left all three MEM_RESERVE. Could this path clear the away bookkeeping and preserve its home copy while letting the native call retire only the requested plain pages? The added “partial” test requests PHYS_PAGE, so a sub-page decommit with committed sentinels on both sides would cover this difference.

Exact-head source trace at 19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df and native Win32 API probe only; I did not run XCL's wrapper or a title. AI-assisted review with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#pullrequestreview-6069796573) · **reviewed** Could the plain `MEM_DECOMMIT` path preserve host pages outside the requested range? With a committed 64 KiB away mapping in a plain `MEM_PRIVATE` reservation, `VirtualFree(base + 4096, 4096, MEM_DECOMMIT)` now selects the enclosing away page. `unmap_away` calls `release_at`, which decommits the full `PHYS_PAGE` (64 KiB) before the wrapper forwards the original 4 KiB call. On main, the plain path forwards that call directly to native `VirtualFree`. I checked the Windows granularity separately: decommitting only the middle 4 KiB of a committed 64 KiB reservation left the 0/4K/8K offsets `MEM_COMMIT / MEM_RESERVE / MEM_COMMIT`; decommitting the full 64 KiB left all three `MEM_RESERVE`. Could this path clear the away bookkeeping and preserve its home copy while letting the native call retire only the requested plain pages? The added “partial” test requests `PHYS_PAGE`, so a sub-page decommit with committed sentinels on both sides would cover this difference. Exact-head source trace at `19abb354ddcbc98bec7b6a2eb54e4d18ac9ab9df` and native Win32 API probe only; I did not run XCL's wrapper or a title. AI-assisted review with Codex.
github-bot force-pushed github-bot/gh-2544 from 19abb354dd to c974329146 2026-11-26 07:35:58 +00:00 Compare
Author
Owner

@⁠Decodere on GitHub · 2026-11-26 07:35 UTC · original

@⁠luckyteagirl Great catch — pushed c9743291 (rebased onto b49be183) fixing this and a related MBI-start boundary case:

  1. unmap_away_in now uses unmap_away_with(..., release_backing = false), detaching AWAY/LAZY bookkeeping and copying committed 64 KiB bytes back to home without calling release_at() for the full PHYS_PAGE, so native VirtualFree retires only the exact requested 4 KiB host pages.
  2. plain_free_range (MEM_DECOMMIT, size > 0) now bounds the range by 4 KiB OS pages (req_start..req_end) rather than m.BaseAddress, so sub-page decommits in one away page never detach an adjacent committed away page in the same contiguous VirtualQuery region.
  3. Added plain_subpage_decommit_preserves_neighbor_pages_and_home_copy covering two adjacent committed 64 KiB away pages with a middle-4 KiB MEM_DECOMMIT and committed sentinels on both sides (MEM_COMMIT / MEM_RESERVE / MEM_COMMIT), verifying the adjacent page stays in AWAY and remapping restores the full 64 KiB home snapshot.
  4. Re-verified release WARP & RTX 4060 hle::kernelx::tests:: (44/0/1, 0 skipped), full release workspace (1439/0/47), and paired 60 s RTX 4060 smoke (1558 frames, 60 60 60, 0 removals/crashes).
**@⁠Decodere** on GitHub · 2026-11-26 07:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2544#issuecomment-7185612572) @⁠luckyteagirl Great catch — pushed `c9743291` (rebased onto `b49be183`) fixing this and a related MBI-start boundary case: 1. `unmap_away_in` now uses `unmap_away_with(..., release_backing = false)`, detaching `AWAY`/`LAZY` bookkeeping and copying committed 64 KiB bytes back to home without calling `release_at()` for the full `PHYS_PAGE`, so native `VirtualFree` retires only the exact requested 4 KiB host pages. 2. `plain_free_range` (`MEM_DECOMMIT`, `size > 0`) now bounds the range by 4 KiB OS pages (`req_start..req_end`) rather than `m.BaseAddress`, so sub-page decommits in one away page never detach an adjacent committed away page in the same contiguous `VirtualQuery` region. 3. Added `plain_subpage_decommit_preserves_neighbor_pages_and_home_copy` covering two adjacent committed 64 KiB away pages with a middle-4 KiB `MEM_DECOMMIT` and committed sentinels on both sides (`MEM_COMMIT / MEM_RESERVE / MEM_COMMIT`), verifying the adjacent page stays in `AWAY` and remapping restores the full 64 KiB home snapshot. 4. Re-verified release WARP & RTX 4060 `hle::kernelx::tests::` (`44/0/1`, `0` skipped), full release workspace (`1439/0/47`), and paired 60 s RTX 4060 smoke (`1558` frames, `60 60 60`, `0` removals/crashes).
This pull request can be merged automatically.
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/2544/head:github-bot/gh-2544'
git switch 'github-bot/gh-2544'

Merge

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