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: 9796971 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 81A536020B for ; Mon, 19 Jun 2017 17:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66CEB1FE5F for ; Mon, 19 Jun 2017 17:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BD3627CEA; Mon, 19 Jun 2017 17:05:45 +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 0550F1FE5F for ; Mon, 19 Jun 2017 17:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751761AbdFSRFn (ORCPT ); Mon, 19 Jun 2017 13:05:43 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:33818 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752372AbdFSRFK (ORCPT ); Mon, 19 Jun 2017 13:05:10 -0400 Received: by mail-io0-f179.google.com with SMTP id i7so68374855ioe.1 for ; Mon, 19 Jun 2017 10:05:09 -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=Stt9n6lB3UEtSEt4M6+stcew9/iG2mWCn0Q50C18XN/3PuSFWiPPTBJNFPFp7MdqCc AHz104KAAh61wX2aBWs/bHW74XARwLYPvCJqSAXATk+7ZWQ100abLjCukLgH5x0mOlE2 Stl5WD4mIKwHzf5idH5BQ2ZpPZ6xpsvQ5RaSiLVeJPFAUKyZsU3dRsKcMX6h3KzWc/I5 IiGxGaRLlYSOY5/jlLcNHuF9RikxXGsimJ0pJS7whZ7/o5LcZ26GMtvCltkYpGgiDco6 OsATei60wUXFpwYowE5BKZjZ/zCW59ysDNY2KAsgW135O1Rs8M2cFJLfo2RTJwPqrB9u 2Q7Q== X-Gm-Message-State: AKS2vOzAGmP1/7P5T2xakGSdA6jpbjtqUwt2NxCQ9bSlD6ob+KghTxj2 dKbyJZyWW+6t2elK 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-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 --- 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 */