Skip to contentSkip to conversation

kqueue, kevent - kernel event notification mechanism

DISCUSSION Carlo Wood 3 participants 3 messages Dec 6, 2001

lore
Share & tools
lore

Carlo Wood

author
#0 lore raw

Hiya,

are there any plans to implement the kqueue, kevent system calls in the linux kernel?

There is no substitute for them currently; select() and poll() both suffer from dramatic cpu usage when a daemon is loaded with a few thousand clients.

It would be good for linux to implement event-driven i/o, if not by means of kqueue/kevent (BSD-ish interface) then at least in some other way.

It has been shown that a heavily loaded networking daemon like an IRC daemon uses 35% less cpu on freeBSD by using event-driven i/o instead of poll().

For those who are not into this material, allow me to explain the difference. The current i/o calls, select and poll, scan all open file descriptors for events, every call. This is clearly not scalable. Event driven means that the kernel never scans all open file descriptors but queues events as they happen on the network card - the latter would in principle be scalable to any number of open file descriptors, as long as there is enough memory and as long as there is a limited number of file descriptors active per time unit.

Signature · 1 line
Carlo Wood <[email protected]>
#1 lore raw
Quoted 2 lines

are there any plans to implement the kqueue, kevent system calls in the linux kernel?

Not that I know of

Quoted 3 lines

It would be good for linux to implement event-driven i/o, if not by means of kqueue/kevent (BSD-ish interface) then at least in some other way.

The standards way is asynchronous io (aio_* interfaces). That is being worked on

Quoted 3 lines

the difference. The current i/o calls, select and poll, scan all open file descriptors for events, every call. This is clearly not scalable. Event driven means that the kernel never scans

The API isnt directly the problem. In fact you can make a fine scalable select by implementing

	poll_setup(..............)
	poll_add/poll_remove
	poll_wait

as multiple calls giving basically the same interface that apps expected anyway. Take a look at the various /dev/poll experimental interfaces and bits of code.

Alan

#2 lore raw
In reply to Carlo Wood
Quoted 10 lines · Alan Cox

The API isnt directly the problem. In fact you can make a fine scalable select by implementing

	poll_setup(..............)
	poll_add/poll_remove
	poll_wait

as multiple calls giving basically the same interface that apps expected anyway. Take a look at the various /dev/poll experimental interfaces and bits of code.

My aio patches already have a poll operation, however it acts as a one shot
operation: an async poll does not complete until the state indicates readiness or it is cancelled. That's needed as there is a 1-1 relationship between submitted aio operations and the space in the completion ring. Still, it looks like it will work quite nicely as a means of accelerating exiting poll() based servers.

-ben

-ben