From nobody Mon Feb 9 02:21:18 2026 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; dkim=fail; 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 1533224106515756.6588133473371; Thu, 2 Aug 2018 08:35:06 -0700 (PDT) Received: from localhost ([::1]:46368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flFd3-0001iR-8m for importer@patchew.org; Thu, 02 Aug 2018 11:35:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flEwz-0004mE-Tb for qemu-devel@nongnu.org; Thu, 02 Aug 2018 10:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1flEww-0001LD-PT for qemu-devel@nongnu.org; Thu, 02 Aug 2018 10:51:37 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:34116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1flEww-00010n-DP; Thu, 02 Aug 2018 10:51:34 -0400 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1flEwJ-0006Do-Hh; Thu, 02 Aug 2018 16:50:55 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1flEw0-0007ah-QP; Thu, 02 Aug 2018 17:50:36 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=WO/i51RAZMMxOOLNyJMB5kIBv1nbCOd9T8MctpjNWGo=; b=kT1rHegxSqno79emN7rI33wK5AdircwLvwdT4OGAxoQQUCrpqh8qZpnRUvc3Iz0Osidq+sKkEjyCXttFWB2ZYbalpYMQZsyt6unLbl26bF+D0N1EgqNlDganOdLP7RbvpPnNIy9sYtxhVQU8BWdPnWK3HVw4IB/yuw38sCCNs1Lrt8G2/7sPPX2787csfR3fvp2n2v+xqI4xXU8/jYptpOaZ8t7db5r/GwDg80z9strV1h0FejsSFYyMrIetddDNrooxf4O248q8eluOdO/yTZ0c+ObUAuxNDagvZW5bFQttqXoa+Lz/RTkyGbVKjTdNy4x0+MpYUbIUbKKEz3m/GQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 2 Aug 2018 17:50:24 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 2/4] throttle-groups: Skip the round-robin if a member is being drained 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: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the throttling code after an I/O request has been completed the next one is selected from a different member using a round-robin algorithm. This ensures that all members get a chance to finish their pending I/O requests. However, if a group member has its I/O limits disabled (because it's being drained) then we should always give it priority in order to have all its pending requests finished as soon as possible. If we don't do this we could have a member in the process of being drained waiting for the throttled requests of other members, for which the I/O limits still apply. This can have additional consequences: if we're running in qtest mode (with QEMU_CLOCK_VIRTUAL) then timers can only fire if we advance the clock manually, so attempting to drain a block device can hang QEMU in the BDRV_POLL_WHILE() loop at the end of bdrv_do_drained_begin(). Signed-off-by: Alberto Garcia --- block/throttle-groups.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index e297b04e17..d46c56b31e 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -221,6 +221,15 @@ static ThrottleGroupMember *next_throttle_token(Thrott= leGroupMember *tgm, ThrottleGroup *tg =3D container_of(ts, ThrottleGroup, ts); ThrottleGroupMember *token, *start; =20 + /* If this member has its I/O limits disabled then it means that + * it's being drained. Skip the round-robin search and return tgm + * immediately if it has pending requests. Otherwise we could be + * forcing it to wait for other member's throttled requests. */ + if (tgm_has_pending_reqs(tgm, is_write) && + atomic_read(&tgm->io_limits_disabled)) { + return tgm; + } + start =3D token =3D tg->tokens[is_write]; =20 /* get next bs round in round robin style */ --=20 2.11.0