Skip to content

Commit

Permalink
aio: Skip timer for io_getevents if timeout=0
Browse files Browse the repository at this point in the history
In this case, it is basically a polling. Let's not involve timer at all
because that would hurt performance for application event loops.

In an arbitrary test I've done, io_getevents syscall elapsed time
reduces from 50000+ nanoseconds to a few hundereds.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
  • Loading branch information
Fam Zheng authored and Benjamin LaHaise committed Dec 13, 2014
1 parent e4a0d3e commit 5f785de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,12 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr,
* the ringbuffer empty. So in practice we should be ok, but it's
* something to be aware of when touching this code.
*/
wait_event_interruptible_hrtimeout(ctx->wait,
aio_read_events(ctx, min_nr, nr, event, &ret), until);
if (until.tv64 == 0)
aio_read_events(ctx, min_nr, nr, event, &ret);
else
wait_event_interruptible_hrtimeout(ctx->wait,
aio_read_events(ctx, min_nr, nr, event, &ret),
until);

if (!ret && signal_pending(current))
ret = -EINTR;
Expand Down

0 comments on commit 5f785de

Please sign in to comment.