Skip to content

epoll keyed wakeups - introduction

Davide Libenzi lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7epoll keyed wakeups - make __wake_up_locked accept a key parameterinclude/linux/wait.h kernel/sched.c+4 -40 replies
2/7epoll keyed wakeups - make __wake_up_sync accept a key parameterinclude/linux/wait.h kernel/sched.c+8 -40 replies
3/7epoll keyed wakeups - introduce key-aware wakeup macrosinclude/linux/wait.h+29 -1212 replies
4/7epoll keyed wakeups - make sockets use keyed wakeupsnet/core/sock.c+3 -30 replies
5/7epoll keyed wakeups - teach epoll about hints coming with the wakeup keyfs/eventpoll.c+9 -10 replies
6/7epoll keyed wakeups - make eventfd use keyed wakeupsfs/eventfd.c+3 -30 replies
7/7epoll keyed wakeups - make tty use keyed wakeupsdrivers/char/tty_io.c+10 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [patch 0/7] epoll keyed wakeups - introduction

The follwing patch set introduces wakeup hints for some of the most popular (from epoll POV) devices, so that epoll code can avoid spurious wakeups on its waiters.
The problem with epoll is that the callback-based wakeups do not, ATM, carry any information about the events the wakeup is related to. So the only choice epoll has (not being able to call f_op->poll() from inside the callback), is to add the file* to a ready-list and resolve the real events later on, at epoll_wait() (or its own f_op->poll()) time. This can cause spurious wakeups, since the wake_up() itself might be for an event the caller is not interested into.
The rate of these spurious wakeup can be pretty high in case of many network sockets being monitored.
By allowing devices to report the events the wakeups refer to (at least the two major classes - POLLIN/POLLOUT), we are able to spare useless wakeups by proper handling inside the epoll's poll callback. Epoll will have in any case to call f_op->poll() on the file* later on, since the change to be done in order to have the full event set sent via wakeup, is too invasive for the way our f_op->poll() system works (the full event set is calculated inside the poll function - there are too many of them to even start thinking the change - also poll/select would need change too).
Epoll is changed in a way that both devices which send event hints, and the ones that don't, are correctly handled. The former will gain some efficiency though.
As a general rule for devices, would be to add an event mask by using key-aware wakeup macros, when making up poll wait queues. Test program available here:

http://www.xmailserver.org/epoll_test.c

Andrew, those are directly based over the bits you already have in -mm.

- Davide