* [PATCH] aio: Skip timer for io_getevents if timeout=0
@ 2014-11-06 12:44 Fam Zheng
2014-11-06 19:41 ` Benjamin LaHaise
0 siblings, 1 reply; 2+ messages in thread
From: Fam Zheng @ 2014-11-06 12:44 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin LaHaise, Alexander Viro, linux-aio, linux-fsdevel,
stefanha, pbonzini, lersek, famz
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>
---
fs/aio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index 84a7510..7c0b561 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -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;
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] aio: Skip timer for io_getevents if timeout=0
2014-11-06 12:44 [PATCH] aio: Skip timer for io_getevents if timeout=0 Fam Zheng
@ 2014-11-06 19:41 ` Benjamin LaHaise
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin LaHaise @ 2014-11-06 19:41 UTC (permalink / raw)
To: Fam Zheng
Cc: linux-kernel, Alexander Viro, linux-aio, linux-fsdevel, stefanha,
pbonzini, lersek
Hi Fam,
On Thu, Nov 06, 2014 at 08:44:36PM +0800, Fam Zheng wrote:
> 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
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> fs/aio.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index 84a7510..7c0b561 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -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;
> --
> 1.9.3
--
"Thought is the essence of where you are now."
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-06 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 12:44 [PATCH] aio: Skip timer for io_getevents if timeout=0 Fam Zheng
2014-11-06 19:41 ` Benjamin LaHaise
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).