From patchwork Thu Aug 2 14:50:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10553921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1FFD13B4 for ; Thu, 2 Aug 2018 15:34:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E329328F77 for ; Thu, 2 Aug 2018 15:34:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15A62BBEC; Thu, 2 Aug 2018 15:34:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 89F0A28F77 for ; Thu, 2 Aug 2018 15:34:31 +0000 (UTC) Received: from localhost ([::1]:46368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flFcU-0001iR-Kh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Aug 2018 11:34:30 -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 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==; 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(ThrottleGroupMember *tgm, ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); ThrottleGroupMember *token, *start; + /* 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 = token = tg->tokens[is_write]; /* get next bs round in round robin style */