From patchwork Mon Nov 13 06:34:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 118716 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1445302qgn; Sun, 12 Nov 2017 22:35:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMYRtFoxt2Cx5m9dTfpep2qgG4SMOgjPmAjHd7h9dfxDorAEkmjRCMV4pehGY3AP25L3ckZ4 X-Received: by 10.159.218.9 with SMTP id v9mr7713001plp.92.1510554914444; Sun, 12 Nov 2017 22:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510554914; cv=none; d=google.com; s=arc-20160816; b=bgW7pmElDvMhXzJMG0pwyyPg6CdrEdeUgEEFriwbe7mfpUflVmlxXNPLiGxZ9oLiGo KGlqtOCKvIASXNSkZfcWQnuurjlQfl9Q0tmignlmK65EDnt7tjzMxOxwtxqQv8Qgkd1W 7qzT+Wm2KU9693ToW08YIiI08TYSeRB7Ct4Uizqq+HvVAjIW4+bT2sf/vLBo/BAcCGCx 041ua+JJLqYPWjmCEogWzMP2bPIezgIrMnzr15zWNUsnWcA6pOly30/5mntUgcr1J12S b7bb28iliRlipWHOK1Fg9AU5UH9rNUtPguEdbbNBM/vutu+cbS811xQaM4olpJfhrMpZ gFdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=qotsggCjIz8ohM2ZdCNsRBOSXkJox9H2y62UQxw4YLg=; b=ogZuMDdqJ6pdKHkk8Whry4UWvfcYgxLmA+Arm/pFECNYgxoxVXQiv15lnZvcDEnn4O vUcEHCafaZGZDbeiMnKpftdWrgrGGslBRFJzZp4Q8xULSuxddH6TBYEZ8pBbVl2B9G2I rVbXZg3eU4AAtBNhUc5iWsXB9MQIfsJdVh0Rms0UvzTVtsOebUk0/tHBgzV8rY3Y1UWO XTkVppymTOZR99kw7pMZQEkAItQYpjTKGX8055rzcdwDC1xuujW7SO+ZQ7itdtMU+lRw YP6I/IoLqSnWGob99RPNaQBojsLkIh8yadESVWg/nnFu8jFQIaauApW74QReMeUUmVhx O4fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kT70Py42; 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 h185si13031390pgc.164.2017.11.12.22.35.14; Sun, 12 Nov 2017 22:35:14 -0800 (PST) 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=kT70Py42; 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 S1752045AbdKMGfM (ORCPT + 27 others); Mon, 13 Nov 2017 01:35:12 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:43748 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809AbdKMGee (ORCPT ); Mon, 13 Nov 2017 01:34:34 -0500 Received: by mail-wr0-f193.google.com with SMTP id 4so13452846wrt.0 for ; Sun, 12 Nov 2017 22:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qotsggCjIz8ohM2ZdCNsRBOSXkJox9H2y62UQxw4YLg=; b=kT70Py42QThSiU8L09cTbbnv4PUCtGrrj+n7nllEHwcGjeWKeCdx8Dj7y4VfjmIvB7 pKB6ZewAGZh/o5ASjEMgSiihiIbAOgLc0MeSZjGpY8QhEuPw4TxQyxmY+fO1VGrJsv3E 4sAkvVeD5IDUg88iVZBTHoLbwB2QyZAScLo+8= 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:in-reply-to :references; bh=qotsggCjIz8ohM2ZdCNsRBOSXkJox9H2y62UQxw4YLg=; b=UPShQpRG/4e3P6nrvZhFBDG04yYQdIfroUjqCyXzMEkz8zQge5DXqbJnb5JKCDGppX 1ybIW8vno5E3Dmb3xS4NBMOMZ6R0KG9N5bemAU/8dJxk82sVv93j4xuiA770Z1bgrYQO hq7lzythnLNGGDqX2LmwtFIilp2EA7uuxP4IslF4dudrudrL2ZMqc+ZFOJ/EYXFslNyq kNc0g6UV7ZbuYa2trKZLe1qTKb5PidIw1DXWcNF05UQTHTnrZm7UpdSVQnFd0W2pkl25 NH52wgXBB3F/m1Zeylor3eEGSo31nI/IY/HVbInJIyFD2MuJkMuC6GN94oixY9h5KD/M emvQ== X-Gm-Message-State: AJaThX73kGtIujF7gd+vxw6mkLyVfS+N+vzouutJC71jMed69D/H7uM3 SLHoHijxf9Dur40yN2iOhg5YUg== X-Received: by 10.223.128.3 with SMTP id 3mr5765617wrk.196.1510554872703; Sun, 12 Nov 2017 22:34:32 -0800 (PST) Received: from localhost.localdomain ([5.169.167.83]) by smtp.gmail.com with ESMTPSA id 10sm11158429wml.27.2017.11.12.22.34.30 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 12 Nov 2017 22:34:31 -0800 (PST) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, lee.tibbert@gmail.com, oleksandr@natalenko.name, lucmiccio@gmail.com, bfq-iosched@googlegroups.com, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 2/4] block, bfq: add missing invocations of bfqg_stats_update_io_add/remove Date: Mon, 13 Nov 2017 07:34:08 +0100 Message-Id: <20171113063410.3029-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20171113063410.3029-1-paolo.valente@linaro.org> References: <20171113063410.3029-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luca Miccio bfqg_stats_update_io_add and bfqg_stats_update_io_remove are to be invoked, respectively, when an I/O request enters and when an I/O request exits the scheduler. Unfortunately, bfq does not fully comply with this scheme, because it does not invoke these functions for requests that are inserted into or extracted from its priority dispatch list. This commit fixes this mistake. Tested-by: Lee Tibbert Tested-by: Oleksandr Natalenko Signed-off-by: Paolo Valente Signed-off-by: Luca Miccio --- block/bfq-iosched.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) -- 2.10.0 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 889a854..91703eb 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1359,7 +1359,6 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, bfqq->ttime.last_end_request + bfqd->bfq_slice_idle * 3; - bfqg_stats_update_io_add(bfqq_group(RQ_BFQQ(rq)), bfqq, rq->cmd_flags); /* * bfqq deserves to be weight-raised if: @@ -1633,7 +1632,6 @@ static void bfq_remove_request(struct request_queue *q, if (rq->cmd_flags & REQ_META) bfqq->meta_pending--; - bfqg_stats_update_io_remove(bfqq_group(bfqq), rq->cmd_flags); } static bool bfq_bio_merge(struct blk_mq_hw_ctx *hctx, struct bio *bio) @@ -1746,6 +1744,7 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq, bfqq->next_rq = rq; bfq_remove_request(q, next); + bfqg_stats_update_io_remove(bfqq_group(bfqq), next->cmd_flags); spin_unlock_irq(&bfqq->bfqd->lock); end: @@ -3700,6 +3699,9 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) spin_lock_irq(&bfqd->lock); rq = __bfq_dispatch_request(hctx); + if (rq && RQ_BFQQ(rq)) + bfqg_stats_update_io_remove(bfqq_group(RQ_BFQQ(rq)), + rq->cmd_flags); spin_unlock_irq(&bfqd->lock); return rq; @@ -4224,6 +4226,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, { struct request_queue *q = hctx->queue; struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_queue *bfqq = RQ_BFQQ(rq); spin_lock_irq(&bfqd->lock); if (blk_mq_sched_try_insert_merge(q, rq)) { @@ -4243,6 +4246,12 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, list_add_tail(&rq->queuelist, &bfqd->dispatch); } else { __bfq_insert_request(bfqd, rq); + /* + * Update bfqq, because, if a queue merge has occurred + * in __bfq_insert_request, then rq has been + * redirected into a new queue. + */ + bfqq = RQ_BFQQ(rq); if (rq_mergeable(rq)) { elv_rqhash_add(q, rq); @@ -4251,6 +4260,9 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, } } + if (bfqq) + bfqg_stats_update_io_add(bfqq_group(bfqq), bfqq, rq->cmd_flags); + spin_unlock_irq(&bfqd->lock); } @@ -4428,8 +4440,11 @@ static void bfq_finish_request(struct request *rq) * lock is held. */ - if (!RB_EMPTY_NODE(&rq->rb_node)) + if (!RB_EMPTY_NODE(&rq->rb_node)) { bfq_remove_request(rq->q, rq); + bfqg_stats_update_io_remove(bfqq_group(bfqq), + rq->cmd_flags); + } bfq_put_rq_priv_body(bfqq); }