From patchwork Mon Jun 26 15:37:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9809955 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 42F22603F3 for ; Mon, 26 Jun 2017 15:38:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47BB728520 for ; Mon, 26 Jun 2017 15:38:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CAC52861B; Mon, 26 Jun 2017 15:38:34 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 D307328619 for ; Mon, 26 Jun 2017 15:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751592AbdFZPic (ORCPT ); Mon, 26 Jun 2017 11:38:32 -0400 Received: from mail-io0-f171.google.com ([209.85.223.171]:34241 "EHLO mail-io0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbdFZPiW (ORCPT ); Mon, 26 Jun 2017 11:38:22 -0400 Received: by mail-io0-f171.google.com with SMTP id r36so2995934ioi.1 for ; Mon, 26 Jun 2017 08:38:17 -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=qp3sDkNhW0UmafFPF7DrEUxNfE7zepdR2oHs6U2dzYo=; b=IZGmg+aHXxIvx/6RZp/RmOY82Hlf0V6ucWNQ/qqr8Q4ebHq4EqT24SFIOfuBQoIa6n FWFmi155xf9lQulNm7P4NzKK7cLuh3pPTHrfS1S3Ytnvpq2kJzfPCsLZR1dzTnaNpwra 5TXdIhNcgkpB6+AGK9i63n/AVAHMp9yTrxHHpUiLe2M9Y2ZHgmuwwr+sIRzmTAErSUMu Mq3b4u8wOmgB/WSfMxWZxPMQp2aa1YBdnqV/+dldub89rXrnwb3XkaxwWcx2UgYG+hKG e/j8PAtD+vtuUycWp5E2C/hdXKkXSFGZDjtd9RhN3ox3+bV1Hu10hYIzySvbQI4APudo EUCQ== 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=qp3sDkNhW0UmafFPF7DrEUxNfE7zepdR2oHs6U2dzYo=; b=iEBzubYavcAlB8CoPzS/uq1ruAMmCbSFkM4uZZUCb02RFpugbtK0p8ewtrOWOVgdHf kGMkw8NZhgzPIGpEDQzISq3bSPwY3dk5uOXzqahZMWE5+jj2h/ty2iaBQpEy2mZdldAR OaWJP9FhSOnvoO8zRs4OOV4tzD6HLI5TWSpGSHdPKqC1mJaDvSUUwlY2ZPYYMphvWbOE uBCEy9HcdrhwevqINmKT9RyE2WSNdm17SRHWvmIfJxWG7WuDKi+q2QGi2rV+yJ2gjpFs H3Tzx0sVM7YOEwqD+zI7fTo2FqTe78QjbC/MGZcnRHqZ8lheeC62VmRDBGB0Qnmoj0SO ukLw== X-Gm-Message-State: AKS2vOwAKw3ZD7qG4rCvx6klAPfVNKsHLpME+Q4sh8u2rZUBut/ezoM7 h0ojJWUBCLdybNhwTQxZkQ== X-Received: by 10.107.183.204 with SMTP id h195mr1010371iof.29.1498491491868; Mon, 26 Jun 2017 08:38:11 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id b69sm33425itb.23.2017.06.26.08.38.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 08:38:11 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, hch@lst.de, martin.petersen@oracle.com, Jens Axboe Subject: [PATCH 3/9] blk-mq: expose write hints through debugfs Date: Mon, 26 Jun 2017 09:37:54 -0600 Message-Id: <1498491480-16306-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498491480-16306-1-git-send-email-axboe@kernel.dk> References: <1498491480-16306-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 Reviewed-by: Martin K. Petersen Reviewed-by: Christoph Hellwig 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 bf2157141d53..596de77b9a0a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -594,6 +594,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 */