kernelx: keep lazy pages on failed MEM_COMMIT (#467) #482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/487"
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 Grimkaaah on 2026-11-24T00:58:35Z.
Summary
LAZYonly afterVirtualAlloc(MEM_COMMIT)succeeds, so a commitment-limit failure can be retried instead of becoming a bare0xc0000005on still-reserved memory.count, last page,GetLastError) and appendfail_summary()to the AV crash line ineh.rs.lazy::ensurenow returnsbool; DirectStoragewritable()fails closed when a destination page cannot be committed.Fixes #467
Test plan
cargo test -p xcl --lib hle::kernelx::lazy::(3 passed, including failed-commit keeps page lazy)Imported from ivall/xcl. Originally posted by mdberkey on 2026-11-24T00:59:04Z.
Review: COMMENTED
t
Imported from ivall/xcl. Originally posted by shdann on 2026-11-24T01:01:40Z.
Review: COMMENTED
lazy::ensurecan reject a writable destination when two callers snapshot the same lazy page. The first caller commits it and removes it fromLAZY. The second then getsfalsefromcommitbecause the entry is gone.dstorage::writabletreats that as a commit failure and rejects the request. Please distinguish an entry that is already gone from a failedVirtualAlloc, and let the existing writability check handle the former. A two-caller test should check that both requests succeed when the page was committed successfully. Static review with OpenAI Codex (GPT-6).upstream-sync referenced this pull request2026-11-24 06:58:47 +00:00
Imported from ivall/xcl. Originally posted by brothernog on 2026-11-24T01:44:00Z.
Tested
bf21bcbon an RTX 3050 (driver 610.88), Windows 11 Home 26300, Rust 1.100.0, debug. This adds one thing to the comparison on #467, about thedstorage.rshunk: it does change behaviour, and it can refuse a healthy destination.ensuretakes the lazy pages under the read lock (lazy.rs:129), drops it, then callscommitfor each.commitreturnsfalsewhen the page is no longer inLAZY(lazy.rs:67), which is also the case when another thread committed it in between: a secondensure, or the title touching the page and the vectored handler committing it.ensurethen reports a failure, andwritable(dstorage.rs:728) fails a request whose pages are all committed and writable.I added a temporary test (removed afterwards): 256 lazy pages, two threads behind a barrier call
ensureover the same range. In 5 of 5 runs at least one call returnedfalse(4 runs[false, false], 1 run[true, false]), and every page was committed afterwards.Dropping the hunk keeps the fix:
writablealready checks every page withVirtualQueryafterensure, so a page that stayed reserved fails there. If you want the bool kept,commitcould tell "not lazy any more" apart from "the commit failed", andensurecould returnfalseonly for the second case.This review was AI-assisted.
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:16:00Z.
Test run of
bf21bcba64680fb85a01e4802a86971af03c4e36on AMD RDNA4. I merged it onto currentmain6025201locally (clean merge).Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 705 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 664 passed, 0 failed, 21 ignoredSKIPPED; thelazytests pass, the failed-commit one included.Review: Removing a lazy page from
LAZYonly afterMEM_COMMITsucceeds is right. Overlap with #512 (open), whose title is about the e2e test output but which also changeskernelx/lazy.rsto keep the page on a failed commit; the two will conflict there, and this PR is the one that is about #467.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by asd3670576 on 2026-11-24T10:25:03Z.
Built and tested the PR head on a Windows 10 machine that has no Shader Model 6.6 and only a GNU toolchain. Every count below is pasted from the run, not written by hand.
Machine
x86_64-pc-windows-gnu(no MSVC, no Windows SDK:cargo buildhere needs MinGW-w64 on PATH or it dies witherror calling dlltool 'dlltool.exe': program not found), Ryzen 9 5950X (32 logical CPUs), 64 GB RAM.H:\leonida\dxc\bin\x64(XCL_DXC_DIR). Agility 1.620.2 atH:\leonida\agility\build\native\bin\x64(XCL_D3D12_DIR) but it cannot load on this OS build (noID3D12SDKConfiguration1before KB5029331), so the inbox runtime caps at Shader Model 6.5 and XCL's GPU recompiler path is unavailable here.xcl-smokeblock from this machine.Apply / build
git fetch https://github.com/ivall/xcl pull/487/head:pr487→bf21bcba64680fb85a01e4802a86971af03c4e36, checked out as-is: no rebase, no conflict resolution,git status --porcelainempty before the build and after it. The API reportsmergeable: true,mergeable_state: unstableagainst currentmain.cargo build --release --workspace→ exit code 0:Tests
cargo test --release -p xcl --lib -- kernelx::lazy, three runs on the default thread count:cargo test --release -p xcl --lib -- gpu::recomp::dxc:cargo test --release -p xcl --lib -- kernelx::lazy gpu::recomp::dxc(both modules in one process, default threads):cargo test --release --workspace --no-fail-fast -- --test-threads=4→ exit code 0. 16test result:lines (one per test binary plus the doc-test run); the xcl lib is:all 16 are
ok; summed over them: 677 passed; 0 failed; 41 ignored. Skips, reported rather than counted as coverage: 86SKIPPEDlines, 84: no GPUand 2: no wave64, for exampleForcing the requirement shows the SM 6.5 cap directly (
XCL_REQUIRE_GPU=mesh cargo test --release -p xcl --lib -- --exact gpu::recomp::tests::gpu_bvh_intersect_ray):On the
dstorage.rshunk. The code in this head agrees with @brothernog's reading:commitreturnsfalseboth when the page is no longer inLAZY(another thread committed it) and whenVirtualAllocfails, andensuremaps either one tofalse. The pre-existingthreads_first_touching_one_lazy_page_together_all_go_ondrives the pages through the vectored handler rather than throughensureand asserts nothing about a return value, so it cannot catch that case; the new test covers the failed-commit path only. I did not measure the race itself here.What this machine can and cannot verify. It can verify that the head builds in release with the GNU toolchain, that the three
kernelx::lazytests are stable here (3/3, and 17/17 with the dxc tests in the same process), and that nothing else in the workspace regresses. It cannot verify the case the fix is about: with 64 GB of RAM and a 153 GB commit limit (125 GB of it free) nothing here reachesERROR_COMMITMENT_LIMIT, socommit's failure branch only runs because the test injects a failing allocator. And because the adapter caps at SM 6.5, no GPU test executed at all — the 84 skips are the whole GPU surface, so this run says nothing about the recompiler paths.AI use: an agent (DeepSeek Harness, "auto" route - I do not know the underlying model) built the head, ran the tests and pasted the output.
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T21:15:15Z.
Two contributors checked independently and found that #488 solves the same problem (for #467) in a different way: #1607, group D13. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T02:56:02Z.
Regression run of
bf21bcbaon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 90 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:05:08Z.
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!
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:35:29Z.
Triage (#1607) – head
bf21bcbUpdate (rechecked against main
6bfb5c51): withdrawn from the close list; recommendation: keep open. Its proposed carrier #488 was closed today, and main still drops the lazy page beforeVirtualAlloc(lazy.rs:39-45), so this is the only open fix for #467. Thedstorage.rspart should be dropped, or made to tell "already committed" apart from "commit failed".#488 makes the same change in
hle/kernelx/lazy.rsandeh.rs:commitcheckscontains, removes the page only whenVirtualAlloc(MEM_COMMIT)succeeds, records the count, page andGetLastErrorin atomics, and appends a summary to the crash line. #488 also names the error code and tests a real commit limit (job object).Problem in the extra part:
ensurenow returns false whenevercommitreturns false, including when the page is no longer inLAZYbecause another thread committed it between the read-lockedrangeand the write-lockedcommit. With parallel DirectStorage requests (#819) into the same 64 KiB page,dstorage.rswritablethen fails a valid request withE_ACCESS_VIOLATION.commitwould need to tell 'already committed' apart from 'commit failed'.Recommendation: close (duplicate of #488).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run.
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.