From patchwork Wed Jun 21 00:22:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9800477 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 CE9D06038C for ; Wed, 21 Jun 2017 00:22:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF07028426 for ; Wed, 21 Jun 2017 00:22:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B43EF28471; Wed, 21 Jun 2017 00:22:32 +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 6B15128426 for ; Wed, 21 Jun 2017 00:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752861AbdFUAWT (ORCPT ); Tue, 20 Jun 2017 20:22:19 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33634 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752812AbdFUAWO (ORCPT ); Tue, 20 Jun 2017 20:22:14 -0400 Received: by mail-pf0-f175.google.com with SMTP id 83so76891867pfr.0 for ; Tue, 20 Jun 2017 17:22:14 -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=vJ4aP8an327sYV+TP8uRWzJRnwXwY1KNILRkyTCvc5iK4X6RiiKZr7qygF5bIurwKb Gek0gAExVQOgtEeh/SIbaRkO2+7f9NP1RErMZfk96NrCOrWocULydB9hUshXvtCp1/d2 scWNi6wmPNJdUC4yhbn18jZpY235mfzI5MhCSMdF7L9+gaxyToN+lPcgedQkibP7Yp4X sjW3kIpY+MZcs6A5j1WMtGnuyCgOIxpS5grVbnhisPOBQfYSwKEWJrhsw+Cea9YOblwC V5Wj7/X9Cv8LlzcIoo9Tw5V0q35TumMLJ57a/Zb7dxFT3ADWEoSDWX5y/3Cl86QqWkuW l6lA== 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=Gskl3ZMTcPHPsrcBuj9nFeUw1B2HFmXGg+Wpv7+4AnCr5csY61LBNXF67Y2mt0drAZ kyf+nBuCj7w2pGY4IV44f8epoigenIt5lm0w/uGMGTuY3dK9Q/2KvyKVHLrfPBOT2flu IxhlOaC6TfXwdYvD86u599934cvv87w9Bb3yaMNeoEwNvVavtliZlFs5TVxvMgiQJwQJ Xd2/2Vn6bYWZb44lBa4GiD1OPVp3VWP+qxHcV4tgjbx9RmWALSj39UsFkBDg2gwu7tim oui7NwV35FkogaLsT2CSKNVTOVzYVE2JPNqhvQix2U8hE63AnqZVEG/hvwtlcVnZn9WS 3DZQ== X-Gm-Message-State: AKS2vOxnuYqcKYuruMUW7mupCOm4uo8TskK+4MvlJ/iRbXeldDEo2/WM H4jR/A4XN85+dARm X-Received: by 10.98.73.18 with SMTP id w18mr33162600pfa.61.1498004533807; Tue, 20 Jun 2017 17:22:13 -0700 (PDT) Received: from localhost.localdomain (66.29.164.166.static.utbb.net. [66.29.164.166]) by smtp.gmail.com with ESMTPSA id f10sm13447835pfd.69.2017.06.20.17.22.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 17:22:13 -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: Tue, 20 Jun 2017 18:22:00 -0600 Message-Id: <1498004526-4543-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498004526-4543-1-git-send-email-axboe@kernel.dk> References: <1498004526-4543-1-git-send-email-axboe@kernel.dk> 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 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 Reviewed-by: Christoph Hellwig --- 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 */