From nobody Sat May 4 19:15:10 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=1678389008; cv=none; d=zohomail.com; s=zohoarc; b=ms+30q55wGu/u/pTzTfbk5PCmQRUAcld7KzSbbQdcTPyt3cljq/DByEeLNASIA04euKAAT3JhgIQ8djgZKKl2qA7ljDtryfCBR2CIhEDapvMJr5gvrFlP2venH64aBBcIawbxUzfeE1t4LVFKvFksnRPFViNmD7pYhl1Aqmbmmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389008; 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=SM3fBLQ31B1m+raAafKAtbmhbbEZMPjYFKg7Q8w6CMQ=; b=GLUIgF1u0G9ws1ZSeN7ZgwjlbanQ1/CKGxp/4SvENWMul3Z9ZOlU034lKgnozbYarahw99OG6PmzFn5o2jJ4esDxeh9DCJoXiSqK2ryeYhUXDIAh+/hPOjcMDj5t3RtO4om267jvOd494UPRAQncTLB1YZCSNrzo5KjstH9mzDs= 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 1678389008752651.2731911798597; Thu, 9 Mar 2023 11:10:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdY-0006Or-3Q; Thu, 09 Mar 2023 14:09:12 -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 1paLdT-0006NK-LW for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:08 -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 1paLdR-00085f-14 for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:07 -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-489-y1wqKnvUPw2TFrtv46F0VA-1; Thu, 09 Mar 2023 14:09:01 -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 6A5E4803503; Thu, 9 Mar 2023 19:09:01 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5402166B26; Thu, 9 Mar 2023 19:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388943; 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=SM3fBLQ31B1m+raAafKAtbmhbbEZMPjYFKg7Q8w6CMQ=; b=aglJe/ojDB0dBavADE5rTmoaFd/I5FVCVGA6U945AajupF5YlEOcZNpqtVMwDZu+jwIP8E jcQXjTFQi10QjJDq9Li9EtlZG+msRkH3w2h/RIMK4C/WfymW5tvSFzlMhiKiycYVgPCdwY 4qDZQ0hq7EsiqVTYrFpmhTPW8CK08fA= X-MC-Unique: y1wqKnvUPw2TFrtv46F0VA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 1/6] block: don't acquire AioContext lock in bdrv_drain_all() Date: Thu, 9 Mar 2023 14:08:50 -0500 Message-Id: <20230309190855.414275-2-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-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=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: 1678389009333100013 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. AIO_WAIT_WHILE_UNLOCKED() has no use for the AioContext parameter other than performing a check that is nowadays already done by the GLOBAL_STATE_CODE()/IO_CODE() macros. Set the ctx argument to NULL here to help us keep track of all converted callers. Eventually all callers will have been converted and then the argument can be dropped entirely. Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- 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 Sat May 4 19:15:10 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=1678389005; cv=none; d=zohomail.com; s=zohoarc; b=Qte08KgjjZBUaZNZ+81X6e89HV4YvSJGOnD08lA7u+DGs7mLrRxU+kkILfyevDyB65TY81g6Hhqi/unUTgFBfWDzn2MLIRHKqFG9oT16B3SToc3A/hYpgQnU2doHXen6+jqtfrmHFf3mSXbPzNXCFOuRF+JLh/yYnPrnzWPnc9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389005; h=Content-Type: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=YRz2ho3GoiZHqPdih1je6yxbEF0XZq8WnR3mqtQr/SE=; b=gcwg0YtTbDSTtFq+4CcXo5iBSBtUVEkS9R2SC5Z8VylsiK8vQIbdaMwqKFT+hYb2aKTrmfe0aG7c27SqJcqjmsS8fZoTuhCx9CgaTtNiS8OUCeRZ5PVFNmwjxb6KqVGa3XlG3qrbsmL+E2pMt4V7X4Jq9W30hx+FMWq4JR0BE/Q= 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 1678389005278235.93509327634592; Thu, 9 Mar 2023 11:10:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdb-0006QW-6C; Thu, 09 Mar 2023 14:09:16 -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 1paLdX-0006Ol-AY for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:11 -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 1paLdV-0008AK-7r for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:11 -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-246-KM3dsksPMauOJvSoJiLexQ-1; Thu, 09 Mar 2023 14:09:04 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2CD01C08974; Thu, 9 Mar 2023 19:09:03 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58AF1492C3E; Thu, 9 Mar 2023 19:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YRz2ho3GoiZHqPdih1je6yxbEF0XZq8WnR3mqtQr/SE=; b=ab46eIwkc7Tjtd/M3/WplVuRwcV/hFiaXeZ137aVm7+oQdOV7g4dazUZbJ93F0pO4yO+56 oLR3wgI98jsAs0H1HFqQRhh7pjLwnDWmXtZN96/T1r0RoMe0kCxXgnk+hvU/n9OokDuqMz y8cC0FPenY2PVaCPzVmGZNIAAEKlEEs= X-MC-Unique: KM3dsksPMauOJvSoJiLexQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 2/6] block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED() Date: Thu, 9 Mar 2023 14:08:51 -0500 Message-Id: <20230309190855.414275-3-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1678389007474100004 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. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- 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 Sat May 4 19:15:10 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=1678389021; cv=none; d=zohomail.com; s=zohoarc; b=OI1Thwo22s/LQa4F+xTI60NDWoZ0sMEPGqxDaKEWHYoTx1IXBnB64yQD6J3CCv6AI9WRu3rql6KKV83TbDwA5aEQmFIO4/xLEG5IFSQjdEEbR7N4pF+L+1zM9ifm2kih/+xv+JmTZD2oXdLFXXFkqOZZpjrIzFvOfIMreQf0GZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389021; h=Content-Type: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=aWG+IEviwS8T1zoXJw48V6vODCcaqCTgHGF8TS9PKNQ=; b=DVAf9dTUoXQsffnKGkmmOv2mKQ9aD1bMWbhRvCU1R+Npo4ObuWM/h6yjEx2ezpSX60m4xzg7dI8K6jBtU6hD8lJuEFMUJg9j7JxEED6789aha5F+kxh8ZV1Eo8AxUvOjpi1FmZnYvA6yw8Xh7V1b3uWrkoCUj6HhOoLJWnhU2fY= 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 1678389021755986.4727960994367; Thu, 9 Mar 2023 11:10:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdg-0006Tx-Gw; Thu, 09 Mar 2023 14:09:20 -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 1paLdX-0006Om-Bj for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:11 -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 1paLdV-0008B6-ME for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:11 -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-361--KM0tmpfNy6bNStpOlhy8Q-1; Thu, 09 Mar 2023 14:09:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 867C63823A0C; Thu, 9 Mar 2023 19:09:06 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id E16B7440DD; Thu, 9 Mar 2023 19:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aWG+IEviwS8T1zoXJw48V6vODCcaqCTgHGF8TS9PKNQ=; b=FZNBP9VtjjqB23GRNPZ4pxKlc0/Ju1hu8vkjyguesWIBLbNeOuqrExQxHjVTt84yrgLTm/ Mf88Z0urwrM1V0SHn7aMpccRduAWyQ68Cb47e7onhCcG1PnO5gOinWn6ka+YD3gx9/r81Y 2bkxv5iQ7T2tM8cE4m+sWKLdkxfDF5o= X-MC-Unique: -KM0tmpfNy6bNStpOlhy8Q-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED() Date: Thu, 9 Mar 2023 14:08:52 -0500 Message-Id: <20230309190855.414275-4-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1678389023521100003 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. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- 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 Sat May 4 19:15:10 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=1678389037; cv=none; d=zohomail.com; s=zohoarc; b=DhS5UckTa2bpw3ZUaoAVI3Vbk28zsWE/fPknYG0FVK2jkFZ+jgADvJjK2o/h2SYk1KYbU0ufG4NXrEFI12wKGx8jIfhToy0dJYnSwtS/wBNAPBPzSRcLort8WI1x72z4Fj1VG88DYxtzZAkYq/vr9I1jkWGcKzuSX9pobQe9w9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389037; h=Content-Type: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=SqmL374Fa1lQorwL8IePiy932AwklGFfW818mJX5WFA=; b=by+K1dbLYqHgGdLJI5Tc50MxqsYmcPX1CtgXWIEKOWoaHVc9WCwLLke22xY1BYE9kwpC3LyuMMU3Rr8glOjOb0QhHJ528O1BUCEdgN/0zfeb16VqM8JpoFrQKoDDX/8dIfeRarlXSXs+0SUcCpZ45xmYh/GsKzLoquF3Mvdn3PU= 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 1678389037174310.0322259665643; Thu, 9 Mar 2023 11:10:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdi-0006Ub-EI; Thu, 09 Mar 2023 14:09:22 -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 1paLdb-0006RA-9i for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:16 -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 1paLdZ-0008Bo-Qm for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:15 -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-207-TsmkxZ3JO26f2FxqnLWF_w-1; Thu, 09 Mar 2023 14:09:09 -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 35EF2857A87; Thu, 9 Mar 2023 19:09:09 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D44F4010E36; Thu, 9 Mar 2023 19:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SqmL374Fa1lQorwL8IePiy932AwklGFfW818mJX5WFA=; b=Awjz4ins91DYNJFl7RwFV5D9Qaiu4sn+RMmETBn4Hd5m8LTuFCboDxFr+xtRLLt0c4gHz5 ayHwIXqhTOhlxE8Yrg87h3z1Hho5cFL/UruY9qwkMWRFTzo+Q9aAfSkQvYwj47NuiOYAzD Y9esyJ7E23z2r2Hv8ICBl0AyRu6o+PI= X-MC-Unique: TsmkxZ3JO26f2FxqnLWF_w-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 4/6] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED() Date: Thu, 9 Mar 2023 14:08:53 -0500 Message-Id: <20230309190855.414275-5-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1678389037573100001 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(). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- 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 Sat May 4 19:15:10 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=1678389058; cv=none; d=zohomail.com; s=zohoarc; b=QYRwM3OS5xuCwe40tzFN2PLvWELlnZeWom3hY5V8qIMjnh+GweJOAdtyA18OGfT9974sqOlTHtMyG4BI8AuPlarIYg7xq81o8DE514jNWVKTcY5sDrrFeadvwF9ylkjY8zehypMjM2e3AlXrfk7RTPWSQr2HsBPAwaUuilD8C/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389058; h=Content-Type: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=pPXTcEmV1//FepBqzFpa0YUz04ZS6QZIg2Dui2Jww/o=; b=etPDuUsEdbbdURHEKtccir7jYstVMg9RE5p6oQBlPZx/SjCpgvgzxxYtsBqamLXcGL/C0qEo+hKhGykQzo10AiehE+MR6mFUxFPPjVSL79IJRKSpQsrXsaM+OzzoixJ+OCv1lT+kCdopTemPQMKW5ft3Zy6cZaD1zaN/OjZBHsw= 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 1678389058078880.1920090554514; Thu, 9 Mar 2023 11:10:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdj-0006V8-7j; Thu, 09 Mar 2023 14:09:23 -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 1paLde-0006TT-O4 for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:20 -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 1paLdd-0008Dk-BL for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:18 -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-111-kMsFeMjAPE-WyFw5OccYaQ-1; Thu, 09 Mar 2023 14:09:12 -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 1246F101AA63; Thu, 9 Mar 2023 19:09:12 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DA272166B2A; Thu, 9 Mar 2023 19:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPXTcEmV1//FepBqzFpa0YUz04ZS6QZIg2Dui2Jww/o=; b=fAh0sKOjbr8on2Y/c2YygwYpNN536AgwLupTBTCerx6NqYpTaAH7WbnYNu2cld7DIJhJOj T6rcJg5PO+rnmzk7tB9mMPHd87364ZdIhOTYw1ySvnNqRsTRMpqTM4luXUMGBxKNx/vB5e 8oIBpT2XWO6RMkqctcenT0seceWYhwM= X-MC-Unique: kMsFeMjAPE-WyFw5OccYaQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 5/6] hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED() Date: Thu, 9 Mar 2023 14:08:54 -0500 Message-Id: <20230309190855.414275-6-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1678389059645100003 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. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- monitor/hmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index fee410362f..5cab56d355 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 Sat May 4 19:15:10 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=1678389005; cv=none; d=zohomail.com; s=zohoarc; b=ZVJxodKmqdc5FfvqfHTt20EYaPd6JBEXnT7s17m5eFbeGvCF9U0mECZ7tpRCaci23erRq4rV640mb1X0dP57fEKrpU28f53VFw97bzxFAhvxnHncUpWHhZK5jD6JaHVol4WpwQxnGZzLyCK38TTAgP5xRaidRuuIopphytVcgEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678389005; h=Content-Type: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=jMtoshAqlniuyeVys7v9v29yYD+MW5M0XRYHSKyek8g=; b=YI0MlZkN3tpZQZ9KjfDiO8lQVnBva93h5UERy+efaMf/T2SZC6YNotme0njhelB9Y+9f4NNO8MdGNqKxWvlH7TgfLKwKQdb/9NRULrgBdIDEO+ziKg56EP5w1wMWJCoqai5IhJ9bUki8JVimVN8MqwBlGa+FN7Auas6pbC2hckc= 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 1678389005167584.8149585501035; Thu, 9 Mar 2023 11:10:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paLdk-0006Vk-14; Thu, 09 Mar 2023 14:09:24 -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 1paLdh-0006U2-M8 for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:22 -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 1paLdg-0008E1-96 for qemu-devel@nongnu.org; Thu, 09 Mar 2023 14:09:21 -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-obUvb5hGNzG7sQmz90mGyg-1; Thu, 09 Mar 2023 14:09:14 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50FDF85A5B1; Thu, 9 Mar 2023 19:09:14 +0000 (UTC) Received: from localhost (unknown [10.39.192.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C5F492B00; Thu, 9 Mar 2023 19:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678388958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jMtoshAqlniuyeVys7v9v29yYD+MW5M0XRYHSKyek8g=; b=GDcsdPI6R8e2rut/9dvzKlgUu0P9y0pZcoRZkIQ7Z/TRduaKI7VgYvvTNnIh+e+hEhk8tq L6Zt3nwtZtZ1DSOvUxRDxbCXuyS44ty+Uk9LnsSSAwEgDmCa4NdP4fAAo+tHFXGi2hbmyO 9+5lUQ76xJdqOPspq2YfldQGomLxfkg= X-MC-Unique: obUvb5hGNzG7sQmz90mGyg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , Kevin Wolf , armbru@redhat.com, "Dr. David Alan Gilbert" , Hanna Reitz , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi Subject: [PATCH v2 6/6] monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED() Date: Thu, 9 Mar 2023 14:08:55 -0500 Message-Id: <20230309190855.414275-7-stefanha@redhat.com> In-Reply-To: <20230309190855.414275-1-stefanha@redhat.com> References: <20230309190855.414275-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1678389007450100003 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. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Wilfred Mallawa --- 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