From patchwork Tue Jun 13 17:15:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9784425 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 11EC660212 for ; Tue, 13 Jun 2017 17:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBE1A2857E for ; Tue, 13 Jun 2017 17:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0E2928676; Tue, 13 Jun 2017 17:15:57 +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 979142857E for ; Tue, 13 Jun 2017 17:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753461AbdFMRP4 (ORCPT ); Tue, 13 Jun 2017 13:15:56 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:33375 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753490AbdFMRPb (ORCPT ); Tue, 13 Jun 2017 13:15:31 -0400 Received: by mail-io0-f170.google.com with SMTP id t87so57862698ioe.0 for ; Tue, 13 Jun 2017 10:15:30 -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=2Qv2YRGvO+1fYLy4Dzxy1NNC5wtKABoAXQszI2TE/WU=; b=nWmT5SrNqPkUPVen4CELa2SPprmQpYhZLwyWOj7U1DlumS2omAyN3LAfpTUCkJAjYa +V0Fst8MLHe/tnJcnttfZtgfjtJKWa380MhXaS6VB+mYgEBTIwP5WrEaRMQqlC1Z7Box lUUOGpX0dIm7UQY3DpekGfjIhsQOCyzsPHdaE92uaM+FNP1oqDSUkYgSSAQKu/zLrJ0l 68QHNTWy2FJapa+wbjiWM3Jda1Sx9O8WZFKJFVUybk4MmAcAdbAV/B4f+Xfx/emlIa0w 6WpL3VY0x4YhQmhJdyOVnjH6KbhUedpbWp8n4JF1kz3g7LlX1VjacKLRIi98AqpVmW5K 20ig== 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=2Qv2YRGvO+1fYLy4Dzxy1NNC5wtKABoAXQszI2TE/WU=; b=R7Wayke1vB9hcoDxEHtmIluSzOIqRbkGNNf/d/3HsUlY5zTPkHrivpqcdLKoFzZZrX CTxvHHaiNkgK4NumTgm/jHwMf1U+VFOPeJqg8S12qf51HyN3PgLldSZnTtstDkEIZQio iUgFw2mnC05GSX+4fW5MTv58SjTnp38nAZXndaxMZmqJyiNw5pGARaxl6/O9Yex0BZdo vEPLgREV+jvWh1z5RR51Nda+M+7yGfyAacKGEhhr+O4WG9Z9WqHNYM0tnr7aoQzPHUMY xlqO93675agJyGpPhT79pf04AGTK71mwutLgxpyw4kGgwBZVV3dCwY99+NMlCWHY0tR9 hk3A== X-Gm-Message-State: AKS2vOxiPsRxqLDA7CFsyZ/E3sw+d/p/Z4VSfVZAy1zwheRP1yu40v2D xyyeNY9QlI7plTn3Zs3YyA== X-Received: by 10.107.63.139 with SMTP id m133mr1255604ioa.87.1497374130000; Tue, 13 Jun 2017 10:15:30 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id y188sm6217526ity.9.2017.06.13.10.15.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 10:15:29 -0700 (PDT) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 03/11] blk-mq: expose stream write stats through debugfs Date: Tue, 13 Jun 2017 11:15:15 -0600 Message-Id: <1497374123-15286-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497374123-15286-1-git-send-email-axboe@kernel.dk> References: <1497374123-15286-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. Signed-off-by: Jens Axboe --- block/blk-core.c | 2 ++ block/blk-mq-debugfs.c | 24 ++++++++++++++++++++++++ include/linux/blkdev.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index a7421b772d0e..12e402e4e741 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2057,6 +2057,8 @@ blk_qc_t generic_make_request(struct bio *bio) do { struct request_queue *q = bdev_get_queue(bio->bi_bdev); + q->stream_writes[bio_stream(bio)] += bio->bi_iter.bi_size >> 9; + if (likely(blk_queue_enter(q, false) == 0)) { struct bio_list lower, same; diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 803aed4d7221..a0a480a0b373 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 < WRITE_LIFE_NR; 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 < WRITE_LIFE_NR; 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..ab623deb20b2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -586,6 +586,8 @@ struct request_queue { size_t cmd_size; void *rq_alloc_data; + + u64 stream_writes[WRITE_LIFE_NR]; }; #define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */