Repository navigation
D3D12.X: a device hang names Windows' GPU timeout when it was one - #2748
Raul-Paiva wants to merge 1 commit into
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
On c9e51e5, recent_resets treats every EvtNext == FALSE as the normal end of the System-log query and returns Some(n). Microsoft's EvtNext contract says only GetLastError() == ERROR_NO_MORE_ITEMS means enumeration finished; a one-second timeout sets ERROR_TIMEOUT, and other read errors can occur. If the first EvtNext fails that way, this code returns Some(0), and removal_note eventually reports no Display 4101 event / probably not a Windows timeout even though the evidence could not be read. A failure after a partial batch can likewise present an incomplete count as a complete query.
Could the read return an unknown/error outcome for any false result other than ERROR_NO_MORE_ITEMS, preserving the distinction from a genuinely empty query? Please close the query handle on both paths and cover a first-call timeout plus finite empty enumeration with an injected/mock event reader. This is exact-head source review based on the Win32 API contract; I did not force an Event Log timeout at runtime.
luckyteagirl
left a comment
There was a problem hiding this comment.
On c9e51e5, removal_note reports “it was Windows' GPU timeout” whenever it finds any system-wide Display 4101 in the prior 30 seconds. The query does not identify this device or bind the event to this removal. On a multi-adapter machine, another display adapter can reset in that interval; even on one adapter, an earlier recovered timeout can coexist with a later unrelated removal. The evidence is useful, but it does not establish that this specific device removal was caused by that event.
Could the log call this a recent Display 4101 event consistent with a Windows timeout, unless the event can be correlated to this device and removal time more tightly? A test can inject a recent event and assert the note stays probabilistic. This is exact-head source review; I did not reproduce a multi-adapter reset.
c9e51e5 to
abdb439
Compare
|
Thanks @luckyteagirl, both points were right. Fixed in
The description has the new test counts and a smoke run on AI use: Claude Code (Claude Opus 5.5) made the changes and wrote this reply. |
|
Test report: passes on NVIDIA. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
abdb439 to
e1ac7f0
Compare
|
One more fix, squashed in On another run with this PR, the device was removed and the note never reached the log. Two threads saw the removal at the same time:
With the lock, on the next real removal ( On
The description is updated. @sage-sage, thanks for the test on AI use: Claude Code (Claude Opus 5.5) found the race in the run log, made the fix and wrote this. |
luckyteagirl
left a comment
There was a problem hiding this comment.
On current head e1ac7f0213876e499786a4307deea67ca16b5c52, describe(Settings { level: Some(1), delay: Some(10) }) says Windows resets the GPU after a submission runs over 10 seconds. Microsoft's TDR registry documentation defines TdrLevel=1 as a system bug check on detected timeout, with no recovery; TdrDelay is the scheduler's preemption-wait threshold. This note would therefore give the wrong outcome for a configured level 1, and it also treats the unimplemented level 2 as recovery. Could describe distinguish these levels and phrase the delay as a preemption timeout? A table-driven test for levels 0, 1, and 3 would capture the important distinction. This is a source and API-contract check; I did not trigger a TDR.
AI use: OpenAI Codex (GPT-6.2 Sol) found and checked the configuration path; OpenAI Codex (GPT-6.2 Astra) verified the source and Microsoft documentation and wrote this review.
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
(Compare against Not tested
AI use
|
e1ac7f0 to
1949ac1
Compare
|
Thanks @luckyteagirl, right again. Fixed in
On AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply. |
|
Ran the TDR diagnostics tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All eight tests pass here, including the one that reads this machine's real System log and registry What this adds: the existing NVIDIA report is on an RTX 4080 SUPER (and an AMD one on RX 9060 XT), both on earlier heads. This is a Blackwell wave32 host at the current head, with a different driver and settings. I did not produce a real device removal here, so I am not adding evidence about the 4101 event in a live run. Not tested: a real AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
1949ac1 to
4c8f841
Compare
|
Wine/NVIDIA verification of exact head
One failure, and it is a Wine
No device removal was triggered here and no title was run; this is the module's unit surface only. AI use: omp, harness model |
A DEVICE_HUNG or DEVICE_RESET removal can be Windows' GPU timeout (TDR): WDDM resets the GPU when it does not preempt within TdrDelay seconds of the scheduler asking, 2 by default. The removal code does not tell that apart from a hang the driver found itself. Windows writes a Display event 4101 to the System log when it was its timeout. The log now names the timeout in effect at start (TdrDelay / TdrLevel, read from the registry without elevation). After a hung or reset device it looks for a 4101 event of the last 30 s, waiting up to 3 s for Windows to write it. A recent event is reported as consistent with the timeout, not as proof: the event names no device. A System log read that fails (anything but ERROR_NO_MORE_ITEMS) is reported as unknown, not as no event. On an RTX 3070 Laptop every 0x887a0006 at a retail title's world start had a 4101 event at the same time (14 of 14 runs), and raising TdrDelay took them away. A later 0x887a0007 on the same machine had none. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4c8f841 to
c20818a
Compare
|
@pickles976, thanks for the Wine run. You were right about the cause, and the test was the problem: That is in AI use: Claude Code (Claude Opus 5.5) made the change and wrote this. |
|
Re-ran the TDR diagnostics tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All nine pass here, including the new Not tested: a real AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2748 at Setup
Targeted Win11 / RTX 4060 release unit tests (
|
|
Status update, and three real removals the diagnostic caught. Review points: all three from @luckyteagirl are addressed.
Could you take another look when you have time? The head c20818a still merges cleanly into In use: this commit has been in my local test tree (main 8b957be plus several open PRs) for the last day. It names the cause on three 0x887a0007 removals during a retail title. All three came with DRED
So on this machine (RTX 3070 Laptop 8 GB, driver 621.24, Windows 10 19045), these hangs are not TDRs: they are a GPU page fault, which matches the separate VA 0x0 reports on #2404. The note came out once per removal, with no lost or doubled lines since the lock in e1ac7f0. AI use: Claude Code (Claude Opus 5.5) collected the log lines and drafted this comment; I checked them against the logs. |
A
0x887a0006(DEVICE_HUNG) or0x887a0007(DEVICE_RESET) removal can be Windows' GPU timeout (TDR): WDDM resets the GPU when it does not preempt withinTdrDelayseconds of the scheduler asking (2 s by default, at the defaultTdrLevel). The removal code alone does not tell that apart from a hang the driver detected itself. The log now says whether Windows logged one. At start it names the timeout in effect. After such a removal it looks in the System log for theDisplayevent 4101 Windows writes when it was its timeout. Logging only. Part of #505.On an 8 GB laptop card, every
0x887a0006at a retail title's world start had a 4101 event at the same time (14 of 14 runs). RaisingTdrDelaytook them away (#505 comment). Without the event, testers on slower cards report these as GPU hangs.What is in it
crates/xcl/src/gpu/tdr.rs(new):settings()readsTdrDelay/TdrLevelfromHKLM\System\CurrentControlSet\Control\GraphicsDrivers. Read only, no elevation.describe()turns them into the log line:TdrDelayas the GPU's preemption timeout, and whatTdrLeveldoes then (0 off, 1 a bug check with no recovery, 3 or unset a reset; 2 is not implemented by Windows). The line says the values are the registry's, which Windows reads at boot, so a change not yet applied is not taken for the one in effect.recent_resets()countsDisplay4101 events of the last 30 s withEvtQuery. A read that fails with anything butERROR_NO_MORE_ITEMSgives "unknown", not a count.removal_note()does this forDEVICE_HUNG/DEVICE_RESETonly, waiting up to 3 s for the event because Windows can write it just after the title sees the removal. A recent event is reported as consistent with the timeout, not as proof: the event names no device.crates/xcl/src/hle/d3d12x/mod.rs: the timeout line afterbackend 'real'.crates/xcl/src/hle/d3d12x/real.rs:log_device_removedadds the note afterD3D12 device removed. A second caller now waits for the first one's report, for at most 5 s (ReportOnce). Without that,stop_if_device_removedon another thread ended the process before the note was written; in one run that was 70 ms after the removal. The wait is bounded and not a lock: the reporting thread can come back itself through the unhandled-exception filter.crates/xcl/Cargo.toml: theWin32_System_EventLogfeature ofwindows-sys, forEvtQuery. No new dependency.Tested
RTX 3070 Laptop 8 GB, driver 621.24, i7-11800H, 32 GB RAM, Windows 10 19045, Rust 1.100.0, debug for the suite.
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4onc20818a: 1445 passed, 1 failed, 47 ignored; 25SKIPPEDlines: "no wave64" on this adapter, per-lane forms the driver refuses, and one "no heap windows". The failure ishle::d3d12x::list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list, which fails intermittently onmaintoo; alone it passed 3 of 3 runs. This change does not touchlist_x.rs. On4c8f841, one test change before, the same suite had 1446 passed, 0 failed.The 9 tests in
gpu::tdr::testspass, among them a reader that fails on its first call (ERROR_TIMEOUT), one that fails after a partial batch, an injected recent event, and a malformed query, which Windows refuses withERROR_EVT_INVALID_QUERY. The two tests that read the real System log printSKIPPEDwhere a valid query cannot read it (Wine'swevtapigives error 0), and otherwise fail only on a query Windows refuses. The 2 tests inreal::report_once_testspass: a second caller waits for the report, and the reporting thread coming back (through the unhandled-exception filter) does not hang. The query ofrecent_resets, run over the last 24 h withGet-WinEvent -FilterXPath, found the 24 events 4101 of this machine that day.In the PR's smoke run the log has, after the adapter line:
(
TdrDelayis 10 on this machine for an earlier test; it is 2 s when not set.)Real removals, each in a 600 s run of a retail title. The tree was this PR on a test tree:
main+ D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404 and others, with a 1 GiB shader heap profile.4c8f841(itstdr.rsandReportOncecopied in as they are; the headc20818achanges only a test since). The thread number is in brackets:nvlddmkm153 events in the 15 s before.stop_if_device_removedon another thread ended the process 6 ms after the note.0x887a0007at 233.3 s. The noteno Display 4101 event in the System log in the last 30 s: …came at 236.6 s, and the process ended after it. The System log has no 4101 in that window.Test reports from others (on earlier heads:
c9e51e5is before both review fixes and the report lock,e1ac7f0before theTdrLevelwording,4c8f841before the Wine skip)e1ac7f0(emirduran707): the 8gpu::tdrtests pass. The suite had 1441 passed and 2 failed, bothdxil::fuzz_teststhat fail onmainthere too. Smoke: 1601 frames, 0 removals (main: 1603).4c8f841(pickles976): 8 of 9gpu::tdrtests and bothreport_oncetests pass. Wine'swevtapireads no System log (error 0), anda_query_windows_refuses_is_told_apartfailed on that. It now skips there like the other System-log test (c20818a). Under Wine the note after a removal should readthe System log could not be read …(not run there).c9e51e5(sage-sage): 1440 passed, 0 failed, and thegpu::tdrtests of that head pass, including the System log read.Regression run
main:
this PR:
Both with the same settings, one after the other (main first, right after its build);
xcl.exehas a 1 GiB shader heap profile (#2590) on this machine for both.Not tested
TdrDdiDelay, the time a thread may stay inside the driver (5 s by default), is another way to a TDR. The start line does not name it; the removals measured here were the GPU not preempting.AI use
🤖 Generated with Claude Code