From patchwork Mon Jun 19 17:04:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9796921 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 853E66020B for ; Mon, 19 Jun 2017 17:05:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A9CC1FF0B for ; Mon, 19 Jun 2017 17:05:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F68727EE2; Mon, 19 Jun 2017 17:05:22 +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=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 A268326E97 for ; Mon, 19 Jun 2017 17:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752636AbdFSRFR (ORCPT ); Mon, 19 Jun 2017 13:05:17 -0400 Received: from mail-io0-f169.google.com ([209.85.223.169]:35107 "EHLO mail-io0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbdFSRFP (ORCPT ); Mon, 19 Jun 2017 13:05:15 -0400 Received: by mail-io0-f169.google.com with SMTP id k93so68343143ioi.2 for ; Mon, 19 Jun 2017 10:05:15 -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=2FxJKbDF3q3xXFZaTRDHNPof51nV5efAsasSRkJvHUA=; b=GamfTaVTwg5P68EnfZmr4fmUiIqioj03Ud+6S/qMFBalnnk39SzS1VqEXZ3cjlYZPr NJaAQtwfuWY9b94vhXF4U6wxa9uGyEXSRSmXcHzprvhThG2DoU03aBlq65zYHgdYQgne I5iOH8SY1OEPgayf3VWHOgoMA3MhdNiVsi3CddGxZfbP0ZP/gm7/Px4926T3yH8gQjo2 bHM7NU3jN6V7Zvb/DV0/+wYMkMEwmj9QoDTbCeIBig8PjHoextO5k8Zp++mC9aqH7P2g yw7vSbWybMCScBmqaUb+O1OBSVXuTebIy4oWPZ80Jjl3lJnkV71Wve77gYvCjLiIEXC5 y+Gw== 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=2FxJKbDF3q3xXFZaTRDHNPof51nV5efAsasSRkJvHUA=; b=SHk01ndO1WUfwlixE5P59sy9uE+vh7etKl1joZNjABSUS8ASB+Xa7xTOzeu+e/rxRI Vt3jP+OHv2J5v+EDiEAqrD1cJp801DsBGuiqIuj8MK69ZrAMz3b2TMk2N8lxhY6n3cMP z0xZbt/XomRMbAE/8LXNi9PVoUMtIiBt6tLTLEpcvBlCSXEvm1SUHJWEQqg5IgYFl8bq oF0VrbFUZyMjJiLbDY8PLpCGDNh6Sgo5yJWHCmbSFh93vokmOvN8JhsylLY2lJ+HAE4u P7KM/wIHmRDDnIuogn/Bg74NeRd4SIU3BpMRVEk+cXgCjciOczjdinV7a4cjSfOFVomG n5gA== X-Gm-Message-State: AKS2vOxrSPCM5CWCFTn5V3gCEXD2/JCadCGQQPasrFjhIbguKkea5gY6 DqtIUti9WAPREvSphJT3tQ== X-Received: by 10.107.134.82 with SMTP id i79mr22056268iod.229.1497891909295; Mon, 19 Jun 2017 10:05:09 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 3sm6770522ith.7.2017.06.19.10.05.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jun 2017 10:05:08 -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, linux-nvme@lists.infradead.org, Jens Axboe Subject: [PATCH 3/9] blk-mq: expose stream write hints through debugfs Date: Mon, 19 Jun 2017 11:04:56 -0600 Message-Id: <1497891902-25737-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497891902-25737-1-git-send-email-axboe@kernel.dk> References: <1497891902-25737-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 9edebbdce0bd..9ebc2945f991 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -135,6 +135,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; @@ -730,6 +753,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = { {"poll_stat", 0400, queue_poll_stat_show}, {"requeue_list", 0400, .seq_ops = &queue_requeue_list_seq_ops}, {"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 22cfba64ce81..687394b70924 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_WRITE_HINTS 5 + u64 write_hints[BLK_MAX_WRITE_HINTS]; }; #define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */