aio-poll: avoid unnecessary polling time computation
Nodes are no longer added to poll_aio_handlers when adaptive polling is disabled, preventing unnecessary try_poll_mode() calls. This avoids iterating over all nodes to compute max_ns unnecessarily when polling is disabled. Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20260423195918.661299-2-jhkim@linux.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Jaehoon Kim committed
Apr 23, 2026 at 14:59 UTC
ed21d9d65c936cbeaea6a9072c95e4787c9ae825
1 file changed
+6
-5
util/aio-posix.c
+6
-5
@@ -307,9 +307,8 @@ static bool aio_dispatch_handler(AioContext *ctx, AioHandler *node)
307
* fdmon_supports_polling(), but only until the fd fires for the first
308
* time.
309
*/
310
- if (!QLIST_IS_INSERTED(node, node_deleted) &&
311
- !QLIST_IS_INSERTED(node, node_poll) &&
312
- node->io_poll) {
310
+ if (ctx->poll_max_ns && !QLIST_IS_INSERTED(node, node_deleted) &&
311
+ !QLIST_IS_INSERTED(node, node_poll) && node->io_poll) {
312
trace_poll_add(ctx, node, node->pfd.fd, revents);
313
if (ctx->poll_started && node->io_poll_begin) {
314
node->io_poll_begin(node->opaque);
@@ -631,7 +630,7 @@ static void adjust_polling_time(AioContext *ctx, AioPolledEvent *poll,
630
bool aio_poll(AioContext *ctx, bool blocking)
631
{
632
AioHandlerList ready_list = QLIST_HEAD_INITIALIZER(ready_list);
634
- bool progress;
633
+ bool progress = false;
634
bool use_notify_me;
635
int64_t timeout;
636
int64_t start = 0;
@@ -656,7 +655,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
655
}
656
657
timeout = blocking ? aio_compute_timeout(ctx) : 0;
659
- progress = try_poll_mode(ctx, &ready_list, &timeout);
658
+ if (ctx->poll_max_ns != 0) {
659
+ progress = try_poll_mode(ctx, &ready_list, &timeout);
660
+ }
661
assert(!(timeout && progress));
662
663
/*