From patchwork Thu Apr 26 07:21:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10364821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A905760225 for ; Thu, 26 Apr 2018 07:22:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 929B82905F for ; Thu, 26 Apr 2018 07:22:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86B8229069; Thu, 26 Apr 2018 07:22:11 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, 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 166BD2905F for ; Thu, 26 Apr 2018 07:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753554AbeDZHWK (ORCPT ); Thu, 26 Apr 2018 03:22:10 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:53992 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbeDZHWJ (ORCPT ); Thu, 26 Apr 2018 03:22:09 -0400 Received: by mail-it0-f67.google.com with SMTP id m134-v6so23210350itb.3 for ; Thu, 26 Apr 2018 00:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=9lOyqPu/kIJdTuGwzobGK8KusmTi+ubXKNJ5a9685DY=; b=B/JHQ1P5UlFvKImXHGDINYPET7q6LrBNgNAFFo26QLFAebqyBxRIxu9EBOEvhCGhCK UxVeHK0r/J5rR2QWIc0Cp0FoPYNg6l1ZSBsgDDTosGi0LtmsJG6Z1UjKQNKTCTl8lsxH 4CkyQpi+zZ9QjaVsZ5BzmJwgsH9sBi+fQI9l8B6Rbl3Z4btau+px+aSpuavY5fMp1mrH gMMY0xuwsYbDJgK5idLbdcFhxm5yR8cbdWuvJxE7IPBlOLOCwSI9brrzdJwzkhLd8KRS zC+qMkOiIuq+gAGheOeET9+nfW2wl73DX2GMZHR39z2j/C9qtbVRvZoXfr6Hja2Ge+m3 REHw== 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:in-reply-to:references; bh=9lOyqPu/kIJdTuGwzobGK8KusmTi+ubXKNJ5a9685DY=; b=HLQn8/sh+CkxC4QgvO6gXBubPm1QVxGn74SxCdRM1acVTMD7z8OeZH6jFNHcoNhFBk 7uINy4s64L9PICBsevneZ4nmpUulbB69HKlf66Rx0V0Mnl6CwZ+8nj9C9wBCE5iTbtCK fqiLRiGP788OQb7BIsr+AcnaZKSTUR4kIsNuGFvRqryhSUgz8OVzPWpHXsH/TzcfUl3D +u6nw0sBl114ctlhMaFlYE2I8kRYaCLTx+3+P//atlttL+wQT+CG1TPMCkCkZBMIsyLo huBoc3I8Cj+nVVLkm6hfNdGco2azkcl3vTNNeRLA7uIdqUAuFXB4mUs0WGA15le4ANaC 9fgg== X-Gm-Message-State: ALQs6tCXHp1RVrXyMp6gM/m2IOg8uDsXycwbVI548McQ3N/H+0+fJZnu Oqg+SQZIaMyUbpq453Lnx5Klxt2Pf3U= X-Google-Smtp-Source: AIpwx4/vK6wcguxtNIMkLH76g7MF9vOuSZdl/tN5YYeXJ277NUxTZGJEne0UqUtl3SO0mFSHJrlOnQ== X-Received: by 2002:a24:3787:: with SMTP id r129-v6mr27463522itr.72.1524727328515; Thu, 26 Apr 2018 00:22:08 -0700 (PDT) Received: from vader.Home (174-23-136-226.slkc.qwest.net. [174.23.136.226]) by smtp.gmail.com with ESMTPSA id d135-v6sm7594742ita.15.2018.04.26.00.22.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 00:22:07 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com Subject: [PATCH 2/2] blk-mq: fix sysfs inflight counter Date: Thu, 26 Apr 2018 00:21:59 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: 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: Omar Sandoval When the blk-mq inflight implementation was added, /proc/diskstats was converted to use it, but /sys/block/$dev/inflight was not. Fix it by adding another helper to count in-flight requests by data direction. Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant") Signed-off-by: Omar Sandoval --- block/blk-mq.c | 19 +++++++++++++++++++ block/blk-mq.h | 4 +++- block/genhd.c | 12 ++++++++++++ block/partition-generic.c | 10 ++++++---- include/linux/genhd.h | 4 +++- 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 5450cbc61f8d..9ce9cac16c3f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -115,6 +115,25 @@ void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); } +static void blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx, + struct request *rq, void *priv, + bool reserved) +{ + struct mq_inflight *mi = priv; + + if (rq->part == mi->part) + mi->inflight[rq_data_dir(rq)]++; +} + +void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]) +{ + struct mq_inflight mi = { .part = part, .inflight = inflight, }; + + inflight[0] = inflight[1] = 0; + blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight_rw, &mi); +} + void blk_freeze_queue_start(struct request_queue *q) { int freeze_depth; diff --git a/block/blk-mq.h b/block/blk-mq.h index 89b5cd3a6c70..e1bb420dc5d6 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -188,7 +188,9 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx) } void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, - unsigned int inflight[2]); + unsigned int inflight[2]); +void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]); static inline void blk_mq_put_dispatch_budget(struct blk_mq_hw_ctx *hctx) { diff --git a/block/genhd.c b/block/genhd.c index dc7e089373b9..c4513fe1adda 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -82,6 +82,18 @@ void part_in_flight(struct request_queue *q, struct hd_struct *part, } } +void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]) +{ + if (q->mq_ops) { + blk_mq_in_flight_rw(q, part, inflight); + return; + } + + inflight[0] = atomic_read(&part->in_flight[0]); + inflight[1] = atomic_read(&part->in_flight[1]); +} + struct hd_struct *__disk_get_part(struct gendisk *disk, int partno) { struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl); diff --git a/block/partition-generic.c b/block/partition-generic.c index 08dabcd8b6ae..db57cced9b98 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -145,13 +145,15 @@ ssize_t part_stat_show(struct device *dev, jiffies_to_msecs(part_stat_read(p, time_in_queue))); } -ssize_t part_inflight_show(struct device *dev, - struct device_attribute *attr, char *buf) +ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct hd_struct *p = dev_to_part(dev); + struct request_queue *q = part_to_disk(p)->queue; + unsigned int inflight[2]; - return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]), - atomic_read(&p->in_flight[1])); + part_in_flight_rw(q, p, inflight); + return sprintf(buf, "%8u %8u\n", inflight[0], inflight[1]); } #ifdef CONFIG_FAIL_MAKE_REQUEST diff --git a/include/linux/genhd.h b/include/linux/genhd.h index c826b0b5232a..6cb8a5789668 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -368,7 +368,9 @@ static inline void free_part_stats(struct hd_struct *part) part_stat_add(cpu, gendiskp, field, -subnd) void part_in_flight(struct request_queue *q, struct hd_struct *part, - unsigned int inflight[2]); + unsigned int inflight[2]); +void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]); void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw); void part_inc_in_flight(struct request_queue *q, struct hd_struct *part,