D3D12.X: readable checks remember pages and probe instead of asking Wine #3021
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3021"
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 voiceovarian1-max on 2026-11-27T12:45:28Z.
For nvidia-dev.
shader::readableguards XCL's reads of title pointers: vtables inis_adopted, the title's view descs, code bytes. Under Wine each answer is a system call (K32QueryWorkingSetEx/VirtualQuery) under Wine's virtual-memory lock, ~20 µs each and more while other threads commit or free memory. In a retail title's world there were 70,000–126,000 checks per 2 s, about 4 per draw or dispatch, which took 1.5–2.8 s of the title's threads per 2 s.There are two parts:
readable_freshskips the remembered pages for memory that may have been freed since: the next page of an instruction (eh::code_bytes_at).IsBadReadPtrinstead of being asked of the system. Wine'sIsBadReadPtrcatches access violations only, and a guard page it read ended the process. So during the probe a vectored handler puts the guard back and turns the guard-page fault into an access violation.XCL_READABLE_PROBE=0asks the system, as before.What is in it
gpu/shader.rs:SEEN,readable_fresh,probe_on,probe_guard_page,readable_asked(the old body).eh.rs:code_bytes_atusesreadable_fresh.hle/d3d12x/list_x.rs: the GPU-address test checks the freed page on a thread of its own, because the page it bound is remembered on its thread.gpu/shader.rs's working-set test expects the probe's answer under Wine.Tested
x86_64-pc-windows-gnu, release. Head14842863on nvidia-dev3f39671d.cargo test -p xcl --lib -- --test-threads=4): 1691 passed, 8 failed, 28 ignored. The same 8 tests fail on nvidia-dev3f39671d.Regression run
scripts/smoke.ps1needs Windows, and we only have Linux. On Windows only the page memory applies.Not tested
VirtualQuerythere was not measured, so whether the page memory helps there is unknown), AMD, a retail title on this branch.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by GreemSC on 2026-11-27T13:33:08Z.
Tested on AMD under Wine, on a port of this PR rather than its own branch: amd-dev
7c795f5e+ a local Wine stack, withreadable_askedadapted to amd-dev'sresident_and_readable(p, end) -> bool(amd-dev has nopages_readable). RX 7900 XT, Mesa 26.2.5 RADV, Proton-CachyOS, vkd3d-proton master (0bb64c5), kernel 7.2, retail title, Series X profile, 360 s scripted runs.radv/amdgpu: Failed to clear a PRT VA region (-22)and gfxhub page faults.0x887a0005, gfxhub page faults, a compute ring reset).XCL_READABLE_PROBE=0on the same exe: the run reached 360 s with no fault (1 run).Not verified, a guess: amd-dev commits full read-write sparse title pages on their first CPU access (
97d83b5b,kernelx::lazy). A probe read of such a page commits it outside the paths that expect it. If so, nvidia-dev would not be affected.Locally we now leave the probe off unless
XCL_READABLE_PROBE=1, and keep the per-thread page memory. Not tested: your branch itself, NVIDIA, Windows.Tested and written by Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:20:42Z.
Triage (#1607) – head
1484286No open or merged PR makes the same change (#2437 and #501 avoid
readable()on other paths).Problems in
gpu/shader.rs:SEENcache is not limited to Wine. On Windows too,readablenow answers true for a page that was freed or protected within 250 ms on the same thread. The list_x test had to move its check to a new thread for this reason.IsBadReadPtron akernelx::lazypage faults intolazy.rs's vectored handler, which commits the 64 KiB page. Before, VirtualQuery answered "not readable" without committing it, so a check can now commit pages that lazy.rs keeps uncommitted on purpose.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T11:01:20Z.
Review (head
1484286, diff read, not a merge-check; draft,PR descriptionred):XCL_READABLE_PROBE=0. A likely cause:IsBadReadPtron a not-yet-committed lazy page triggerskernelx/lazy.rs's handler (~52), which commits it.VirtualQueryused to answer "not readable" without committing, so the probe both commits memory lazy.rs keeps uncommitted on purpose and flips the answer to true.shader.rs~229). On Windows too, a page freed or protected within 250 ms (SEEN_FOR, ~295) still reads as readable on that thread, so XCL can dereference it and crash. Thelist_x.rs~8411 test had to move its check to a new thread for that reason. Nothing clears the memory when a page is freed, and the Windows gain wasn't measured.shader.rs~710 weakens a test, which AGENTS.md rules out.nvidia-dev, though the PR targets main; there's no Windows run and no smoke pair.VirtualProtect) is unverified.Fine: the probe itself is gated on
under_wine()and the variable (~258), it merges cleanly, andcode_bytes_atskips the memory. #2437 and #501 avoidreadable()on other paths.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.