From patchwork Wed Dec 21 14:03:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 707816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tkGkb0fSgz9sR9 for ; Thu, 22 Dec 2016 01:09:59 +1100 (AEDT) Received: from localhost ([::1]:57138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJhae-0003kw-Vh for incoming@patchwork.ozlabs.org; Wed, 21 Dec 2016 09:09:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJhV6-00061U-B9 for qemu-devel@nongnu.org; Wed, 21 Dec 2016 09:04:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJhV5-00018V-N2 for qemu-devel@nongnu.org; Wed, 21 Dec 2016 09:04:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cJhV0-000153-Ch; Wed, 21 Dec 2016 09:04:06 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84C3380E4A; Wed, 21 Dec 2016 14:04:05 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBLE3pbf031818; Wed, 21 Dec 2016 09:04:04 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 21 Dec 2016 15:03:51 +0100 Message-Id: <20161221140351.30652-11-pbonzini@redhat.com> In-Reply-To: <20161221140351.30652-1-pbonzini@redhat.com> References: <20161221140351.30652-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Dec 2016 14:04:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/10] async: optimize aio_bh_poll X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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; }