Page MenuHomeFreeBSD

Add EV_EXCLUSIVE to kevent.
Needs ReviewPublic

Authored by dchagin on May 9 2022, 10:15 PM.
Tags
None
Referenced Files
F155013563: D35155.diff
Thu, Apr 30, 4:46 PM
Unknown Object (File)
Mon, Apr 27, 10:23 AM
Unknown Object (File)
Fri, Apr 24, 5:10 AM
Unknown Object (File)
Tue, Apr 21, 3:58 AM
Unknown Object (File)
Mon, Apr 20, 12:31 AM
Unknown Object (File)
Fri, Apr 17, 2:15 PM
Unknown Object (File)
Wed, Apr 15, 10:26 AM
Unknown Object (File)
Wed, Apr 15, 5:40 AM

Details

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45515
Build 42403: 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
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

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

sys/kern/kern_event.c
2074

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.

Someone was asking about something like this on Discord; thinking just in terms of providing a flag that matches EPOLLEXCLUSIVE semantics and ignoring the Linuxolator aspect for a minute: I think the bulk of the implementation would actually be in knote() instead, effectively only KNOTE_ACTIVATE'ing some subset of what we touched if some of them are marked EXCLUSIVE. I don't know that it's quite that straightforward, though.