LWN.net Logo

Kernel events without kevents

Kernel events without kevents

Posted Mar 15, 2007 13:45 UTC (Thu) by pphaneuf (guest, #23480)
Parent article: Kernel events without kevents

On the other hand, the poll interfaces do not provide a way for applications to receive events without the need to call into the kernel - a feature which has been requested by some interested parties.

I keep being mystified by this, since there clearly need to be some synchronization between userspace and the kernel, which seems to be done with kevent_commit(), which is... a system call, that, uh, calls into the kernel.

Generality of kevent with regard to AIO and other event sources can be interesting, its possibly avoiding copies through mmapping the ring buffer between userspace and the kernel, is another possibly interesting, and while I happen to not be too convinced by either of these points, they have the merit of at least existing.

But unless I am nuts (which might be the case!), getting events from kevent requires calling into the kernel. Either someone explains to me how this is not the case, exactly, or people stop saying that.


(Log in to post comments)

Kernel events without kernel calls

Posted Mar 15, 2007 13:55 UTC (Thu) by corbet (editor, #1) [Link]

But unless I am nuts (which might be the case!), getting events from kevent requires calling into the kernel. Either someone explains to me how this is not the case, exactly, or people stop saying that.

That's what the whole user-space event ring mechanism is about. This article from December describes a recent version of the API.

Kernel events without kernel calls

Posted Mar 15, 2007 14:03 UTC (Thu) by pphaneuf (guest, #23480) [Link]

And, as per that linked article, when events are consumed from the ring buffer, kevent_commit() (which I presume is a system call, "calling into the kernel"), has to be called "from time to time".

Some batching can be done, but this is very similar to the kind of batching that happens when calling epoll_wait() with a "maxevents" parameter bigger than one.

So, there's a system call at a similar frequency as epoll occuring. I'll grant you, there is some opportunity for less copying of the events structures, as I mentioned, but that's it.

Kernel events without kernel calls

Posted Mar 22, 2007 22:56 UTC (Thu) by hno (guest, #43549) [Link]

There is significant difference between epoll and ring buffer batching.

with epoll you have an syscall each and every time you want to process events, even if there is a single event to process.

With a ring buffer you only need to notify the kernel when there is a risk the kernel may run out of space in the buffer. For example once per rinbuffersize/2 number of events processed.

But it's true that when you get heavily CPU bound and not able to keep up with the rate of events the two converges to about the same. But as long as processing is able to keep up with the rate of events the ring buffer always wins, i.e. in all situations except complete overload.

So in worst case the ring buffer performs equal to explicit call, on average significantly better than explicit call.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds