From: Stefan Hajnoczi <stefanha@redhat.com>
To: Jaehoon Kim <jhkim@linux.ibm.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
pbonzini@redhat.com, fam@euphon.net, armbru@redhat.com,
eblake@redhat.com, berrange@redhat.com, eduardo@habkost.net,
dave@treblig.org, sw@weilnetz.de
Subject: Re: [PATCH RFC v1 1/3] aio-poll: avoid unnecessary polling time computation
Date: Mon, 16 Feb 2026 09:58:07 -0500 [thread overview]
Message-ID: <20260216145807.GA396170@fedora> (raw)
In-Reply-To: <20260113174824.464720-2-jhkim@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2706 bytes --]
On Tue, Jan 13, 2026 at 11:48:22AM -0600, Jaehoon Kim wrote:
> Nodes are no longer added to poll_aio_handlers when adaptive polling is
> disabled, preventing unnecessary try_poll_mode() calls. Additionally,
> aio_poll() skips try_poll_mode() when timeout is 0.
Do these two changes need to be made together? If not, please split them
into two commits. This will make the commit descriptions easier to
understand.
>
> This avoids iterating over all nodes to compute max_ns unnecessarily
> when polling is disabled or timeout is 0.
>
> Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
> ---
> util/aio-posix.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/util/aio-posix.c b/util/aio-posix.c
> index e24b955fd9..7ddf92a25f 100644
> --- a/util/aio-posix.c
> +++ b/util/aio-posix.c
> @@ -306,9 +306,8 @@ static bool aio_dispatch_handler(AioContext *ctx, AioHandler *node)
> * fdmon_supports_polling(), but only until the fd fires for the first
> * time.
> */
> - if (!QLIST_IS_INSERTED(node, node_deleted) &&
> - !QLIST_IS_INSERTED(node, node_poll) &&
> - node->io_poll) {
> + if (ctx->poll_max_ns && !QLIST_IS_INSERTED(node, node_deleted) &&
> + !QLIST_IS_INSERTED(node, node_poll) && node->io_poll) {
> trace_poll_add(ctx, node, node->pfd.fd, revents);
> if (ctx->poll_started && node->io_poll_begin) {
> node->io_poll_begin(node->opaque);
> @@ -630,7 +629,7 @@ static void adjust_polling_time(AioContext *ctx, AioPolledEvent *poll,
> bool aio_poll(AioContext *ctx, bool blocking)
> {
> AioHandlerList ready_list = QLIST_HEAD_INITIALIZER(ready_list);
> - bool progress;
> + bool progress = false;
> bool use_notify_me;
> int64_t timeout;
> int64_t start = 0;
> @@ -655,7 +654,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
> }
>
> timeout = blocking ? aio_compute_timeout(ctx) : 0;
> - progress = try_poll_mode(ctx, &ready_list, &timeout);
> + if ((ctx->poll_max_ns != 0) && (timeout != 0)) {
> + progress = try_poll_mode(ctx, &ready_list, &timeout);
> + }
> assert(!(timeout && progress));
Can you walk me through the timeout == 0 case when polling is active?
Further down in aio_poll():
/* If polling is allowed, non-blocking aio_poll does not need the
* system call---a single round of run_poll_handlers_once suffices.
*/
if (timeout || ctx->fdmon_ops->need_wait(ctx)) {
My concern is that aio_poll(timeout=0) could return without polling or
waiting for fds when polling is active. Maybe I've missed something that
prevents this?
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-02-16 14:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 17:48 [PATCH RFC v1 0/3] aio-poll: improve aio-polling efficiency Jaehoon Kim
2026-01-13 17:48 ` [PATCH RFC v1 1/3] aio-poll: avoid unnecessary polling time computation Jaehoon Kim
2026-02-16 14:58 ` Stefan Hajnoczi [this message]
2026-02-16 15:21 ` Stefan Hajnoczi
2026-02-16 20:47 ` JAEHOON KIM
2026-02-17 13:16 ` Stefan Hajnoczi
2026-02-18 13:43 ` JAEHOON KIM
2026-01-13 17:48 ` [PATCH RFC v1 2/3] aio-poll: refine iothread polling using weighted handler intervals Jaehoon Kim
2026-01-13 17:48 ` [PATCH RFC v1 3/3] qapi/iothread: introduce poll-weight parameter for aio-poll Jaehoon Kim
2026-01-14 7:48 ` Markus Armbruster
2026-01-15 5:14 ` JAEHOON KIM
2026-01-15 7:28 ` Markus Armbruster
2026-01-15 10:05 ` Halil Pasic
2026-01-15 16:00 ` JAEHOON KIM
2026-01-16 8:19 ` Markus Armbruster
2026-01-19 18:16 ` [PATCH RFC v1 0/3] aio-poll: improve aio-polling efficiency Stefan Hajnoczi
2026-01-23 19:15 ` JAEHOON KIM
2026-01-27 21:11 ` Stefan Hajnoczi
2026-02-03 21:12 ` Stefan Hajnoczi
2026-02-06 6:50 ` JAEHOON KIM
2026-02-12 18:53 ` Stefan Hajnoczi
2026-02-13 15:13 ` JAEHOON KIM
2026-02-16 12:42 ` Stefan Hajnoczi
2026-02-19 22:27 ` Stefan Hajnoczi
2026-02-20 19:00 ` JAEHOON KIM
2026-02-24 4:24 ` Stefan Hajnoczi
2026-02-26 6:03 ` JAEHOON KIM
2026-03-09 20:46 ` JAEHOON KIM
2026-03-23 14:08 ` JAEHOON KIM
2026-03-23 18:51 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260216145807.GA396170@fedora \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=fam@euphon.net \
--cc=jhkim@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.