fix(libkernel): run APR buffers past an unsatisfied wait on their own queue #3588
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3588"
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 tv7 on 2026-10-11T13:50:23Z.
What
sceKernelAprSubmitCommandBufferand the AMM submit ran the whole buffer on the submitting thread. AWaitOnAddress/WaitOnCounterthe submitter itself satisfies after the submit returns therefore never returned. A buffer now runs on the submitting thread until such an unsatisfied wait; the rest of it, and every APR or AMM buffer submitted after it (order kept), runs on one APR thread. Buffers without such a wait behave as before.sceKernelAprSubmitCommandBufferAndGetIdreturns the submission id;sceKernelAprWaitCommandBufferandsceAmprAmmWaitCommandBufferCompletionwait for completion.Marvel's Wolverine (PPSA03671): the
Archive Asset IOthread submits a buffer with aWaitOnAddresswhile holding the archive mutex and sets the address later. On main it spins in_execute, the main thread blocks on that mutex, and loading stops about 40 s in.Tested
Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release, on main
a11c8f7f7.TestWaitSatisfiedAfterSubmissioninGuestAmpr.cpp: the submit of a buffer waiting on an address the test sets afterwards returns, a second buffer does not run before the first, both complete once the address is set. Fails on main (submit does not return within 5 s), passes with the fix.guest_kernel_syssymlink not permitted,windows_exceptions,guest_filesystem,agc_driver_emulated_color_compare) or only under-j8(agc_driver_prepared_shaders_debug, passes alone).tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-11T14:46:12Z.
Linux check with 007 First Light (PPSA11386 v01.018.000), which stops at row 6 of #2523 (the APR-submit hang): its loading thread records a
WaitOnAddressfollowed by file reads, submits them throughsceKernelAprSubmitCommandBufferAndGetId, and writes the awaited value only after the submit returns. Setup: CachyOS, RTX 3080, GCC 16.2.1, Release, run in a bubblewrap sandbox:maina11c8f7f7(240 s run): the log stops after 141 shader-cache misses with no further output. That's row 6.main+ this PR (32a3047b5): 007 passes row 6 and runs on to row 8,VOP3 source modifiers are not implemented(#2463 (closed) / SleglJan/AnyPS5#21). Row 7 is already merged.On the same machine
TestWaitSatisfiedAfterSubmission(inguest_ampr_markers) passes with this PR.guest_ampr_markersandguest_ampr_threadsboth pass 10 repeats.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-11T17:53:12Z.
Pushed a follow-up commit,
fix(libkernel): give AMM buffers their own queue. The first version put APR and AMM buffers in one queue, and that deadlocks Marvel's Wolverine a little later in loading:WaitOnAddresson a counter in the title's data, waiting for0x...9b. The counter was at0x...98.WriteAddresscommands of AMM buffers (each AMM buffer is a run of maps, each followed by aWriteAddressof the next counter value). The AMM buffer that writes0x...99to0x...9bwas submitted after 449, so the shared queue held it behind 449. Neither ran again, and every later APR and AMM buffer queued behind them.I also tried letting every waiting buffer go independently. That breaks Wolverine differently: a later APR buffer then reads into memory that is not ready yet (
APR: read failed). So order within APR matters, and AMM is a separate stream. Each engine now has its own queue and thread. Order is kept inside each one, and a wait in one does not hold up the other.New test
TestAmmNotBehindAprWait(guest_ampr_markers): an APR buffer waits on an address that an AMM buffer submitted after it writes. It fails on the previous head of this PR (sceAmprAmmWaitCommandBufferCompletiondoes not return within 5 s) and passes now.Wolverine with this head: loading goes on past that point and reaches a new stop, a
D16_UNORM_S8_UINTdepth target that NVIDIA cannot attach (separate PR).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:38:51Z.
Checked on current main: build and the libs/libkernel ctest scope pass (112/112);
guest_ampr_markersfails without the change and passes with it. Matches @SleglJan's Linux run.Added in a commit of our own: a "APR and AMM command buffers" section in
docs/dev/ARCHITECTURE.md, since the PR adds a worker thread and two queues. Note that a command that throws on the worker now aborts the process instead of throwing on the submitter.Merging once CI is green.