From patchwork Mon Jun 5 08:57:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 13267099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 994DAC7EE2A for ; Mon, 5 Jun 2023 08:59:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6626-0005jD-Gy; Mon, 05 Jun 2023 04:57:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q661w-0005e2-RD for qemu-devel@nongnu.org; Mon, 05 Jun 2023 04:57:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q661r-0004tt-RC for qemu-devel@nongnu.org; Mon, 05 Jun 2023 04:57:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685955451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8kn4X9cTNOGnvKvkys0hQOWHt63gb/D4FmLjivC66Vo=; b=Hw+Opvd8kWs0Q8E+mbeXiXuCeNakg44kZhmkcypb7kOjkryQHzooyiNKZ8m8M8dvzuQYuP mM4jW45osNzLWyLjhST3Bx3X8iOrXprUlQ7t5h/w7HMd4BNQZUKnLXcyqumw+hlI1WNLU9 FYuMmcK+f72pafLhilxIJuj406qcNmk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-srQNjcU0Ox2jis29ML0SuQ-1; Mon, 05 Jun 2023 04:57:29 -0400 X-MC-Unique: srQNjcU0Ox2jis29ML0SuQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 564E9803D45; Mon, 5 Jun 2023 08:57:29 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.193.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C3F340C6EC4; Mon, 5 Jun 2023 08:57:28 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, hreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v2 11/11] Revert "graph-lock: Disable locking for now" Date: Mon, 5 Jun 2023 10:57:11 +0200 Message-Id: <20230605085711.21261-12-kwolf@redhat.com> In-Reply-To: <20230605085711.21261-1-kwolf@redhat.com> References: <20230605085711.21261-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that bdrv_graph_wrlock() temporarily drops the AioContext lock that its caller holds, it can poll without causing deadlocks. We can now re-enable graph locking. This reverts commit ad128dff0bf4b6f971d05eb4335a627883a19c1d. Signed-off-by: Kevin Wolf --- block/graph-lock.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/block/graph-lock.c b/block/graph-lock.c index 3bf2591dc4..40fcadbd3e 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -30,10 +30,8 @@ BdrvGraphLock graph_lock; /* Protects the list of aiocontext and orphaned_reader_count */ static QemuMutex aio_context_list_lock; -#if 0 /* Written and read with atomic operations. */ static int has_writer; -#endif /* * A reader coroutine could move from an AioContext to another. @@ -90,7 +88,6 @@ void unregister_aiocontext(AioContext *ctx) g_free(ctx->bdrv_graph); } -#if 0 static uint32_t reader_count(void) { BdrvGraphRWlock *brdv_graph; @@ -108,21 +105,13 @@ static uint32_t reader_count(void) assert((int32_t)rd >= 0); return rd; } -#endif void bdrv_graph_wrlock(BlockDriverState *bs) { AioContext *ctx = NULL; GLOBAL_STATE_CODE(); - /* - * TODO Some callers hold an AioContext lock when this is called, which - * causes deadlocks. Reenable once the AioContext locking is cleaned up (or - * AioContext locks are gone). - */ -#if 0 assert(!qatomic_read(&has_writer)); -#endif /* * Release only non-mainloop AioContext. The mainloop often relies on the @@ -137,7 +126,6 @@ void bdrv_graph_wrlock(BlockDriverState *bs) } } -#if 0 /* Make sure that constantly arriving new I/O doesn't cause starvation */ bdrv_drain_all_begin_nopoll(); @@ -166,7 +154,6 @@ void bdrv_graph_wrlock(BlockDriverState *bs) } while (reader_count() >= 1); bdrv_drain_all_end(); -#endif if (ctx) { aio_context_acquire(bdrv_get_aio_context(bs)); @@ -176,7 +163,6 @@ void bdrv_graph_wrlock(BlockDriverState *bs) void bdrv_graph_wrunlock(void) { GLOBAL_STATE_CODE(); -#if 0 QEMU_LOCK_GUARD(&aio_context_list_lock); assert(qatomic_read(&has_writer)); @@ -188,13 +174,10 @@ void bdrv_graph_wrunlock(void) /* Wake up all coroutine that are waiting to read the graph */ qemu_co_enter_all(&reader_queue, &aio_context_list_lock); -#endif } void coroutine_fn bdrv_graph_co_rdlock(void) { - /* TODO Reenable when wrlock is reenabled */ -#if 0 BdrvGraphRWlock *bdrv_graph; bdrv_graph = qemu_get_current_aio_context()->bdrv_graph; @@ -254,12 +237,10 @@ void coroutine_fn bdrv_graph_co_rdlock(void) qemu_co_queue_wait(&reader_queue, &aio_context_list_lock); } } -#endif } void coroutine_fn bdrv_graph_co_rdunlock(void) { -#if 0 BdrvGraphRWlock *bdrv_graph; bdrv_graph = qemu_get_current_aio_context()->bdrv_graph; @@ -277,7 +258,6 @@ void coroutine_fn bdrv_graph_co_rdunlock(void) if (qatomic_read(&has_writer)) { aio_wait_kick(); } -#endif } void bdrv_graph_rdlock_main_loop(void) @@ -296,18 +276,13 @@ void assert_bdrv_graph_readable(void) { /* reader_count() is slow due to aio_context_list_lock lock contention */ /* TODO Reenable when wrlock is reenabled */ -#if 0 #ifdef CONFIG_DEBUG_GRAPH_LOCK assert(qemu_in_main_thread() || reader_count()); #endif -#endif } void assert_bdrv_graph_writable(void) { assert(qemu_in_main_thread()); - /* TODO Reenable when wrlock is reenabled */ -#if 0 assert(qatomic_read(&has_writer)); -#endif }