From nobody Wed Nov 5 16:42:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149692342952451.746231527757914; Thu, 8 Jun 2017 05:03:49 -0700 (PDT) Received: from localhost ([::1]:48848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIwAD-0008En-4T for importer@patchew.org; Thu, 08 Jun 2017 08:03:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIw3j-0001f3-US for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIw3g-0001sD-TA for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39498) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIw3g-0001rM-NL for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5726DC90D; Thu, 8 Jun 2017 11:56:59 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-24.pek2.redhat.com [10.72.12.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6600817DC9; Thu, 8 Jun 2017 11:56:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5726DC90D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A5726DC90D From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 8 Jun 2017 19:56:27 +0800 Message-Id: <20170608115643.18859-8-famz@redhat.com> In-Reply-To: <20170608115643.18859-1-famz@redhat.com> References: <20170608115643.18859-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 08 Jun 2017 11:56:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 07/23] block: access io_limits_disabled with atomic ops 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Signed-off-by: Paolo Bonzini Message-Id: <20170605123908.18777-4-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- block/block-backend.c | 4 ++-- block/throttle-groups.c | 2 +- include/sysemu/block-backend.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index f3a6008..e50ec03 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1953,7 +1953,7 @@ static void blk_root_drained_begin(BdrvChild *child) /* Note that blk->root may not be accessible here yet if we are just * attaching to a BlockDriverState that is drained. Use child instead.= */ =20 - if (blk->public.io_limits_disabled++ =3D=3D 0) { + if (atomic_fetch_inc(&blk->public.io_limits_disabled) =3D=3D 0) { throttle_group_restart_blk(blk); } } @@ -1964,7 +1964,7 @@ static void blk_root_drained_end(BdrvChild *child) assert(blk->quiesce_counter); =20 assert(blk->public.io_limits_disabled); - --blk->public.io_limits_disabled; + atomic_dec(&blk->public.io_limits_disabled); =20 if (--blk->quiesce_counter =3D=3D 0) { if (blk->dev_ops && blk->dev_ops->drained_end) { diff --git a/block/throttle-groups.c b/block/throttle-groups.c index b73e7a8..69bfbd4 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -240,7 +240,7 @@ static bool throttle_group_schedule_timer(BlockBackend = *blk, bool is_write) ThrottleGroup *tg =3D container_of(ts, ThrottleGroup, ts); bool must_wait; =20 - if (blkp->io_limits_disabled) { + if (atomic_read(&blkp->io_limits_disabled)) { return false; } =20 diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 840ad61..24b63d6 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -80,7 +80,8 @@ typedef struct BlockBackendPublic { CoQueue throttled_reqs[2]; =20 /* Nonzero if the I/O limits are currently being ignored; generally - * it is zero. */ + * it is zero. Accessed with atomic operations. + */ unsigned int io_limits_disabled; =20 /* The following fields are protected by the ThrottleGroup lock. --=20 2.9.4