From patchwork Sat Jun 17 19:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9794371 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 E3F55600F6 for ; Sat, 17 Jun 2017 20:00:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1418209D8 for ; Sat, 17 Jun 2017 20:00:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A53B426C9B; Sat, 17 Jun 2017 20:00:15 +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 58CCD283FF for ; Sat, 17 Jun 2017 20:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752774AbdFQUAL (ORCPT ); Sat, 17 Jun 2017 16:00:11 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:34341 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbdFQUAI (ORCPT ); Sat, 17 Jun 2017 16:00:08 -0400 Received: by mail-it0-f48.google.com with SMTP id m47so7077211iti.1 for ; Sat, 17 Jun 2017 13:00:07 -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=Lp3UMWmSJcLz6I4UTXd9WAvMVEMYX53/qtdZIbKXpMU=; b=Z7Fh/OlX7zu1Q4CHgHBljwA6fvjzJy8/k2Eh5Qn9BihKKNBjoc2BqdoEebPMdCdi5O vhwZ+N3F5mcxVWpmh3rJ0R8ObcqgjXlPJpNKdJYbomTLLRkPpr4eD/6s2/SIvdSgqTn4 DNH+YNGY3OL2HaysDxIJ4qaL6cjpclBsuDWf25My1J10KiZwp8vdxgP4KkZBmLC8IGCQ sIxFOaW3HfUgXiHgVmMNpxecbw9DBkdfbeFdmqc+UTX3CN2rZjwjqGO/q4qsQupjnlue HJxJ/f0D4aoW/9qBtBiSYJhJYfzsYwQD0iV3k7GcIRUHdI4NQOEbgEclgxL/dB1K5t6r Cp+w== 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=Lp3UMWmSJcLz6I4UTXd9WAvMVEMYX53/qtdZIbKXpMU=; b=hAtFoYqhO0Y821KJzZULw4I/JkcnXyY/z38OtTzkJjwV6usg8VYBi31Sd7Sfy56LsK /MRESJIV/1/jkMxaoE0VKbxX1HbQ1Fl2ZZiWqcQG9K1zfltbe6YJQZ0aJc5ac0yq4DXD MHioYmP5o36PLjfTj/4hsQSOFVKmzv8te+FWKJmoV9hwklDqjig78OAXF4/m54BJeM2V k9PMB9/CgY+9CMFTKdNjWqw+elLmjkNSwhJtV4YIHkjoKFIFWNzYIdkJzqUQYaAsN7eS bgq5t2rxFm17rewDEQ13yEi7zaToYcofdQ47Cz8Rv57jtqwV1nZNqdlswH/HS712s2Yf qcqw== X-Gm-Message-State: AKS2vOxwM+gb9QUyZx6UdUSpPwJHAwUEdS93wbHIj4OikFuvvRdJuBIW xNoCFAacEIymG7cfM4w15Q== X-Received: by 10.36.84.144 with SMTP id t138mr15633751ita.76.1497729607074; Sat, 17 Jun 2017 13:00:07 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w199sm537049iod.15.2017.06.17.13.00.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Jun 2017 13:00:06 -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 03/11] blk-mq: expose stream write hints through debugfs Date: Sat, 17 Jun 2017 13:59:46 -0600 Message-Id: <1497729594-4707-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497729594-4707-1-git-send-email-axboe@kernel.dk> References: <1497729594-4707-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 with each write hint. 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->write_hints[] if they handle a given write hint. 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..b069a76f7fc7 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_write_hint_show(void *data, struct seq_file *m) +{ + struct request_queue *q = data; + int i; + + for (i = 0; i < BLK_MAX_WRITE_HINTS; i++) + seq_printf(m, "hint%d: %llu\n", i, q->write_hints[i]); + + return 0; +} + +static ssize_t queue_write_hint_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_WRITE_HINTS; i++) + q->write_hints[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}, + {"write_hints", 0600, queue_write_hint_show, queue_write_hint_store}, {}, }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b74a3edcb3da..ab36068f6129 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -588,6 +588,9 @@ struct request_queue { void *rq_alloc_data; struct work_struct release_work; + +#define BLK_MAX_WRITE_HINTS 5 + u64 write_hints[BLK_MAX_WRITE_HINTS]; }; #define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */