From patchwork Wed Oct 24 17:13:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10654815 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 5A68A14BB for ; Wed, 24 Oct 2018 17:13:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4881D2AF4A for ; Wed, 24 Oct 2018 17:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BC6E2AF55; Wed, 24 Oct 2018 17:13:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 291462ADEA for ; Wed, 24 Oct 2018 17:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbeJYBmg (ORCPT ); Wed, 24 Oct 2018 21:42:36 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56044 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbeJYBmf (ORCPT ); Wed, 24 Oct 2018 21:42:35 -0400 Received: by mail-wm1-f65.google.com with SMTP id s10-v6so4137648wmc.5 for ; Wed, 24 Oct 2018 10:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=a61AxcMEEoOMby5wnEQKj4zTJW6/YYCLTZm/LR69Eak=; b=ccR8E2CaWIxow2gsguoihgieQq3o5wiDx3hFraj6Bc2Wt+UeoEzieHKCoPiJaZhDxx PnoJF/ZfveXvtnp/nYMbUsJ6dwmw1P4UHH1u9W2j62A0DaNdgXEt0KszX/lsIHMgdrit zTSnRM+WvD9fXKr176H5+ekicoCZkZAfTgm1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=a61AxcMEEoOMby5wnEQKj4zTJW6/YYCLTZm/LR69Eak=; b=hW+G+Sdw485VF9dlgbG5NdksCmd9NlnvOs35hOGDUTrwNZT8jH14XU/5LtgcCvA3q6 GHj3on/YBkvXpZooi+im8z3RPWQw4kX7Lq2cDv698A4LTlfzJF0sNFHMj0ny+uMFMtAn 50VksLfgzpdxcfTL4L81oVlwXKIcplRMUOFThdDQtTaaA35zzLtkuqtZOb4ND0GD7GDQ zyVCa+qlRC6LOh1UN1/tuuvZ5Y16iZ3ZEbwStovRQuHbIZv/fwtKWCXck9CugkOQXRXe Xz6Ohr4l/+DUDPGoHTLbMtR2mNlF6t4AP8wQiufpNDcG+fqeVUnZstIcM6B3JEqqc5z6 yaKQ== X-Gm-Message-State: AGRZ1gKIRYplOWxxSy4unPkPU1yK1NuN9EiFqwS4o2i8SrRS27/IjMe+ DvqitVninLRHIaYIRG1kcUOpPg== X-Google-Smtp-Source: AJdET5dPN19u9l5CCBA5r/4WxzLox0LT77bCcfq4cmEJuA4HoP9F5jQoA04TWzR4tG5wywRE1Mtqdw== X-Received: by 2002:a1c:6c09:: with SMTP id h9-v6mr3454230wmc.95.1540401221962; Wed, 24 Oct 2018 10:13:41 -0700 (PDT) Received: from localhost.localdomain ([2.43.217.248]) by smtp.gmail.com with ESMTPSA id 64-v6sm6449041wrr.64.2018.10.24.10.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 10:13:40 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Federico Motta , Paolo Valente Subject: [PATCH BUGFIX] block, bfq: fix asymmetric scenarios detection Date: Wed, 24 Oct 2018 19:13:25 +0200 Message-Id: <20181024171325.7154-1-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Federico Motta Since commit 2d29c9f89fcd ("block, bfq: improve asymmetric scenarios detection"), a scenario is defined asymmetric when one of the following conditions holds: - active bfq_queues have different weights - one or more group of entities (bfq_queue or other groups of entities) are active bfq grants fairness and low latency also in such asymmetric scenarios, by plugging the dispatching of I/O if the bfq_queue in service happens to be temporarily idle. This plugging may lower throughput, so it is important to do it only when strictly needed. By mystake, in commit '2d29c9f89fcd' ("block, bfq: improve asymmetric scenarios detection") the num_active_groups counter was firstly incremented and subsequently decremented at any entity (group or bfq_queue) weight change. This is useless, because only transitions from active to inactive and vice versa matter for that counter. Unfortunately this is also incorrect in the following case: the entity at issue is a bfq_queue and it is under weight raising. In fact in this case there is a spurious increment of the num_active_groups counter. This spurious increment may cause scenarios to be wrongly detected as asymmetric, thus causing useless plugging and loss of throughput. This commit fixes this issue by simply removing the above useless and wrong increments and decrements. Fixes: 2d29c9f89fcd ("block, bfq: improve asymmetric scenarios detection") Signed-off-by: Federico Motta Signed-off-by: Paolo Valente Tested-by: Oleksandr Natalenko --- block/bfq-wf2q.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 476b5a90a5a4..4b0d5fb69160 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -792,24 +792,18 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, * queue, remove the entity from its old weight counter (if * there is a counter associated with the entity). */ - if (prev_weight != new_weight) { - if (bfqq) { - root = &bfqd->queue_weights_tree; - __bfq_weights_tree_remove(bfqd, bfqq, root); - } else - bfqd->num_active_groups--; + if (prev_weight != new_weight && bfqq) { + root = &bfqd->queue_weights_tree; + __bfq_weights_tree_remove(bfqd, bfqq, root); } entity->weight = new_weight; /* * Add the entity, if it is not a weight-raised queue, * to the counter associated with its new weight. */ - if (prev_weight != new_weight) { - if (bfqq && bfqq->wr_coeff == 1) { - /* If we get here, root has been initialized. */ - bfq_weights_tree_add(bfqd, bfqq, root); - } else - bfqd->num_active_groups++; + if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) { + /* If we get here, root has been initialized. */ + bfq_weights_tree_add(bfqd, bfqq, root); } new_st->wsum += entity->weight;