From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOlaW-00015Q-Tw for qemu-devel@nongnu.org; Wed, 04 Jan 2017 08:26:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOlaW-0006ou-4r for qemu-devel@nongnu.org; Wed, 04 Jan 2017 08:26:44 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOlaV-0006oa-V4 for qemu-devel@nongnu.org; Wed, 04 Jan 2017 08:26:44 -0500 Received: by mail-wm0-x243.google.com with SMTP id m203so91462215wma.3 for ; Wed, 04 Jan 2017 05:26:43 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 4 Jan 2017 14:26:25 +0100 Message-Id: <20170104132625.28059-11-pbonzini@redhat.com> In-Reply-To: <20170104132625.28059-1-pbonzini@redhat.com> References: <20170104132625.28059-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: stefanha@redhat.com, famz@redhat.com Avoid entering the slow path of qemu_lockcnt_dec_and_lock if no bottom half has to be deleted. Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- async.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/async.c b/async.c index 2305e11..0d218ab 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); @@ -112,9 +113,17 @@ int aio_bh_poll(AioContext *ctx) bh->idle = 0; aio_bh_call(bh); } + 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) { @@ -128,7 +137,6 @@ int aio_bh_poll(AioContext *ctx) } qemu_lockcnt_unlock(&ctx->list_lock); } - return ret; } -- 2.9.3