Repository navigation
feat(libkernel): implement kevent EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT - #5847
Conversation
adriadam10
left a comment
There was a problem hiding this comment.
Thanks, the enabled flag and the EV_DISPATCH collect paths look right and guest_kqueue passes here. Two points differ from kern_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.
|
Both points fixed in
PR body and the |
…EONESHOT A knote registered or modified with EV_DISABLE stays registered but is not polled, fired or reported until an EV_ENABLE change re-arms it, as kern_event.c does with KN_DISABLED. EV_DISPATCH reports an event once and then disables the knote, and EV_FORCEONESHOT registers as oneshot. A negative nevents fails with EINVAL instead of throwing. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… flags On a new knote EV_FORCEONESHOT is dropped from the flags; on an existing one it sets EV_ONESHOT and fires the knote, as kqueue_register does at l.1339-1341. A modify no longer ORs EV_ONESHOT, EV_CLEAR or EV_DISPATCH into the knote. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
637cb1e to
a7da412
Compare
|
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.
Some 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.
|
adriadam10
left a comment
There was a problem hiding this comment.
Both points are fixed: EV_FORCEONESHOT is a no-op on add and sets EV_ONESHOT and triggers on an existing knote, as in kqueue_register, and a modify no longer adopts flags. Checked the build and ctest on the PR merged onto main, guest_kqueue passes and fails without the change; merging once the full Build is green.
… and follow Windows $Deleted paths Carries the additive pieces of boykopovar#6510 onto main after its feature was superseded by boykopovar#5847: the deleteEventFunc invocation when an EV_ONESHOT note retires in CollectTriggered, the Windows $Deleted path detection in FileEvent (IsDeleted transitions), the relaxed timer-modify and SetVnodeNotes guards, and the compatible kevent tests.
… and follow Windows $Deleted paths Carries the additive pieces of boykopovar#6510 onto main after its feature was superseded by boykopovar#5847: the deleteEventFunc invocation when an EV_ONESHOT note retires in CollectTriggered, the Windows $Deleted path detection in FileEvent (IsDeleted transitions), the relaxed timer-modify and SetVnodeNotes guards, and the compatible kevent tests.
… and follow Windows $Deleted paths Carries the additive pieces of boykopovar#6510 onto main after its feature was superseded by boykopovar#5847: the deleteEventFunc invocation when an EV_ONESHOT note retires in CollectTriggered, the Windows $Deleted path detection in FileEvent (IsDeleted transitions), the relaxed timer-modify and SetVnodeNotes guards, and the compatible kevent tests.
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)