Commit 5f785de588735306ec4d7c875caf9d28481c8b21

Authored by Fam Zheng
Committed by Benjamin LaHaise
1 parent e4a0d3e720

aio: Skip timer for io_getevents if timeout=0

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>

Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -1253,8 +1253,12 @@
1253 1253 * the ringbuffer empty. So in practice we should be ok, but it's
1254 1254 * something to be aware of when touching this code.
1255 1255 */
1256   - wait_event_interruptible_hrtimeout(ctx->wait,
1257   - aio_read_events(ctx, min_nr, nr, event, &ret), until);
  1256 + if (until.tv64 == 0)
  1257 + aio_read_events(ctx, min_nr, nr, event, &ret);
  1258 + else
  1259 + wait_event_interruptible_hrtimeout(ctx->wait,
  1260 + aio_read_events(ctx, min_nr, nr, event, &ret),
  1261 + until);
1258 1262  
1259 1263 if (!ret && signal_pending(current))
1260 1264 ret = -EINTR;