Received: from eggs.gnu.org ([2001:4830:134:3::10]:37420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBgtg-000386-NN for qemu-devel@nongnu.org; Tue, 29 Nov 2016 06:48:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBgtc-00084l-KK for qemu-devel@nongnu.org; Tue, 29 Nov 2016 06:48:28 -0500 Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 29 Nov 2016 12:47:07 +0100 Message-Id: <20161129114707.2975-11-pbonzini@redhat.com> In-Reply-To: <20161129114707.2975-1-pbonzini@redhat.com> References: <20161129114707.2975-1-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 10/10] async: optimize aio_bh_poll List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org Avoid entering the slow path of qemu_lockcnt_dec_and_lock if no bottom half has to be deleted. Signed-off-by: Paolo Bonzini --- async.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/async.c b/async.c index 95927fc..6f8184b 100644 --- a/async.c +++ b/async.c @@ -92,6 +92,7 @@ int aio_bh_poll(AioContext *ctx) { QEMUBH *bh, **bhp, *next; int ret; + bool deleted = false; qemu_lockcnt_inc(&ctx->list_lock); @@ -114,9 +115,17 @@ int aio_bh_poll(AioContext *ctx) aio_bh_call(bh); aio_context_release(ctx); } + if (bh->deleted) { + deleted = true; + } } /* remove deleted bhs */ + if (!deleted) { + qemu_lockcnt_dec(&ctx->list_lock); + return ret; + } + if (qemu_lockcnt_dec_and_lock(&ctx->list_lock)) { bhp = &ctx->first_bh; while (*bhp) { @@ -130,7 +139,6 @@ int aio_bh_poll(AioContext *ctx) } qemu_lockcnt_unlock(&ctx->list_lock); } - return ret; } -- 2.9.3