From nobody Wed Nov 5 19:59:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536843489513296.6842231199207; Thu, 13 Sep 2018 05:58:09 -0700 (PDT) Received: from localhost ([::1]:42293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0RCC-00069x-FA for importer@patchew.org; Thu, 13 Sep 2018 08:58:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0R73-00027p-Gj for qemu-devel@nongnu.org; Thu, 13 Sep 2018 08:52:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0R6y-0001eA-Cm for qemu-devel@nongnu.org; Thu, 13 Sep 2018 08:52:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0R6t-0001Zj-D5; Thu, 13 Sep 2018 08:52:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA68F3082E64; Thu, 13 Sep 2018 12:52:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-67.ams2.redhat.com [10.36.117.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFA4460BE0; Thu, 13 Sep 2018 12:52:36 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 13 Sep 2018 14:52:03 +0200 Message-Id: <20180913125217.23173-4-kwolf@redhat.com> In-Reply-To: <20180913125217.23173-1-kwolf@redhat.com> References: <20180913125217.23173-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 13 Sep 2018 12:52:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/17] aio-wait: Increase num_waiters even in home thread 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: kwolf@redhat.com, famz@redhat.com, slp@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Even if AIO_WAIT_WHILE() is called in the home context of the AioContext, we still want to allow the condition to change depending on other threads as long as they kick the AioWait. Specfically block jobs can be running in an I/O thread and should then be able to kick a drain in the main loop context. Signed-off-by: Kevin Wolf Reviewed-by: Fam Zheng --- include/block/aio-wait.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h index c85a62f798..46ba7f9111 100644 --- a/include/block/aio-wait.h +++ b/include/block/aio-wait.h @@ -77,10 +77,12 @@ typedef struct { AioWait *wait_ =3D (wait); \ AioContext *ctx_ =3D (ctx); \ if (ctx_ && in_aio_context_home_thread(ctx_)) { \ + atomic_inc(&wait_->num_waiters); \ while ((cond)) { \ aio_poll(ctx_, true); \ waited_ =3D true; \ } \ + atomic_dec(&wait_->num_waiters); \ } else { \ assert(qemu_get_current_aio_context() =3D=3D \ qemu_get_aio_context()); \ --=20 2.13.6