fix(libkernel): bound equeue pending events #7509
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7509"
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 Pouare514 on 2026-10-18T10:15:31Z.
What
Bound
pendingEventsper equeue registration to the armed event plus at most 64 queued events. A trigger past the cap drops the oldest queued event and keeps the latest payload; anAddEventcarrying more than 64 keeps the latest 64. Drained bursts report exactly as before. The cap lives inKernelEqueuePrivate::kMaxPendingEventsand is enforced centrally inTriggerEvent/AddEvent, so it covers every producer with the queue-behind pattern (VideoOut flip/vblank, AMPR completions) instead of patching one filter.AddEventbuilds the stored event field-by-field and copies at most 64 queued entries, so it never copies an unbounded host queue.Tested
Release Ninja
BUILD_TESTING=ON(MinGW GCC 15.2) on Windows.ctest -R "guest_equeue_events|guest_kqueue|guest_socket_events": 3/3 pass (equeue 0.48s, kqueue 3.06s, socket_events 0.21s).guest_equeue_eventscases: 100k undrained AMPR triggers stay bounded (deliver exactly 65 = 1 + 64, last payload is the latest) and anAddEventseeded with 20k queued events is truncated to 65 with the latest preserved; small bursts (existing 2- and 3-completion AMPR tests) still deliver every event.Equeue.cppreverted (new tests kept),guest_equeue_event_testsaborts onRequire(total <= kBound)after the flood (unbounded 100k deliveries). Pass-with: same binary passes after restoring the fix (exit 0).git diff --checkclean;python3 tools/check_conventions.py --base origin/mainpasses; no//in added C++ lines.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 akkadbakkad89 on 2026-10-18T11:28:15Z.
Linux datapoint at head
c170bba422(author ran Windows):guest_equeue_events,guest_kqueue,guest_socket_events- 3/3 pass on Ubuntu 24.04 (WSL2), GCC, Release. The bounded-AMPR cases build and run clean here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T12:06:14Z.
Thanks for the Linux run. That independently confirms the bounded AMPR flood and the seeded AddEvent queue pass on the current head, complementing the Windows focused run in the description.
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-18T12:20:14Z.
Confirmed on Ubuntu 24.04 (GCC 13.3) as well as Windows, with this PR merged onto
main9f25d0bf5.Equeue.cppreverted tomain,guest_equeue_eventsaborts on both platforms; with the PR it passes.NotifyAllin the same functions), and the combined build passesguest_equeue_eventsandguest_kqueue5/5.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-18T13:53:26Z.
Windows run of head
c170bba42, merged ontomain0d078f75dtogether with #7492 (fd2eb3521) and #7090 (17d9e0a51); the merges are clean, so this is the stack.BUILD_TESTING=ON.libspass, no warning inEqueue.cpporGuestEqueueEvents.cpp.guest_equeue_events(with the 100k-trigger flood and the 20k-seedAddEventcases) passes 3/3 on a quiet host (0.70-0.89 s) and 15/15 with--repeat until-fail:15under load from other builds (0.77-2.27 s, mean 1.30 s). The other 34 equeue/kqueue/socket/poll/select/rudp tests pass 3x, 105/105 in total.Equeue.cpptaken from #7492's head (your three cap hunks removed, header and tests kept)guest_equeue_eventsaborts after 1.27 s at the bound check, whileguest_kqueuestill passes. With the stack restored it passes.ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip'): 936 tests, 929 pass, 2 skipped, 5 load timeouts (conventions_function_bodies,configure_seed,hardware_oracle_compare,guest_none_relocations,tls_function_coverage_register_address_loads) that pass serially.tools/check_conventions.py --base origin/mainandgit diff origin/main --checkpass; no env var added.Titles: VideoOut is the only producer that queues behind an armed event. PPSA99169 (RetroArch), PPSA01153 (OliSe Player) and PPSA74126 (Stremio Plus), 60 s each against the same build with
Equeue.cpp,Equeue.hppandUdp.cppfrommain: no stop line, frames 5494 / 3457 / 3387 before and 5914 / 3486 / 3487 after. A local diagnostic print (reverted) inTriggerEventfor a cap drop did not fire in 45 s on PPSA74126, PPSA99082 or PPSA99169 (app.exeonly), so none of these titles reaches the 64 limit; I did not log theAddEventtruncation.On the limit itself: FreeBSD 11.4 has no per-knote queue (repeated activations of an
EV_CLEARknote accumulate inkn_dataand are reported once), so 1 + 64 is this project's own bound. The debt entry says the console's depth is unknown, which is accurate; I have nothing that measures it.Not checked: Linux, macOS, a console, the
AddEventtruncation in a title, #6510 and #7129 merged with this.Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-18T16:27:24Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One docs-debt conflict, unioned.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the two knownmainregressions (agc_driver_tessellation— Mesa, #5444;agc_driver_bda_device— #7584), neither from this PR.To pick it up:
Head is
6dd4d5d5c.