fix(agc): print a GPU queue worker failure when it is first stored #5177
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5177"
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 boykopovar/AnyPS5. Originally posted by 13hourstilliland on 2026-10-13T13:57:41Z.
What
Driver::ReportFailurestores a queue worker's exception without printing it. The failure only surfaces when a guest thread next enters the driver (CheckFailureon Submit, WaitIdle and the like). A guest whose own driver waits on a fence word in guest memory never enters the driver again, so it sees a GPU that stopped and never the reason.The first stored failure is now printed once, as
[gpu] driver failure: <what()>, whileReportFailurestill holds the driver mutex, so aWaitIdlethat wakes on the stored failure returns only after the line is out. Control flow is unchanged: it is still rethrown on the next driver call and at shutdown.This does not fix the vkQuake (PPSA99010)
radv/ps5: the GPU has not reached submission ...stall. @orishamir measured on Windows that it is the host pipeline compile time (#4977), with no stored failure, onmainand on this PR alike.Tested
Linux (Debian, GCC 14), lavapipe (Mesa 25.0.7), on
main4c1de0c0c:agc_driver_worker_failure_log: a flip that fails on the worker is printed exactly once and is still rethrown by the next driver call. With thePrintFailurecall removed it fails withthe worker failure was not printed; restored, it passes. 20 of 20 repeated runs pass.agc_driver_flip,agc_driver_present_mode,agc_driver_flip_computepass (4/4 with the new test).tools/check_conventions.py --base origin/mainpasses.The capture is opened with
"wb", so Windows no longer writes\r\ninto it, and the print now happens beforeWaitIdlecan return. Both failures @orishamir found were Windows-only and don't reproduce on Linux, so the 20 of 20 above doesn't show the race is gone. His local run with the same two changes passed 20 of 20 on Windows.No title run: this box has no GPU.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T17:27:09Z.
Windows run, since the description says Windows wasn't tested. Windows 11, RTX 4080, WinLibs GCC 15.2.0 r7, Release, this head (ac03f3ed1) merged onto
maine34c47921. Every other test in the fullctestpasses (1198 of 1199).agc_driver_worker_failure_logfails on Windows in 20 of 20 runs withthe worker failure was not printed. I found two causes and checked each with local edits (not pushed anywhere):freopen(..., "w", stderr)(Flip.cpp:347) opens the capture file in text mode. With the file kept instead of removed, it holds[gpu] driver failure: intentional flip failure\r\n: the line is printed once, but the check atFlip.cpp:372looks for...failure\n.gpu] driver failure: intentional flip failure).ReportFailureprints atLifecycle.cpp:198, after it releasesmutex, soWaitIdle(its predicate isfailure != nullptr, line 166) can return and the test can restore stderr before the print lands. With the print also moved inside the locked block, the test passes 20 of 20. Withmain'sLifecycle.cppand the newline-insensitive check, it fails 3 of 3, so the check still pins the change.vkQuake (PPSA99010), with LibreQuake data in
app0/id1, 90 s per run:mainit stalls in 3 of 3 runs:radv/ps5: the GPU has not reached submission 19 (at 18) in 10 s, thenQUAKE ERROR: vkWaitForFences failed with code -4and exit status 1. The same happens in 3 of 3 runs with this PR, and no[gpu] driver failureline appears in the title'sapp0/trace.txt. That file also receives this library's own[dispatch] creating a pipeline ...lines, so a print there would have shown up.queue worker 0x0thread is inAgcDriver::VulkanDevice::dispatch->nvoglv64->nvgpucomp64, so it is still compiling. WithAPS5_PROFILE_DRAW=1, the last pipelines started before the stall are 420,923, 208,392, 208,366, 105,396 and 349,278 SPIR-V words. On this machine the stall is the pipeline compile time from #4977, not a stored failure, so this PR doesn't print anything for it.s_round_mode 8 at pc 316error onmain968d32686earlier today. With this PR one34c47921it gets a pipeline (the PR doesn't touch the recompiler), and none of these 8 runs (3 onmain, 5 with this PR) aborted on #981.AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:59:36Z.
Review: CHANGES_REQUESTED
Thanks for the fix and for the negative check. Two problems make the new test fail on Windows (confirmed by @orishamir above: 20 of 20 runs,
the worker failure was not printed):tests/Flip.cpp:347:freopen(..., "w", stderr)opens the file in text mode, so on Windows the capture holds...failure\r\nand the search atFlip.cpp:372for...failure\nnever matches. Open it in binary mode ("wb") or make the check newline-insensitive.Execution/src/Driver/Lifecycle.cpp:199:PrintFailureruns aftermutexis released, whileWaitIdlealready returns oncefailure != nullptr(line 166). The test can restore stderr before the print lands (first bytes missing in the capture; 5 of 10 runs passed even with the newline fixed). Printing inside the locked block made it 20 of 20 in @orishamir's run. Please do that, or make the test wait for the print another way.Also, the description says the vkQuake stall hides the #981 throw. @orishamir measured on Windows that the stall is the pipeline compile time (#4977): the same
radv/ps5: the GPU has not reached submission ...appears 3 of 3 onmainand 3 of 3 with this PR, with no stored failure. Please reword "What" so it doesn't present this as the fix for that symptom; the print is still useful for failures that do get stored.Imported from boykopovar/AnyPS5. Originally posted by 13hourstilliland on 2026-10-14T19:43:01Z.
@adriadam10 @orishamir thanks for the Windows runs and for pinning down both causes.
Pushed
6e3152f0e, rebased on4c1de0c0c:tests/Flip.cpp: stderr is captured withfreopen(..., "wb", ...), so the line ends in\non Windows too.Lifecycle.cpp:PrintFailureruns inside the locked block inReportFailure, so aWaitIdlethat wakes onfailure != nullptrreturns only after the line is out.Linux, lavapipe: 4/4 flip tests pass, and the new test passes 20 of 20 repeated runs. It still fails with
the worker failure was not printedwith the print removed. I can't reproduce either Windows failure here, so orishamir's 20 of 20 on Windows with the same two changes is the evidence for those.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T19:50:42Z.
Review: APPROVED
Checked the interdiff against the earlier points: the capture is opened with
"wb"(Flip.cpp:347),PrintFailurenow runs inside the locked block (Lifecycle.cpp:198), and "What" no longer presents this as the vkQuake stall fix.agc_driver_worker_failure_logand the flip tests pass here, and the test fails with thePrintFailurecall removed. Merging once the Windows build is green.