Page MenuHomeFreeBSD

Add EV_EXCLUSIVE to kevent.
Needs ReviewPublic

Authored by dchagin on May 9 2022, 10:15 PM.
Tags
None
Referenced Files
F82144109: D35155.diff
Thu, Apr 25, 10:11 PM
Unknown Object (File)
Mon, Apr 22, 7:00 AM
Unknown Object (File)
Sat, Apr 20, 7:09 PM
Unknown Object (File)
Feb 14 2024, 9:50 AM
Unknown Object (File)
Dec 22 2023, 10:04 PM
Unknown Object (File)
Dec 10 2023, 6:36 PM
Unknown Object (File)
Nov 14 2023, 3:05 AM
Unknown Object (File)
Nov 6 2023, 1:26 AM

Details

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45506
Build 42394: arc lint + arc unit

Event Timeline

second iteration, it's works, but I'm not sure.

dchagin retitled this revision from Kqueue EV_EXCLUSIVE experiments. to Add EV_EXCLUSIVE to kevent..May 10 2022, 4:06 PM
dchagin added reviewers: kib, Linux Emulation.
dchagin changed the repository for this revision from rS FreeBSD src repository - subversion to rG FreeBSD src repository.

Manual page change is probably small enough to be fixed while committing if nothing else needs revision. (As always, I can't attest to source change or consistency between it and manual page.)

lib/libc/sys/kqueue.2
289–290 ↗(On Diff #105814)
This revision is now accepted and ready to land.May 19 2022, 7:51 AM

Manual page change is probably small enough to be fixed while committing if nothing else needs revision. (As always, I can't attest to source change or consistency between it and manual page.)

Thank you! Since I don't really understand the role of influx in kevent() I won't commit until Kostya criticizes kqueue_sccan changes

Is this Review still valid, valuable, and ready to land?

Is this Review still valid, valuable, and ready to land?

Please, see my previous comment, also it would be nice to test in the real environment

dchagin added reviewers: markj, jmg.

Reading the description of EPOLLEXCLUSIVE from the epoll_ctl manual page, this looks like it provides the wrong semantics. The use-case for EPOLLEXCLUSIVE seems to be that you have multiple epoll descriptors being used to monitor events on a single object; when an event occurs, only one of the epoll descriptors will receive the event. In the Linuxulator there is a 1-1 correspondence between kqueues and epoll descriptors. You are translating EPOLLEXCLUSIVE to a per-knote flag, and if N kqueues contain an event for a given resource, there will be N independent knotes. The tests work because they use a single kqueue, but I believe that epoll semantics require EV_EXCLUSIVE to work across multiple kqueues. I believe it is unusual to have multiple threads sharing a kqueue anyway; see https://www.usenix.org/system/files/atc21-zhao.pdf

So, I would expect an implementation of EPOLLEXCLUSIVE to, at least, modify knote() such that we avoid activating more than one knote with EV_EXCLUSIVE set.

lib/libc/sys/kqueue.2
282 ↗(On Diff #105814)

The flag applies to the knote, not the entire queue.

sys/kern/kern_event.c
2086

There is no need to add a separate case, you can change line 2061 to if ((kn->kn_flags & EV_CLEAR | EV_DISPATCH | EV_EXCLUSIVE)) != 0) { and the behaviour will be unchanged.