From patchwork Thu Jun 15 03:45:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9787997 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 AF4C860231 for ; Thu, 15 Jun 2017 03:45:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A58AF23F88 for ; Thu, 15 Jun 2017 03:45:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A54827C2D; Thu, 15 Jun 2017 03:45:26 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable 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 90E1A23F88 for ; Thu, 15 Jun 2017 03:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752041AbdFODpY (ORCPT ); Wed, 14 Jun 2017 23:45:24 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35011 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbdFODpW (ORCPT ); Wed, 14 Jun 2017 23:45:22 -0400 Received: by mail-pf0-f182.google.com with SMTP id l89so1804627pfi.2 for ; Wed, 14 Jun 2017 20:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oGR+UbMfogfFj4SDs8jHc/yfHmj0nOfl8InF9B4o1gM=; b=TJ35OkC72SAraAxtvKV63AWg5G2KcXGUsQUWCHhmrSOjA0Tcae0fT1CoLCG2KjhVTQ P9baP230T+c4B2wfGCJ1R9CszVBNKh1OIQ8fN4NR/Nf/ETcfXzp9SfeE9banZen/DhO9 XCCkH0+6omWyC+0er5lPdodP5KYk9nEA1R/qLp/klWBRjjvoDruSdB8iR//rg7x4+8zP HQzulwzrKHU8tNKME6oL0DnUIqDmSeT3l6+WzbVeVD8ofIO2GpWTvGTVNqQQFVsCI6wo pnhYvog4PFxyoJBxeOw1qumtg3zif5fszI7zywPDYcCps40FR6ebsD83ysi8IdTurdX0 JjrA== 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=oGR+UbMfogfFj4SDs8jHc/yfHmj0nOfl8InF9B4o1gM=; b=b9Z1FWEDcfg3ThqAxBT0yjVcbRoQblsUBuWiZyG/09wvkdqRAsJnnYtuMyCryj/Ue+ mriH5d7k2c7c9W72p/uOZn2DBl085kZtopTJi74OhYEpILrKaDokDl/LE7DUqC1wbslZ D8WLpNtW2FeARdFg5FsNmGsT9jg2fH8QzRmmbG5mnujfuDAzE/a0GNFio+7dUJLiH5J/ FoggH8h7ZGCvSw9J8LdOPRDEdnzQ3GqZM8TR6CRqm1Wn9EntUKwl1Y4u0iJ918syXD5c xsVyzQMHmSqoLube0Ywo0ikb3z9vPV3cADNTqw7wWoBSmwbaQ3v1Ci/bKtA7pP8dq+kJ T72g== X-Gm-Message-State: AKS2vOwcuyJZy5SeoDnID7tGUjSF0/jQIljX0oP7P1nmXyYqWui71ff8 KjNnb104OgSwwBlTxxMmTg== X-Received: by 10.84.177.131 with SMTP id x3mr3768087plb.39.1497498321226; Wed, 14 Jun 2017 20:45:21 -0700 (PDT) Received: from localhost.localdomain (66.29.164.166.static.utbb.net. [66.29.164.166]) by smtp.gmail.com with ESMTPSA id f71sm2532627pfd.98.2017.06.14.20.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 20:45:20 -0700 (PDT) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: adilger@dilger.ca, hch@infradead.org, martin.petersen@oracle.com, Jens Axboe Subject: [PATCH 02/11] blk-mq: expose stream write stats through debugfs Date: Wed, 14 Jun 2017 21:45:03 -0600 Message-Id: <1497498312-17704-3-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497498312-17704-1-git-send-email-axboe@kernel.dk> References: <1497498312-17704-1-git-send-email-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Useful to verify that things are working the way they should. Reading the file will return number of kb written to each stream. Writing the file will reset the statistics. No care is taken to ensure that we don't race on updates. Drivers will write to q->stream_writes[] if they handle a stream. Reviewed-by: Andreas Dilger Signed-off-by: Jens Axboe --- block/blk-mq-debugfs.c | 24 ++++++++++++++++++++++++ include/linux/blkdev.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 803aed4d7221..0a37c848961d 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -133,6 +133,29 @@ static void print_stat(struct seq_file *m, struct blk_rq_stat *stat) } } +static int queue_streams_show(void *data, struct seq_file *m) +{ + struct request_queue *q = data; + int i; + + for (i = 0; i < BLK_MAX_STREAM; i++) + seq_printf(m, "stream%d: %llu\n", i, q->stream_writes[i]); + + return 0; +} + +static ssize_t queue_streams_store(void *data, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct request_queue *q = data; + int i; + + for (i = 0; i < BLK_MAX_STREAM; i++) + q->stream_writes[i] = 0; + + return count; +} + static int queue_poll_stat_show(void *data, struct seq_file *m) { struct request_queue *q = data; @@ -656,6 +679,7 @@ const struct file_operations blk_mq_debugfs_fops = { static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = { {"poll_stat", 0400, queue_poll_stat_show}, {"state", 0600, queue_state_show, queue_state_write}, + {"streams", 0600, queue_streams_show, queue_streams_store}, {}, }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ab92c4ea138b..88719c6f3edf 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -586,6 +586,9 @@ struct request_queue { size_t cmd_size; void *rq_alloc_data; + +#define BLK_MAX_STREAM 5 + u64 stream_writes[BLK_MAX_STREAM]; }; #define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */