feat(libkernel): implement kevent EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT #5847
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5847"
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 akkadbakkad89 on 2026-10-14T13:44:56Z.
What
keventno longer throws onEV_DISABLE,EV_DISPATCH,EV_FORCEONESHOTor a negativenevents, followingkqueue_register/kqueue_scanin FreeBSD 11'skern_event.c:KernelEqueueEventgains anenabledflag (FreeBSD'sKN_DISABLED).PollEvents,TriggerExpiredTimers,TriggerEvent,WaitForDescriptorsinterest registration andNextTimerWaitMicrosall skip disabled knotes, so a disabled knote never fires.EV_DISABLEonEV_ADDregisters the knote disabled; on an existing knoteEV_DISABLE/EV_ENABLEtoggles it.EV_ENABLE | EV_DISABLEstill returnsEINVAL.EV_DISPATCHreports the event once, then disables the knote until re-enabled - both collect paths (CollectTriggered,CollectOncePerWait).EV_FORCEONESHOTis ignored on a new knote; on an existing knote it setsEV_ONESHOTand fires it, askqueue_registerdoes at l.1339-1341.udata, the filter's touch/fflags and enable/disable - no flag adoption, matchingkqueue_register.neventsreturnsEINVAL.Known deviation documented in
docs/dev/debt/libkernel.md: aNOTE_TRIGGERraised while a user knote is disabled is kept and reported afterEV_ENABLE, where FreeBSD'sknotedrops it.File-level overlap note:
Kqueue.cpp/Equeue.cppare also touched by open PRs #5749 (EVFILT_VNODE on macOS) and #5493 (vnode error naming) - different code paths, line-adjacent only.Tested
WSL Ubuntu 24.04, gcc, host CPU only:
guest_kqueue: all pass, includingDisableAndDispatchcases - register-disabled socket knote stays silent untilEV_ENABLE;EV_DISPATCHfires once, suppresses further data, re-arms onEV_ENABLE, disables again;EV_FORCEONESHOTon add stays a normal level knote (delivers twice), on modify sets oneshot and fires (EV_DELETEthenENOENT); disabled user knote keeps itsNOTE_TRIGGERuntil re-enable;Errorsgains thenevents < 0->EINVALcheck and the oldEV_DISABLEthrow expectation is removedguest_equeue_events,guest_ult_queue_*(8 tests): passguest_socket_pair,guest_dup,guest_fstatfs,guest_getrlimit,guest_signals: passtools/check_conventions.py --base upstream/main: cleanChecklist
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 adriadam10 on 2026-10-14T13:52:58Z.
Review: CHANGES_REQUESTED
Thanks, the enabled flag and the EV_DISPATCH collect paths look right and
guest_kqueuepasses here. Two points differ fromkern_event.c(the commit the debt entry cites):EV_FORCEONESHOTon a new knote:kqueue_registeronly clears it fromkn_kevent.flagson the attach path (l.1303-1304). It setsEV_ONESHOTand activates the knote only when the knote already exists (l.1339-1341).Kqueue.cpp:252applies it on add, andGuestKqueue.cpp:250-253pins that. Please follow the source: no oneshot on add; on an existing knote setEV_ONESHOTand trigger it.ModifyKnote(Kqueue.cpp:232) ORsEV_ONESHOT | EV_CLEAR | EV_DISPATCHinto an existing knote.kqueue_registerdoes not do that for an existing knote (onlyudata, the filter's touch/fflags, and enable/disable). It also letsEV_CLEARthrough on a socket knote, whichAddDescriptorKnotethrows on at add time. Drop the line (or, if you have a source for it, cite it and keep the throw forEV_CLEARon sockets), and fix the PR body and the debt entry accordingly.Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-14T14:17:47Z.
Both points fixed in
637cb1ed4, thanks for the line references:EV_FORCEONESHOTon add now does nothing beyondKNOTE_CLEARED_FLAGSstripping it; on an existing knoteModifyKnotesetsEV_ONESHOTand marks the knote triggered. The test now pins both halves:EV_ADD | EV_FORCEONESHOTdelivers as a normal level knote twice, then the same change on the existing knote fires once and the knote is gone (EV_DELETE->ENOENT).EV_ONESHOT | EV_CLEAR | EV_DISPATCHOR on modify is dropped; a modify now touches onlyudata, enable/disable,EV_FORCEONESHOTand the filter's touch/fflags, matchingkqueue_register. NoEV_CLEARcan reach a socket knote through modify any more.PR body and the
libkernel.mddebt entry updated to describe the new behaviour.guest_kqueuegreen locally (WSL).Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T06:42:45Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libkernel.mdL111-112docs/dev/debt/libkernel.mdL111-112core/libs/prx/libkernel/Equeue/Equeue.cppL52-53, L68-69, L84-85, L101-102, L123, L130, L155, L167-168core/libs/prx/libkernel/Equeue/src/Kqueue.cppL225, L244-252core/libs/tests/GuestKqueue.cppL59, L252, L534-535docs/dev/debt/libkernel.mdL111-112docs/dev/debt/libkernel.mdL110-112Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/tests/GuestKqueue.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Equeue/Equeue.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:40:44Z.
Review: APPROVED
Both points are fixed:
EV_FORCEONESHOTis a no-op on add and setsEV_ONESHOTand triggers on an existing knote, as inkqueue_register, and a modify no longer adopts flags. Checked the build and ctest on the PR merged onto main,guest_kqueuepasses and fails without the change; merging once the full Build is green.