test(agc): resubmit an SGPR pattern fill whose batch retired before the read saw it #8715
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8715"
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 janzezno on 2026-10-20T22:00:20Z.
What
agc_driver_sgpr_pattern_fill_keystimes out under parallelctest(#8708).ReadAfterWritewaits forRecorder::NewestWriteNoteover the keys, which only scans the open and in-flight batches. When the queue worker submits the dispatch and its batch retires before the test thread takesGpuMutex, the note is gone and the loop waits out its 10 s deadline.Submitnow appends aWRITE_DATAof a sequence number after the dispatch.SubmitAndReadreplaces eachSubmit+ReadAfterWritepair. If the note isn't pending but the label already holds the latest sequence number, the dispatch was recorded (it comes before the label in the DCB) and has retired, so the same fill is submitted again, at most 16 times; past that the test fails withthe dispatch completed N times without a pending write over the keys, so a dispatch that never notes its write fails at once instead of at the deadline. The existing assertions are unchanged.A new case makes the race deterministic:
SubmitAndRead(..., retireFirst = true)callsSettle()after the submit, so the fill has retired before the first poll. It asserts the fill was submitted again, then the same pending-0001 key assertions as the main loop.Tested
Arch Linux, kernel 7.2.11, GCC 16.2.1, Release,
BUILD_TESTING=ON, onmaine48bbff9f.mainfails 3 of 3 withthe submitted dispatch never became a pending write over the keysafter 10.2 s; the first commit passes 3 of 3 in 2.45 s.retireFirstcase fails at the 10 s deadline; with the note looked up at the wrong address (a dispatch that never notes), the test fails in 0.09 s withthe dispatch completed 17 times without a pending write over the keys.ctest --test-dir build -j12 -R 'agc|shader|spirv|recomp' --output-on-failure:mainfailed this test in run 7 of 7; the first commit passes it in 15 of 15 runs (0.10 to 0.13 s), the second in 15 of 15 (0.08 to 0.11 s). The other failures in those runs also fail onmainhere:agc_driver_guest_memory_lifetime(#7784),agc_driver_image_array_window_past_layer_limit(#8361),agc_driver_tessellation(#5444), and the occasionalagc_driver_pixel_interlockandagc_driver_storage_read_during_idle_store.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^agc_driver_sgpr_pattern_fill_keys$' -V --repeat until-fail:20: 20 of 20 onmain, on the first commit and on the second, noVUID-in either log, nowas not found but was requested.python3 tools/check_conventions.py --base origin/mainpasses.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 MarcZX10 on 2026-10-20T22:02:53Z.
Review: COMMENTED
The retry logic matches the reported race, but the deterministic regression described in Tested is not in this diff: the 200 ms post-submit delay was explicitly “not part of this PR.” As a result, normal CI can pass without reaching the new
Finished == Submittedrecovery branch. Please add a controlled test path that lets one fill retire beforeReadAfterWritebegins (for example, an optional test helper that waits for the completion label and queue retirement before polling), then assert thatSubmitAndReadresubmits and the original key assertions still pass. That would make the race fix a deterministic regression rather than relying on parallel scheduling.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:06:04Z.
Code review location:
core/libs/prx/libSceAgcDriver/tests/execution/SgprPatternFillKeys.cpp; line 98Correction: I withdraw this concern. I found several existing execution tests that use aligned
volatilelabels for GPUWRITE_DATApolling, includingWriteDataWrittenAhead.cpp,SameQueueLabelWait.cpp, andGatedDispatchCapture.cpp. Although other tests usestd::atomic_reffor some label reads, that alone does not establish a defect in this PR’s matching pattern. I have not found a concrete issue with this change from that observation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:13:34Z.
Thanks,
retireFirstnow makes the retired-before-read path deterministic, asserts that resubmission occurred, andMaxResubmitsbounds recovery. That addresses my earlier coverage request. The current headbc49073a2bd7has passing conventions and labels checks, but this run has no build/Vulkan job; the reported 15/15 load runs are from before this new path was added. Could you runagc_driver_sgpr_pattern_fill_keyson this exact head and update the report? I have only reviewed the new path statically.Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-20T22:13:51Z.
Both reviews are addressed in the second commit, along with the bound from your comment on #8708:
SubmitAndRead(..., retireFirst = true)callsSettle()right after the submit, so the fill has retired before the first poll. The new case assertsresubmits > 0, then the same pending-0001 key assertions as the main loop. With the resubmit disabled it fails at the 10 s deadline, so normal CI now goes through the recovery branch.the dispatch completed 17 times without a pending write over the keys, apart from the deadline message.Finishedis nowalignas(8) std::uint32_tread throughstd::atomic_ref<std::uint32_t>(Finished).load(), as inPm4Replay.cpp.On the final code: 20 of 20 alone with the validation layer (no
VUID-), 15 of 15 loaded-j12runs. The description is updated.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:14:46Z.
Thanks, that confirms the deterministic path and mutation failure. One validation detail remains: did the unmodified
agc_driver_sgpr_pattern_fill_keyspass on headbc49073a2bd7? Please include the OS/toolchain and exact invocation (and report the normal-head pass separately from the resubmit-disabled mutation); the hosted checks on this head run conventions/labels only.Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-20T22:20:26Z.
Yes. Rerun on head
bc49073a2itself (clean tree, full rebuild):Arch Linux, kernel 7.2.11, GCC 16.2.1, CMake/CTest 4.4.4, Release,
BUILD_TESTING=ON; AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5.Unmodified head
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^agc_driver_sgpr_pattern_fill_keys$' -V --repeat until-fail:20: passes 20 of 20, noVUID-, nowas not found but was requested.ctest --test-dir build -j12 -R 'agc|shader|spirv|recomp' --output-on-failure, 15 runs:agc_driver_sgpr_pattern_fill_keyspasses in all 15 (0.09 to 0.11 s). The other failures in those runs also fail onmainhere:agc_driver_guest_memory_lifetime(#7784),agc_driver_image_array_window_past_layer_limit(#8361) andagc_driver_tessellation(#5444) in all 15, andagc_driver_pixel_interlockin 1.Mutation (local, not pushed)
if (false && retired)): fails at the newretireFirstcase after 10.08 s withthe submitted dispatch never became a pending write over the keys.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:23:40Z.
Review: APPROVED
The exact-head report resolves my remaining validation request: the unmodified
bc49073a2bd7passed 20 focused Vulkan runs and all 15 parallel selections, and disabling resubmission makes the deterministic retirement case fail as intended. The test diff now forces retirement, asserts a resubmit, and bounds retries at 16. Hosted CI on this head covers conventions/labels only, so I am relying on the author-reported Arch/RADV runtime runs for execution coverage.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:24:00Z.
Follow-up: the author supplied exact-head runtime evidence for
bc49073a2bd7: 20/20 isolated focused CTest repetitions and 15/15 parallel-selection repetitions passed on Arch Linux with GCC 16.2.1, CMake/CTest 4.4.4, RADV RX 7900 GRE, andANYPS5_REQUIRE_VULKAN=1. They also report that disabling resubmission makes the deterministicretireFirstcase fail as intended. With the added bounded retry path and deterministic assertion reviewed, I approved the PR; hosted platform build jobs were not run.