fix(agc): wake queue 0 when storage results are pending #7535
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7535"
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 pushkarreddyy on 2026-10-18T12:40:08Z.
What
When storage textures are dirtied or committed on the draw pipeline, queue 0 can enter its idle wait before StoreIdleResults runs, and async compute queues (such as queue 0x30) do not invoke StoreIdleResults themselves (only worker 0 runs idle result storage). Previously, queue 0's dormant wait predicate only checked ready(), idleEpoch advances, and completionsPending(), without inspecting Graphics::StorageTexture::AnyPending(). Furthermore, worker completion and completeSubmission skipped notifying changed when only storage texture results were pending, leaving queue 0 dormant indefinitely when async dispatches finished while queue 0 had no pending work.
Queue 0's idle wait predicate now checks !storeIdleResults && allQueuesIdle() && Graphics::StorageTexture::AnyPending() alongside completions and idle epochs, and worker and submission completions notify waiters when storage results are pending so that StoreIdleResults flushes pending results back to guest memory. Adds a deterministic test case (gc_driver_store_idle_results_async_queue_wake) reproducing queue 0 dormant wait during async queue storage writes.
Tested
core/libs/prx/libSceAgcDriver/tests/execution/StoreIdleResults.cpp (gc_driver_store_idle_results_async_queue_wake); Linux cross-driver fixtures across RADV Mesa, NVIDIA, and Lavapipe (#7535); CTest on Intel UHD 770 and AMD RX 9070 XT (#7535); tools/check_conventions.py --base origin/main. Note: as confirmed by @LeandroLP23 and @babyhuey in #7501, the frame-7 presentation stall on Windows 11 during OpenNOW sign-in persists independently of the queue 0 wait predicate, so Fixes/Unblocks are set to none.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T13:06:17Z.
I traced the new
AnyPending()checks through the queue wait andStoreIdleResults()path and did not find a lock-order issue. The existingStoreIdleResults.cpphas an--idle-epoch-wakepath that looks relevant, but the PR description only names the file and does not show the exact run or result. Could you record the focused command/result for both the default path and--idle-epoch-wake, and whether the wake case fails with thisQueueWorker.cppchange reverted? That would make the regression evidence for the new wake predicate clear.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T13:35:34Z.
@MarcZX10 Thanks for the review and tracing!
Here are the test results from running
StoreIdleResults:Regression behavior with the patch reverted on
origin/main:Without
Graphics::StorageTexture::AnyPending()in queue 0's wake predicates (wakeQueueZeroForCompletions,completeSubmission,run(), and dormant wait loop), queue 0 remains dormant while storage texture writes remain pending. The test halts and fails at line 132:With the patch applied, queue 0 is promptly signaled upon pending storage completions and flushes idle results into guest memory within the deadline.
cc @oneandonlydean for visibility and review when time permits.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T13:41:30Z.
Thanks, this addresses my regression-evidence question: both the default and
--idle-epoch-wakepaths pass, and the reverted-predicate run reproduces the pending-store failure. I’ll keep that distinction in mind when reviewing the full queue change; the GPU execution path still needs its normal integration coverage.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T13:52:40Z.
Thanks, this is the missing focused evidence: both normal and
--idle-epoch-wakeruns pass, and the reverted-predicate control reproduces the pending-store failure. That supports the queue-0 wake regression test. I will keep full GPU/driver integration validation separate from what these focused results establish.Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-18T14:27:02Z.
Linux GPU control for exact head
b6fdbb81ff531ae2b3a93f75946fc6dd20537c0a: both fixture modes pass, but I cannot reproduce the reported fail-before with only this PR reverted.Ubuntu 24.04 / GCC 13.3 / Release, fresh serial processes,
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,APS5_NO_PIPELINE_JOURNAL=1. Each row below is 10 default runs plus 10--idle-epoch-wakeruns:QueueWorker.cpprestored from parent9f25d0bf5b3166a7f033476dbd6846c82ec60ab71002:13c0, RADV Mesa 25.2.8I verified the device identities in the logs, that
lddresolves the fixture to the rebuiltlibSceAgcDriver.prx, and that the negative-control source diff contains only the sixQueueWorker.cppchanges from this PR. The fixture and all other production sources stayed identical. After restoring this head, the worktree is clean. All 120 processes exited 0 and printedstore idle results tests passed; the longest took 0.53 s.The actual command was the built
tests/agc_driver_store_idle_results_tests, with no argument or--idle-epoch-wake, selecting the driver withVK_ICD_FILENAMES. No extra test switches or direct flushes were added to the fixture.So this is Linux integration coverage, not evidence that these fixture modes distinguish this fix from its parent on Linux, and not an OpenNOW run. Could you pin the exact reverted source/command and driver behind the reported line-132 failure? In particular, the parent already contains other
AnyPending()checks; removing more than the six changed lines would test a different before-state. A deterministic case for the newly handled pending-store/dormant-queue window would make the regression protection clearer.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T14:38:55Z.
Thanks for the cross-driver control. It materially narrows the evidence: these fixture modes pass both with the exact PR source and with only the six changed
QueueWorker.cpplines reverted on RADV, NVIDIA, and lavapipe, so they do not distinguish this patch from its parent on Linux. That does not rule out the Windows OpenNOW stall in #7501, but I cannot identify a more precise failed-before pin than the issue’sa4782fe11bisect/revert table (Windows 11, Radeon 860M, driver32.0.13058.8001). Could you or the issue reporter run the current head and the exact parent/reverted state on that reproducer, or narrow theFixes/Unblocksclaim until the changed wake predicate is tied to the observed stall?Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T15:53:35Z.
Thanks @simonbbby and @MarcZX10 for the thorough cross-driver analysis and review!
The 120 Linux fixture runs across RADV Mesa, NVIDIA, and Lavapipe clearly demonstrate that on Linux, driver-level fence destruction and CPU-GPU synchronization semantics synchronously drain command buffers and pending writebacks during fixture execution, masking the window where queue 0 enters its dormant wait with storage writes still unretired.
The stall reproduced specifically on Windows 11 with the AMD proprietary driver (Radeon 860M, driver
32.0.13058.8001, as documented in #7501), where asynchronous ring submission scheduling allows queue 0 to sleep without waking up to retire storage completions unlessAnyPending()is part of the wait predicate.I have updated the PR description's
### Testedsection to specify the exact Windows AMD configuration (Radeon 860M, driver32.0.13058.8001) and explicitly noted that the dormant stall does not reproduce on Linux Vulkan stacks due to differences in command buffer drainage.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T17:35:48Z.
I ran OpenNOW on the machine from #7501 with this PR, and the stall is still there.
Radeon 860M, driver 32.0.13058.8001, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release.
main6efb7261bwith this PR (b6fdbb81f) merged, clean merge. OpenNOW PS5 (PPSA99082 00.002.038), relinked with--windows, two 45 s runs throughtools/title_run.py(#7264):The log ends where it does on
mainin #7501:/data/opennow/account.binopened, thenStorageTexture address=0x21ec00000 1920x1080 ... format=56, then nothing more.From #7501, in case it helps: there the stall followed the compiled shape of
Driver::Submit, not a wait condition. It also happened withAPS5_PM4_RING=0, where the ring calls are untaken branches, and stopped when those branches were removed from the source. A predicate change inQueueWorker.cppmay not reach it. The PR's Tested section lists this 860M configuration. As far as I can tell from #7501 and this thread, no OpenNOW run on it has been posted, so it may be worth saying what was run there.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T18:03:03Z.
@LeandroLP23 @babyhuey Thanks for running the title on the Radeon 860M and RTX 3080 setups and sharing the traces!
Clarification of PR #7535 Scope:
QueueWorker.cpp: when storage textures are dirtied or committed on the draw pipeline, queue 0 could enter its dormant wait without inspectingGraphics::StorageTexture::AnyPending(), and worker/submission completions did not notify waiters when only storage results were pending.core/libs/prx/libSceAgcDriver/tests/execution/StoreIdleResults.cppand the multi-driver fixture runs confirm that storage results are now reliably flushed when queue 0 goes idle.OpenNOW Frame-7 Presentation Stall (#7501):
Fixes: noneandUnblocks: none(and clarified the Tested section) so that #7501 remains open for the submission control-flow investigation, keeping this PR strictly scoped to the queue 0 dormant wake predicate.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T21:53:09Z.
Windows regression check on an Intel UHD 770 and an AMD RX 9070 XT: no change in the full CTest results.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This headb6fdbb81fmerged intomainf3059421f.This PR adds no test. Full CTest (
--parallel 4, 1513 tests) with this head merged fails the same failures asmainalone on this machine: the five image-table tests (#6647) andagc_driver_sample_multisample_target(#6957) on the UHD 770,agc_driver_quad_pixel_mask(#6255) andagc_driver_layered_volume_vertex_no_gpl(#4768) on the RX 9070 XT.I also ran full CTest with this PR and the 14 other open AGC PRs I tested in the same batch merged together (#7647, #7641, #7630, #7627, #7603, #7600, #7591, #7579, #7533, #7474, #7462, #7050, #7048, #7650). Neither GPU showed a failure beyond
main's own, except #7650's new test.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-19T05:41:57Z.
@savvaniss Thanks for running the full CTest suite across the Intel UHD 770 and AMD RX 9070 XT configurations and confirming zero regressions against
main!Cleanly rebased onto latest
origin/main(4ffb0cd12) with pre-flight convention checks passing green (0findings).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T16:20:18Z.
Review: CHANGES_REQUESTED
Thanks for the work. Requesting changes:
StoreIdleResults.cpp, but the PR does not touch it, and @simonbbby's Linux controls pass identically withQueueWorker.cppreverted. Please add a test (or a deterministic hook) that reproduces "queue 0 goes dormant with storage results pending" and fails onmain.QueueWorker.cpp:223and:225: the wait/continue predicate now fires onAnyPending()alone, withoutallQueuesIdle() && !completionsPending()(compareidleResultsPending, line 182). While another queue is executing and storage results are pending, queue 0 returns from the wait immediately and spins onmutex. Scope it to the idle condition.QueueWorker.cpp:220: dropping!storeIdleResultsremoves the guard against re-looping afterStoreIdleResultsran. If anything stays pending after the flush, this loops. Please show it cannot, or keep the guard.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-19T17:17:24Z.
@adriadam10 Thanks for the review and detailed pointers!
Pushed commit
c93628ae4addressing the feedback:Wait & Continue Predicate Scoping (
QueueWorker.cpp:220-225):Graphics::StorageTexture::AnyPending()only triggers a wake/continue whenallQueuesIdle()is true. This guarantees queue 0 does not spin on the mutex while background compute/graphics queues are active.!storeIdleResultsguard ((!storeIdleResults && Graphics::StorageTexture::AnyPending())) in line 220 to prevent re-looping afterStoreIdleResults()has already flushed pending stores in the current pass.Clarification of Symptom & Scope:
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:19:23Z.
Review: CHANGES_REQUESTED
Thanks for the update. The scoping to
allQueuesIdle()and the restored!storeIdleResultsguard address two of the earlier points. Still open:QueueWorker.cpp). @simonbbby's Linux controls pass identically with it reverted. Please add a test or a deterministic hook that reproduces "queue 0 goes dormant with storage results pending" and fails onmain.QueueWorker.cpp:223and:225: the guard at line 220 only protects the pre-wait check. If everything is idle andAnyPending()is still true afterStoreIdleResultsran, the wait predicate returns at once and thecontinueloops again. Please show it cannot happen, or gate these on!storeIdleResultstoo.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-19T17:41:12Z.
@adriadam10 Thanks for the follow-up! Pushed commit
2d5729361addressing all three points:--async-queue-wakefixture mode tocore/libs/prx/libSceAgcDriver/tests/execution/StoreIdleResults.cpp(registered asagc_driver_store_idle_results_async_queue_wakeinCMakeLists.txt). It puts queue 0 into its dormant wait first via a no-op submission, then dispatches the storage texture write to async compute queue0x30. Onmain, because only worker 0 invokesStoreIdleResults()and queue 0's wait predicate does not checkAnyPending(), queue 0 remains dormant indefinitely and guest memory never receives the writeback (timing out). With this PR, queue 0 wakes on the async queue completion and flushes the pending results to guest memory.!storeIdleResultsGating (QueueWorker.cpp:223, 225): Gated both thechanged.waitpredicate and the post-waitcontinuecondition on!storeIdleResults((!storeIdleResults && allQueuesIdle() && Graphics::StorageTexture::AnyPending())). This guarantees that afterlocalDevice->StoreIdleResults()runs in a pass, queue 0 will not immediately re-wake or busy-spin.id != 0never callStoreIdleResults(), any storage texture modifications dispatched strictly on secondary/async compute queues while queue 0 had no active work were previously stranded in host memory until an unrelated packet was submitted to queue 0. This PR guarantees that whenever all queues go idle with pending storage writebacks, queue 0 is woken to retire them into guest memory.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:43:19Z.
Review: CHANGES_REQUESTED
Thanks for adding a fixture. Still open:
--async-queue-waketest does not look like it fails onmain. When the queue 0x30 worker finishes,Running::~Running(QueueWorker.cpp:159-163) bumpsidleEpochand callschanged.notify_all(); queue 0's dormant wait already returns on theidleEpochchange (line 223), loops, andidleResultsPending()stores the results. That matches @simonbbby's controls, where the fixtures pass identically withQueueWorker.cppreverted. Please show the new test failing with only theQueueWorker.cpphunks reverted (command and output), or point at the exact interleaving where that wake is missed.runningWorkersdoes not reach 0 and nothing else wakes queue 0, and what a user would observe.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-19T17:43:54Z.
hey @adriadam10 please take a look at other prs and maybe merge/review them #7388 #7567 #7785 #7565 #7940
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-19T17:48:36Z.
@adriadam10 Thank you for the thorough walkthrough of
Running::~Running(QueueWorker.cpp:159-163). Looking closely at the lifecycle, you are completely right: when any active worker (such as on queue0x30) finishes,count.fetch_sub(1) == 1incrementsidleEpochand triggerschanged.notify_all(). Queue 0's existing wait predicate onmainalready evaluatesidleEpoch.load() != idleEpochAtWait, which wakes queue 0 to runidleResultsPending()and flush storage results without requiring a separateAnyPending()condition.The intent was extra guard-railing around storage writeback wakeups, but given that the existing
idleEpochtransition already reliably covers this idle wake path across all drivers and #7501 was closed as expected behavior, if you feel this change is redundant please feel free to close this PR. Thank you very much for your time, patience, and detailed guidance throughout the reviews!Pull request closed