From patchwork Mon Feb 8 16:14:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 580368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D3021140784 for ; Tue, 9 Feb 2016 03:18:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=srCNpE4Y; dkim-atps=neutral Received: from localhost ([::1]:46218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoWL-0002fy-Hp for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2016 11:18:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoTI-0006CL-7q for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSoTH-0002R0-8O for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:28 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoTH-0002Qu-1u for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:27 -0500 Received: by mail-wm0-x241.google.com with SMTP id 128so16171687wmz.3 for ; Mon, 08 Feb 2016 08:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=i2uXwCbB+7YyK/44AzZzoTaB6bmsZzD6d6bHXsAyhQc=; b=srCNpE4Y6p4n1wBz9D04YjDr30O4q0P65YINvlm6CCk/DCFmivJGAIa+2Ul63vzPDW 3Vmjd7MBN/uHdunDMsa1YC5t5erKHHiMyq+jkJHBBKdrSaOkBWd2C1q5OQuMXSceVTr8 aSz9TkJHTGCLVdJwSkX6QXv2+SFe9h/h7Zu7eRoqIk5c244DDJ8jAKvVtXIedsuvoNG/ dEBx0Ge1nS0e5PyFyaipgid0EXo94U755RnxwfDxfAuzSY8/WIw7utSc1U0S7J1EQX6F eGptVlMs7Iv4vMSPoYmSw7ciOOT0wTXMWkFewMuFnYUfOLDeiLx4LU//VG2y+I7ioYUy TEVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=i2uXwCbB+7YyK/44AzZzoTaB6bmsZzD6d6bHXsAyhQc=; b=igB57OvU9SUITEgsP0VVicmBIIuOTyks+5q70L4I/0S/2vDnUhVknwRpa35JS2wOjA xc0NE8pxVUQqSGlcWPXilbS1X5GoHrDLwhyxe2rTrGJxT8He5wwTRASWBDQ0yw1ckBkB 1R7nOhSaDSxyYsgQon+Gd8cqxjisiAQFtIMRM850kxpEo3dAtAhMhPf+WAobRwzLlLjF cnTKLXXyGOFRH1z/GtfW3l3TSbs1vjvzNp8sBPBCx6C9HY9pMp7TVrI6yEYEkPhHsTKY HCmxCGC4rd42WmwfkaZR6o/I9lynDYET+eVWsV8B3QHeJV/XeDImgp9mnYYImeR/EN80 8Ruw== X-Gm-Message-State: AG10YORBTIEZkI3BzNM4mreP304UX7Tvt0cGqQRlOl8n0rpkPzGJiDrto/dawnq3Qi1+YA== X-Received: by 10.194.58.169 with SMTP id s9mr24107804wjq.52.1454948126607; Mon, 08 Feb 2016 08:15:26 -0800 (PST) Received: from donizetti.lan (94-39-141-130.adsl-ull.clienti.tiscali.it. [94.39.141.130]) by smtp.gmail.com with ESMTPSA id v2sm13305429wmd.24.2016.02.08.08.15.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 08:15:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 17:14:59 +0100 Message-Id: <1454948107-11844-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454948107-11844-1-git-send-email-pbonzini@redhat.com> References: <1454948107-11844-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Cc: stefanha@redhat.com Subject: [Qemu-devel] [PATCH 08/16] aio: rename bh_lock to list_lock X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This will be used for AioHandlers too. There is going to be little or no contention, so it is better to reuse the same lock. Signed-off-by: Paolo Bonzini --- async.c | 16 ++++++++-------- include/block/aio.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/async.c b/async.c index edb2846..fc4c173 100644 --- a/async.c +++ b/async.c @@ -51,12 +51,12 @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) .cb = cb, .opaque = opaque, }; - qemu_mutex_lock(&ctx->bh_lock); + qemu_mutex_lock(&ctx->list_lock); bh->next = ctx->first_bh; /* Make sure that the members are ready before putting bh into list */ smp_wmb(); ctx->first_bh = bh; - qemu_mutex_unlock(&ctx->bh_lock); + qemu_mutex_unlock(&ctx->list_lock); return bh; } @@ -98,7 +98,7 @@ int aio_bh_poll(AioContext *ctx) /* remove deleted bhs */ if (!ctx->walking_bh) { - qemu_mutex_lock(&ctx->bh_lock); + qemu_mutex_lock(&ctx->list_lock); bhp = &ctx->first_bh; while (*bhp) { bh = *bhp; @@ -109,7 +109,7 @@ int aio_bh_poll(AioContext *ctx) bhp = &bh->next; } } - qemu_mutex_unlock(&ctx->bh_lock); + qemu_mutex_unlock(&ctx->list_lock); } return ret; @@ -240,7 +240,7 @@ aio_ctx_finalize(GSource *source) thread_pool_free(ctx->thread_pool); - qemu_mutex_lock(&ctx->bh_lock); + qemu_mutex_lock(&ctx->list_lock); while (ctx->first_bh) { QEMUBH *next = ctx->first_bh->next; @@ -250,12 +250,12 @@ aio_ctx_finalize(GSource *source) g_free(ctx->first_bh); ctx->first_bh = next; } - qemu_mutex_unlock(&ctx->bh_lock); + qemu_mutex_unlock(&ctx->list_lock); aio_set_event_notifier(ctx, &ctx->notifier, false, NULL); event_notifier_cleanup(&ctx->notifier); qemu_rec_mutex_destroy(&ctx->lock); - qemu_mutex_destroy(&ctx->bh_lock); + qemu_mutex_destroy(&ctx->list_lock); timerlistgroup_deinit(&ctx->tlg); } @@ -551,7 +551,7 @@ AioContext *aio_context_new(Error **errp) (EventNotifierHandler *) event_notifier_dummy_cb); ctx->thread_pool = NULL; - qemu_mutex_init(&ctx->bh_lock); + qemu_mutex_init(&ctx->list_lock); qemu_rec_mutex_init(&ctx->lock); timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx); diff --git a/include/block/aio.h b/include/block/aio.h index 3f055d2..322a10e 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -88,7 +88,7 @@ struct AioContext { uint32_t notify_me; /* lock to protect between bh's adders and deleter */ - QemuMutex bh_lock; + QemuMutex list_lock; /* Anchor of the list of Bottom Halves belonging to the context */ struct QEMUBH *first_bh;