From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704356; cv=none; d=zohomail.com; s=zohoarc; b=jiyaesapZvzDfESeA1vnhAeo8oYjBu4/BqBJnjQjcpDchqvGnPoTe4FfhCNW+09b5wP/EfpGETvWlYcFrw2gZkUo/gd5x6Ge60XkgjzcF9rIDVMA9RX2sdHBbRPoTC/mYA84cJRQFx+hmvRHATLTgA0lJgPDH+rSDUmTd3ATAhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704356; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A/TobBksR8XjbrP3bHhTfUZS09aM4kuJxHipMzY0CJI=; b=VX+rPdr0l5ZH9Uld1T7QfZlPi+sXjwFfirI0x2oZ3cy2+eGlMvJwVbfxlBa7txl11hObbYp7UjqIQKCymOXS1bzZEn/mUFFD+fVwQb2KNSVxdvUPHnCEbl/tGcS7GwlgrqkgaJvhj2WpAtxpaRtv64+rspPa2UluV4zaN4K3nzw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16777043569361011.651394522777; Wed, 1 Mar 2023 12:59:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTX2-0003OS-Nf; Wed, 01 Mar 2023 15:58:36 -0500 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 1pXTX1-0003Nt-AX for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXTWz-0003zh-5m for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:35 -0500 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-158-NE4KwpkTMTGl9XbEwNEvqg-1; Wed, 01 Mar 2023 15:58:27 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F6D9181E3EF; Wed, 1 Mar 2023 20:58:26 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3815C15BAD; Wed, 1 Mar 2023 20:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704312; 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=A/TobBksR8XjbrP3bHhTfUZS09aM4kuJxHipMzY0CJI=; b=aHn3LDZEWGS/gMnhpCV3V0RnkVCirqx2EaVKJUDgWfdI4kYJhlndvTIAf8zje9Iyx00QNx Qpjj/bHkr0PYGiv+Kfey7i86QD2kdSEoPhpjWOVGhtz9gG6Y6H/HAbS50Bb1wL3wjySSbn ewLoqDOkWrQNCBl0G7rs9TSU0juE0R0= X-MC-Unique: NE4KwpkTMTGl9XbEwNEvqg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 1/6] block: don't acquire AioContext lock in bdrv_drain_all() Date: Wed, 1 Mar 2023 15:57:56 -0500 Message-Id: <20230301205801.2453491-2-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704358345100002 Content-Type: text/plain; charset="utf-8" There is no need for the AioContext lock in bdrv_drain_all() because nothing in AIO_WAIT_WHILE() needs the lock and the condition is atomic. Note that the NULL AioContext argument to AIO_WAIT_WHILE() is odd. In the future it can be removed. There is an assertion in AIO_WAIT_WHILE() that checks that we're in the main loop AioContext and we would lose that check by dropping the argument. However, that was a precursor to the GLOBAL_STATE_CODE()/IO_CODE() macros and is now a duplicate check. So I think we won't lose much by dropping it, but let's do a few more AIO_WAIT_WHILE_UNLOCKED() coversions of this sort to confirm this is the case. Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block/block-backend.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 278b04ce69..d2b6b3652d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1835,14 +1835,8 @@ void blk_drain_all(void) bdrv_drain_all_begin(); =20 while ((blk =3D blk_all_next(blk)) !=3D NULL) { - AioContext *ctx =3D blk_get_aio_context(blk); - - aio_context_acquire(ctx); - /* We may have -ENOMEDIUM completions in flight */ - AIO_WAIT_WHILE(ctx, qatomic_mb_read(&blk->in_flight) > 0); - - aio_context_release(ctx); + AIO_WAIT_WHILE_UNLOCKED(NULL, qatomic_mb_read(&blk->in_flight) > 0= ); } =20 bdrv_drain_all_end(); --=20 2.39.2 From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704368; cv=none; d=zohomail.com; s=zohoarc; b=hleHYABBO16efoj36QwvoeqTS6tsic+2fUzDSOE7k7G4vOiuaM9IR2coQnVRI8RNyOcRivGgxuuGWIde5gK1kDQksODe+zy+tjQP3aQw0grF5giRXd/CFY8eTOF0VgHL/ywz45tU+vIFXUwBowtJAaRY2upAPwLlcVtB/2MczZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704368; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LdGb5Ls2u5U36PxIozwXUuHqm0B9xfiL5iWE7YMkha8=; b=AyB6CB5mFKOu6l0qiV31zOS0fFO2wI9aDmYYeyDkq8jtMQhtPn/5AgwYrlyuLyxGaAMNzgChHME0ZPkwb6670CQwZBgtDnWHkWFkQTwvQ6wETwU3wxuKNh9rJSzgHM8uPMMkOzSWW+AzuFxAFG9HPZE9uGdjk1BYJXR5K9wHFpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677704368239479.3317354038983; Wed, 1 Mar 2023 12:59:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTX1-0003Nq-4c; Wed, 01 Mar 2023 15:58:35 -0500 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 1pXTX0-0003LV-4P for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:34 -0500 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 1pXTWy-0003zZ-OI for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:33 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-465-rB75_74tPkWgzvltuna-ig-1; Wed, 01 Mar 2023 15:58:29 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C83D3C0D181; Wed, 1 Mar 2023 20:58:28 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B288492C14; Wed, 1 Mar 2023 20:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704312; 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=LdGb5Ls2u5U36PxIozwXUuHqm0B9xfiL5iWE7YMkha8=; b=Tk3mwH7kTvemVHtFR5smjNUCWU4Zb7VsHQiMJAJEmf00I6zwNLfAOjtdXiRh4VONwTUOwg o8PnPyWOsDKK6wITEH+UShAL8gCb/aYScuBNTKC7pf5RVP4bY3KhtvUbQoEuIlcgtlC/cf gzK9kEwgdUuYsIiciP3/qgGvunSSAXk= X-MC-Unique: rB75_74tPkWgzvltuna-ig-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 2/6] block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED() Date: Wed, 1 Mar 2023 15:57:57 -0500 Message-Id: <20230301205801.2453491-3-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704370235100002 Content-Type: text/plain; charset="utf-8" There is no change in behavior. Switch to AIO_WAIT_WHILE_UNLOCKED() instead of AIO_WAIT_WHILE() to document that this code has already been audited and converted. The AioContext argument is already NULL so aio_context_release() is never called anyway. Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- block/export/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/export/export.c b/block/export/export.c index 28a91c9c42..e3fee60611 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -306,7 +306,7 @@ void blk_exp_close_all_type(BlockExportType type) blk_exp_request_shutdown(exp); } =20 - AIO_WAIT_WHILE(NULL, blk_exp_has_type(type)); + AIO_WAIT_WHILE_UNLOCKED(NULL, blk_exp_has_type(type)); } =20 void blk_exp_close_all(void) --=20 2.39.2 From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704394; cv=none; d=zohomail.com; s=zohoarc; b=ZMy0pQ+1aGlxkyYyWzPXLVzyiXxhKgKI4KdzKnWCEf4+LareRffao1mrCRoNZGEwwLHBv6sl94YdoFBt2g+hpvu8m6yZC8sCJSiEtuSHqHLwRQq5Yh1FoFxQgOOIinp8ci67YaRTiZ9vSNtzZ3wf7qymUCrldRqYr4d3T9NBzbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704394; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9jar66EgWAWpe6Qk8yO0Iso5fl52X8ZjyyQ+aBAGVe0=; b=a5WdCB8hNhGThD2f0l3ZLPK5uEt7vL2SCtolKiibHjg++4JJlw7fZEo0LakHzS0aKSnuHsvrVZCiMcsRPnfR2ghKZLYsxg+ODC6VIv/a/tPO92s8F5SLUskMYNR3GjaG6qRX6lxifQl8ehuwgBcU+xZNeYI3ki0R6/QaKgPSdWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677704394914136.8938702089971; Wed, 1 Mar 2023 12:59:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTXD-0003YH-KX; Wed, 01 Mar 2023 15:58:47 -0500 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 1pXTXC-0003Uh-5J for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:46 -0500 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 1pXTXA-00041g-Jv for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:45 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-b5FlmGpuOb-BSFCwX5_cWw-1; Wed, 01 Mar 2023 15:58:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53DBD3811F20; Wed, 1 Mar 2023 20:58:41 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC7D62166B26; Wed, 1 Mar 2023 20:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704324; 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=9jar66EgWAWpe6Qk8yO0Iso5fl52X8ZjyyQ+aBAGVe0=; b=g8j5hIlRIahdpp5Ji0sJ70ewIhlkq3+qlo31/Wb3MTXTKJ11aX/aZst81UpvMH/a+ORbGy mPJmuDw18THgfd36VeZuxRSf3+hlB3FuRd3aK0AT0lQxYjzvVw9qQDiFjcNvlbPqYCyqTg +6J0Bzkzuoo6GfF1QWZWMtFW/G1IV3s= X-MC-Unique: b5FlmGpuOb-BSFCwX5_cWw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED() Date: Wed, 1 Mar 2023 15:57:58 -0500 Message-Id: <20230301205801.2453491-4-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704396377100003 Content-Type: text/plain; charset="utf-8" The following conversion is safe and does not change behavior: GLOBAL_STATE_CODE(); ... - AIO_WAIT_WHILE(qemu_get_aio_context(), ...); + AIO_WAIT_WHILE_UNLOCKED(NULL, ...); Since we're in GLOBAL_STATE_CODE(), qemu_get_aio_context() is our home thread's AioContext. Thus AIO_WAIT_WHILE() does not unlock the AioContext: if (ctx_ && in_aio_context_home_thread(ctx_)) { \ while ((cond)) { \ aio_poll(ctx_, true); \ waited_ =3D true; \ } \ And that means AIO_WAIT_WHILE_UNLOCKED(NULL, ...) can be substituted. Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- block/graph-lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/graph-lock.c b/block/graph-lock.c index 454c31e691..639526608f 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -127,7 +127,7 @@ void bdrv_graph_wrlock(void) * reader lock. */ qatomic_set(&has_writer, 0); - AIO_WAIT_WHILE(qemu_get_aio_context(), reader_count() >=3D 1); + AIO_WAIT_WHILE_UNLOCKED(NULL, reader_count() >=3D 1); qatomic_set(&has_writer, 1); =20 /* --=20 2.39.2 From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704382; cv=none; d=zohomail.com; s=zohoarc; b=k+hhuEhoOJHW9gRcsU16Ojd/TGs52Zb0WrWibaaZKL/7xzsvLvbHFOp6abUZR7WIzKQDuEE5g5DuuV9VUtpMzPU/ij/0gA1pwWb9+Wo+z3Xux+YA+bpMnjhUpaJl6WIE1dRMaaSLwmD7K2j1/9dpUqfibWDir92DDxnZmy7I8rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704382; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EQQslyk0CFxJfyjKuK+Q1w9UawRHB447WDiYX7wePso=; b=ASW3cSLmtQfpkWtyIQeplDxqY/z/XpSXgC++dHzQF8B8dK8eRDEb43da/BIxFbFmoCU6gA8llzTdSV34WMBs7w/BmQCL3kTRS+JBI5lwRMpPbjEKvKLP6fM+16ip7oNb/ch7QTTsbRfquU7miqbttBI6sNyGv5tgbnpqpbK5aOs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167770438298321.786723579780983; Wed, 1 Mar 2023 12:59:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTXH-0003j6-KN; Wed, 01 Mar 2023 15:58:51 -0500 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 1pXTXF-0003ec-Rb for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:49 -0500 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 1pXTXE-00042k-Gr for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:49 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-WVYR6tm5MxaPEgX7xFwQGA-1; Wed, 01 Mar 2023 15:58:44 -0500 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 F40F03C0D181; Wed, 1 Mar 2023 20:58:43 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4107740C6EC4; Wed, 1 Mar 2023 20:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704328; 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=EQQslyk0CFxJfyjKuK+Q1w9UawRHB447WDiYX7wePso=; b=Q7tvNpBJ7hEeyw5CuB1cnpJggMWZS+T4GUIYEDqAk9P5vgirNXHW0W7IiwdRlz4PceCyMU 5+0nEIdMxlKHKgvEoijMaW3qgsycEgUOgZoO1pnpQxxuJ7d5j35tisWTVWAope68C+VIVV n20mQtdVjlZjb7gphRrjy3kj2qImK54= X-MC-Unique: WVYR6tm5MxaPEgX7xFwQGA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 4/6] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED() Date: Wed, 1 Mar 2023 15:57:59 -0500 Message-Id: <20230301205801.2453491-5-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704384334100003 Content-Type: text/plain; charset="utf-8" Since the AioContext argument was already NULL, AIO_WAIT_WHILE() was never going to unlock the AioContext. Therefore it is possible to replace AIO_WAIT_WHILE() with AIO_WAIT_WHILE_UNLOCKED(). Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 8974d46941..db438c7657 100644 --- a/block/io.c +++ b/block/io.c @@ -520,7 +520,7 @@ void bdrv_drain_all_begin(void) bdrv_drain_all_begin_nopoll(); =20 /* Now poll the in-flight requests */ - AIO_WAIT_WHILE(NULL, bdrv_drain_all_poll()); + AIO_WAIT_WHILE_UNLOCKED(NULL, bdrv_drain_all_poll()); =20 while ((bs =3D bdrv_next_all_states(bs))) { bdrv_drain_assert_idle(bs); --=20 2.39.2 From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704399; cv=none; d=zohomail.com; s=zohoarc; b=TAizv0dBekpVmrSFt/Uxq1Ji0I4NXsZrkdtuTaBS8ikEEEpK+uA329Q7Y3lnrGM1FxS42Q9R7bvIAqAKuLWmEEJTR4F51jLsFB8vDnveNwSwuKRk6w+ODTYgNgTY7KCbxvc7xkkcfQTvZGOF45C4Mgx2CSrxCzalbYtvuQPtmpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hGMUDOrvdrqVeJV6p0I58n/itCYTbVoWgepoEQjV6cI=; b=MpUWjR+wuM2sPoBpUdXFDe2KsLc9j5M1I+n/Fdk1bnAxqSAaMshHOJQQrDrQxgPRdSZygMV+EZZF9/UELv2BdsNBhQ1j879fXYkPf/n4tAdTJEyCmM1xY0mXi4SheWfA6kabtoTeB5FwenW5M2Gz2ldsoBD0H3IO0Ph7loG601s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677704399129861.3858314112678; Wed, 1 Mar 2023 12:59:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTXH-0003h6-C3; Wed, 01 Mar 2023 15:58:51 -0500 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 1pXTXG-0003fM-7M for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:50 -0500 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 1pXTXE-00042n-Od for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:49 -0500 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-261-zICkY_JhNTOGr5Pi9a4sTA-1; Wed, 01 Mar 2023 15:58:46 -0500 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 6FD23181E3F0; Wed, 1 Mar 2023 20:58:46 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9D7B4014D1B; Wed, 1 Mar 2023 20:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704328; 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=hGMUDOrvdrqVeJV6p0I58n/itCYTbVoWgepoEQjV6cI=; b=EwNZQZuLlBbYZX/0tS4akSb1e+inVR753KdX1xqTfyEdGZI7zJc2f51/tbjEpUFo1Y4SMh V8uWvh3mkYdSXc06pIengqFJwVVPuI3IJwokYY0e6HtAY8rQ4ZOTI04TxG2a4cNq4WOxad OoX5dQ1h3wXRijXO7sU+07pz/zvCCgI= X-MC-Unique: zICkY_JhNTOGr5Pi9a4sTA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 5/6] hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED() Date: Wed, 1 Mar 2023 15:58:00 -0500 Message-Id: <20230301205801.2453491-6-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704400400100003 Content-Type: text/plain; charset="utf-8" The HMP monitor runs in the main loop thread. Calling AIO_WAIT_WHILE(qemu_get_aio_context(), ...) from the main loop thread is equivalent to AIO_WAIT_WHILE_UNLOCKED(NULL, ...) because neither unlocks the AioContext and the latter's assertion that we're in the main loop succeeds. Signed-off-by: Stefan Hajnoczi Acked-by: Markus Armbruster Reviewed-by: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- monitor/hmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index 2aa85d3982..5ecbdac802 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1167,7 +1167,7 @@ void handle_hmp_command(MonitorHMP *mon, const char *= cmdline) Coroutine *co =3D qemu_coroutine_create(handle_hmp_command_co, &da= ta); monitor_set_cur(co, &mon->common); aio_co_enter(qemu_get_aio_context(), co); - AIO_WAIT_WHILE(qemu_get_aio_context(), !data.done); + AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done); } =20 qobject_unref(qdict); --=20 2.39.2 From nobody Sun May 5 09:14:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677704384; cv=none; d=zohomail.com; s=zohoarc; b=nb7kxDnWNMUhwaVm1DzkUCk/hr302VdqXF7rYNDBpVj2LzDUXMGnoI4UK2Zbrnx/xeemVesMKoEdGTY089jcbX78pmzLFBdQxJJpBIwIzribo1FWYh1L8zHnb8VqUw3T0pjALF4h2/TeLnrsLuLrg1pxg4YvqwdY4Yu3L5sBcVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677704384; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l7FHaIBM/eBasSIGq1f13k97Nq9uyQeyH+6pJ/nmRAA=; b=Efz6+TprkibMQRUr8lswfN7T5jc1cHz/wvNPUbvPERMhFA1VUG7sWF8y29mBxeo4R7uGoIoOldM+xl+HtAdp3hcKrPJswXxLfab14YACp94mSyM5b8L0Z9q7I6zffT4Ti7275Juk5zVIJBKjJcD+q66fZ/pOOgZ1HEgkZHJyQQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677704384565476.48482526328075; Wed, 1 Mar 2023 12:59:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXTXL-0003rM-J7; Wed, 01 Mar 2023 15:58:55 -0500 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 1pXTXK-0003qx-Ic for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXTXJ-000449-2F for qemu-devel@nongnu.org; Wed, 01 Mar 2023 15:58:54 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-426-4X4nKHZjOxa_icySQsdFzA-1; Wed, 01 Mar 2023 15:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD9DC3811F2C; Wed, 1 Mar 2023 20:58:48 +0000 (UTC) Received: from localhost (unknown [10.39.192.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DB5C2166B26; Wed, 1 Mar 2023 20:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677704332; 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=l7FHaIBM/eBasSIGq1f13k97Nq9uyQeyH+6pJ/nmRAA=; b=IUikfMTIoO1MOVAXcgMBo1JzFqOn3gvndINVq/bjhc84e1pLsXjpgD50SF9NfjmLQfBWy+ bslLWOsJk3PPHV11lBmstl/6GPMyRwqMTDsoGO6Sw2vv5LMSZgfxPHaWUDTv1extvK8JJo iMf8YAx5I4AcE5VWDxWyqoE9F0Z9Dpw= X-MC-Unique: 4X4nKHZjOxa_icySQsdFzA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org, Emanuele Giuseppe Esposito , Markus Armbruster , Kevin Wolf , Stefan Hajnoczi , "Dr. David Alan Gilbert" , Hanna Reitz Subject: [PATCH 6/6] monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED() Date: Wed, 1 Mar 2023 15:58:01 -0500 Message-Id: <20230301205801.2453491-7-stefanha@redhat.com> In-Reply-To: <20230301205801.2453491-1-stefanha@redhat.com> References: <20230301205801.2453491-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677704386323100009 Content-Type: text/plain; charset="utf-8" monitor_cleanup() is called from the main loop thread. Calling AIO_WAIT_WHILE(qemu_get_aio_context(), ...) from the main loop thread is equivalent to AIO_WAIT_WHILE_UNLOCKED(NULL, ...) because neither unlocks the AioContext and the latter's assertion that we're in the main loop succeeds. Signed-off-by: Stefan Hajnoczi Acked-by: Markus Armbruster Reviewed-by: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- monitor/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor/monitor.c b/monitor/monitor.c index 8dc96f6af9..602535696c 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -666,7 +666,7 @@ void monitor_cleanup(void) * We need to poll both qemu_aio_context and iohandler_ctx to make * sure that the dispatcher coroutine keeps making progress and * eventually terminates. qemu_aio_context is automatically - * polled by calling AIO_WAIT_WHILE on it, but we must poll + * polled by calling AIO_WAIT_WHILE_UNLOCKED on it, but we must poll * iohandler_ctx manually. * * Letting the iothread continue while shutting down the dispatcher @@ -679,7 +679,7 @@ void monitor_cleanup(void) aio_co_wake(qmp_dispatcher_co); } =20 - AIO_WAIT_WHILE(qemu_get_aio_context(), + AIO_WAIT_WHILE_UNLOCKED(NULL, (aio_poll(iohandler_get_aio_context(), false), qatomic_mb_read(&qmp_dispatcher_co_busy))); =20 --=20 2.39.2