d3d12: return committed guest pages after a failed buffer import retry #576
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/576"
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 brcly/TuxBox. Originally posted by csj0oe on 2026-11-30T06:57:12Z.
What
When a buffer import fails,
import_with_commitcommits the guest pages and retries the same import. Today it commits the whole range even when nothing there is reserved; with this change it commits only the reserved spans and retries only when it committed something.VirtualQuerythe range first and commit only the spans that are still reserved.MEM_DECOMMITa title thread can commit and write the same pages, and the decommit would drop its data.Why it matters
Measured, not assumed: with this change alone the frame-0 watchdog still fired in one run (run26, exit code 5 after 43.1 s, crash at
game_scarlett_master.exe+0x2215C35). The pipeline-pause change is what changed that; this branch does not stop the watchdog, and the earlier claim that it did was wrong.The remaining value is narrower: an import over a range with nothing reserved no longer pays for a pointless commit and retry, which on a full card repeated across the pages the title had touched. The pause covers the one retry that can still happen.
Verification
an_already_committed_range_is_not_committed_or_retriedfails with 1 retry instead of 0; the other three pass.cargo fmt --all.cargo clippy --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --all-targets -- -D warnings -A clippy::redundant-clone.python build.py d3d12.check200 passed, 0 failed on an RTX 5090 (620.70.10, GE-Proton11-14) at head337669e8, reported by @NickStallman. The current head differs from it by four lines intests/device/heap_import.rs. That check does not drive a failed import on a full card, so it says nothing about the benefit or the race.python3 tuxbox.py check --no-gpu: 11 passed, 1 failed. The failure is the pre-existingclippy::redundant-cloneatruntime/dxbc/src/fssm.rs:121, which this branch does not touch; the package clippy above passes with that lint allowed.Not run
NVIDIA, and the Lanes /
d3d12-*/guest-frame/presentGPU suites; no GPU was available in this session.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:41:14Z.
Thanks. The tests are good, and skipping the retry when nothing in the range is reserved is a clear improvement. I'm holding the PR for now, though, because the part with the most risk is also the part whose benefit hasn't been shown.
+0x2215C35stops firing. Could you boot your 7.5 GB card before and after, and say whether the frame-0 crash goes away? A log showing the watchdog firing while the commit-and-retry runs would also help, because the crash may come from the failed import itself rather than from time spent inside it.MEM_DECOMMIT, a title thread can commit and write the same pages. Its commit succeeds silently because the pages are already committed. Our decommit then drops its data, and its next access faults. The window is small, but the old code couldn't lose title memory this way.The simplest version that is clearly safe would keep only the
reserved_spanscheck (no commit and no retry when nothing is reserved) plus the watchdog pause. The decommit could follow in a separate PR once a run shows it's needed. If you'd rather keep the decommit, please show a boot with it and explain how (3) is ruled out.Imported from brcly/TuxBox. Originally posted by csj0oe on 2026-11-30T09:58:35Z.
Took your simpler version, and this is now the whole change:
GuestCommit::commitstillVirtualQuerys the range and commits only the spans that are reserved.roll_back,disarm, theDropimpl andMEM_DECOMMITare removed. A failed retry leaves the pages committed, and the log line sayskept them committedinstead of claiming a rollback.commit_guest_pageskeeps its old meaning for the placed-image caller: true when it committed or the range is already valid.On your first point, I cannot offer a before/after boot that credits this change, and I am not going to imply one: with this branch alone the frame-0 watchdog still fired (run26, exit code 5 at 43.1 s, crash at
game_scarlett_master.exe+0x2215C35). The body now says that instead of the old claim.Measured on the branch, four tests under GE-Proton (4 passed):
a_failed_retry_leaves_the_pages_it_committed(assertsMEM_COMMIT/PAGE_READWRITEacross the range after a failed retry),an_already_committed_range_is_not_committed_or_retried(data stays0x5a),a_failed_retry_keeps_the_title_page_and_the_span_it_committed(both stay committed), and the success case.Failing first: with the pre-change gate (
if !commit_guest_pages(base, bytes) { return None; }) restored in a throwaway copy,an_already_committed_range_is_not_committed_or_retriedfails with retriesleft: 1, right: 0; with the branch code it passes. The other three pass on both, so that one is the gate this change actually moves.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T10:06:29Z.
@csj0oe NVIDIA check, RTX 5090 (
10de:2b85, 620.70.10, GE-Proton11-14), fullpython tuxbox.py checkat337669e8(your earlier head, one5d2e913): 200 pass, 0 fail. The current headd58798e8differs only by four lines intests/device/heap_import.rs, which I haven't run. This says nothing about brcly's question on the race or on the benefit; the check doesn't drive a failed import on a full card.Evidence: TuxBox check of
337669e8c6, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run