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: 149501 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp276792ljp; Wed, 24 Oct 2018 10:13:47 -0700 (PDT) X-Google-Smtp-Source: AJdET5dQeih2bk6vDY7xUikdEpfMxlQ06z+5Zulcpnq3iBqz62KI/2b21pp7F0kKPr40go/LYFLD X-Received: by 2002:a62:3301:: with SMTP id z1-v6mr3391274pfz.85.1540401227110; Wed, 24 Oct 2018 10:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540401227; cv=none; d=google.com; s=arc-20160816; b=MCQINF5bPyWaQoqGm1JKF2dIyFIpYAt+0YcqZLpk18eNU5ttsuX3PA1jJoqidnh/9e ZyTI5jHwLHSuppZRwdhUR1fm5LpUco7vHkbHsV0ViHpKTBd5p0KDgmHMHKJ7M6StsG3e UprT+hLzWwURvRBZSfPo5VWYlGRdJFIGstgVcDmSs4flGA95iYrnSsDsggcNq4cs8w0S lJi1qiXIfqffLpgQZh35//nk+R+9XREoCL4a9FLqc1XcLxn5M8DiLOhlL5HdD8Lxj6mJ x80uO86sV9aQICgfdai5B/43xwMa9MPnz6H8rYj5SRMJ85Dfc7oWhzt64Sqqetq53bQ9 5viw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=a61AxcMEEoOMby5wnEQKj4zTJW6/YYCLTZm/LR69Eak=; b=npeHOkSY/BaF9YzpfLppYKL8e0xopT+DT+swAvDaOBllHExQCegXbHG59WbUdPHfqN 3c0rAMWbYXTp4NcNFYesF9kNNgFczS0wN1+QqXtOo6tH9KVrXcRWGbGUV1zmS442F2FM nh5Q70yZtD8cG41VqlgjXmVtJWjig7y0ZC+97XmHbws82VXMxr34xx6Q6Cev/+zrwXkx bmNaGBVSPgJFPV9FV2f36Ltp0wRX/7vuz3cCCfMmPzH9ePrBrjMBDhD6DdXjbia6pSB1 ZN3Qe8pQJR2BFAEWrV3aOqrQnenJVIPajrZ2jLyvR0mf4e3LxdBcTdyL207iAASGFFar IVIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccR8E2Ca; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12-v6si4948926plt.115.2018.10.24.10.13.45; Wed, 24 Oct 2018 10:13:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccR8E2Ca; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbeJYBmf (ORCPT + 32 others); Wed, 24 Oct 2018 21:42:35 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36238 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbeJYBmf (ORCPT ); Wed, 24 Oct 2018 21:42:35 -0400 Received: by mail-wm1-f66.google.com with SMTP id a8-v6so6198810wmf.1 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=CIf03086P/HKlwdwu+uAFE0A6mJr2r4wakSo7Qyc79dhm8JIeZOh7+okTsY8SOCH/F TzV5mMEN+n9ZF3DY+A/wE0MH1TGgXVbZMJxEZWr24+rl78FV827QBSWVFHM3aua7xL65 BEFmiujyNqcNqduqZY0217kpM5jJOVhOdU/OwE9TLjD+DCotiNojEpk1IqBZjKghP2fV IQGH6LG1/KMN9cj7QD1iRmeDlbBeKn6cIEit5UcwAtcBw2g/CDtvpYJdIiMn0KWkN5Aa h8MS9fwIoC3np2yL+Ple1SPqcUI8icREMKiqCGuSpnhbAcfsVIQjCJUYLR/T5eH1AWn1 EqsQ== X-Gm-Message-State: AGRZ1gI+HbxgEkFV/ioFtl6GcPoAIdBTlnFxQtFw7DEC3CSx6n4+sC7f 8kZyUBq/RGP5gX0dG0vZOPRb/w== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- block/bfq-wf2q.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.19.1 Tested-by: Oleksandr Natalenko 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;