Skip to contentSkip to conversation

aio: Skip timer for io_getevents if timeout=0

PATCH In review Fam Zheng 2 participants 2 messages Nov 6, 2014

Subsystems (2)
lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 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.

---
 fs/aio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
index 84a7510..7c0b561 100644
@@ -1221,8 +1221,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;
Signature · 1 line
1.9.3
maintainer
#1 lore raw

Hi Fam,

Quoted 5 lines · Fam Zheng

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.

This looks quite reasonable. I've applied this to my aio-next tree.

-ben

Quoted 26 lines
---
 fs/aio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
index 84a7510..7c0b561 100644
@@ -1221,8 +1221,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;
Signature · 1 line
1.9.3
Signature · 7 lines
"Thought is the essence of where you are now."

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to [email protected].  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>