From: Yaowei Bai Date: Wed, 14 Sep 2016 11:03:39 +0000 (-0400) Subject: aio-posix: avoid unnecessary aio_epoll_enabled() calls X-Git-Tag: v2.8.0-rc0~104^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b9424689a32bb76942ec39f6d5c60b72eb002e0;p=thirdparty%2Fqemu.git aio-posix: avoid unnecessary aio_epoll_enabled() calls As epoll whether enabled or not is a global setting, we can just check it only once rather than checking it with every node iteration. Through this we can avoid a lot of checks when epoll is not enabled. Signed-off-by: Yaowei Bai Reviewed-by: Xiubo Li Message-id: 1473851019-7005-3-git-send-email-baiyaowei@cmss.chinamobile.com Signed-off-by: Stefan Hajnoczi --- diff --git a/aio-posix.c b/aio-posix.c index 43162a9f291..4ef34dd1750 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -431,11 +431,13 @@ bool aio_poll(AioContext *ctx, bool blocking) assert(npfd == 0); /* fill pollfds */ - QLIST_FOREACH(node, &ctx->aio_handlers, node) { - if (!node->deleted && node->pfd.events - && !aio_epoll_enabled(ctx) - && aio_node_check(ctx, node->is_external)) { - add_pollfd(node); + + if (!aio_epoll_enabled(ctx)) { + QLIST_FOREACH(node, &ctx->aio_handlers, node) { + if (!node->deleted && node->pfd.events + && aio_node_check(ctx, node->is_external)) { + add_pollfd(node); + } } }