mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wang Jianchao (Kuaishou)" <jianchao.wan9@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <jbacik@fb.com>, Tejun Heo <tj@kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC V5 15/16] blk/rq-qos: move the rqos debugfs code to blk-rq-qos.c
Date: Thu, 24 Feb 2022 17:06:53 +0800	[thread overview]
Message-ID: <20220224090654.54671-16-jianchao.wan9@gmail.com> (raw)
In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com>

This is no functional change in this patch.

Signed-off-by: Wang Jianchao (Kuaishou) <jianchao.wan9@gmail.com>
---
 block/blk-mq-debugfs.c | 42 ++++++------------------------------------
 block/blk-mq-debugfs.h | 17 ++++-------------
 block/blk-rq-qos.c     | 38 +++++++++++++++++++++++++++++++++++---
 block/blk-rq-qos.h     |  1 +
 4 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 4c9dafd16a08..71e6a097361b 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -13,7 +13,6 @@
 #include "blk-mq-debugfs.h"
 #include "blk-mq-sched.h"
 #include "blk-mq-tag.h"
-#include "blk-rq-qos.h"
 
 static void print_stat(struct seq_file *m, struct blk_rq_stat *stat)
 {
@@ -691,7 +690,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
 	{},
 };
 
-static void debugfs_create_files(struct dentry *parent, void *data,
+void blk_mq_debugfs_create_files(struct dentry *parent, void *data,
 				 const struct blk_mq_debugfs_attr *attr)
 {
 	if (IS_ERR_OR_NULL(parent))
@@ -709,7 +708,7 @@ void blk_mq_debugfs_register(struct request_queue *q)
 	struct blk_mq_hw_ctx *hctx;
 	int i;
 
-	debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
+	blk_mq_debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
 
 	/*
 	 * blk_mq_init_sched() attempted to do this already, but q->debugfs_dir
@@ -742,7 +741,7 @@ static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx,
 	snprintf(name, sizeof(name), "cpu%u", ctx->cpu);
 	ctx_dir = debugfs_create_dir(name, hctx->debugfs_dir);
 
-	debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs);
+	blk_mq_debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs);
 }
 
 void blk_mq_debugfs_register_hctx(struct request_queue *q,
@@ -755,7 +754,7 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q,
 	snprintf(name, sizeof(name), "hctx%u", hctx->queue_num);
 	hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir);
 
-	debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_attrs);
+	blk_mq_debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_attrs);
 
 	hctx_for_each_ctx(hctx, ctx, i)
 		blk_mq_debugfs_register_ctx(hctx, ctx);
@@ -802,7 +801,7 @@ void blk_mq_debugfs_register_sched(struct request_queue *q)
 
 	q->sched_debugfs_dir = debugfs_create_dir("sched", q->debugfs_dir);
 
-	debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_attrs);
+	blk_mq_debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_attrs);
 }
 
 void blk_mq_debugfs_unregister_sched(struct request_queue *q)
@@ -811,35 +810,6 @@ void blk_mq_debugfs_unregister_sched(struct request_queue *q)
 	q->sched_debugfs_dir = NULL;
 }
 
-void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
-{
-	debugfs_remove_recursive(rqos->debugfs_dir);
-	rqos->debugfs_dir = NULL;
-}
-
-void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
-{
-	struct request_queue *q = rqos->q;
-
-	if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs)
-		return;
-
-	if (!q->rqos_debugfs_dir)
-		q->rqos_debugfs_dir = debugfs_create_dir("rqos",
-							 q->debugfs_dir);
-
-	rqos->debugfs_dir = debugfs_create_dir(rqos->ops->name,
-					       rqos->q->rqos_debugfs_dir);
-
-	debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs);
-}
-
-void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
-{
-	debugfs_remove_recursive(q->rqos_debugfs_dir);
-	q->rqos_debugfs_dir = NULL;
-}
-
 void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 					struct blk_mq_hw_ctx *hctx)
 {
@@ -858,7 +828,7 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 
 	hctx->sched_debugfs_dir = debugfs_create_dir("sched",
 						     hctx->debugfs_dir);
-	debugfs_create_files(hctx->sched_debugfs_dir, hctx,
+	blk_mq_debugfs_create_files(hctx->sched_debugfs_dir, hctx,
 			     e->hctx_debugfs_attrs);
 }
 
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index a68aa6041a10..ed805dca934c 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -31,10 +31,8 @@ void blk_mq_debugfs_unregister_sched(struct request_queue *q);
 void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 				       struct blk_mq_hw_ctx *hctx);
 void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
-
-void blk_mq_debugfs_register_rqos(struct rq_qos *rqos);
-void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos);
-void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q);
+void blk_mq_debugfs_create_files(struct dentry *parent, void *data,
+				 const struct blk_mq_debugfs_attr *attr);
 #else
 static inline void blk_mq_debugfs_register(struct request_queue *q)
 {
@@ -78,15 +76,8 @@ static inline void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hc
 {
 }
 
-static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
-{
-}
-
-static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
-{
-}
-
-static inline void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
+void blk_mq_debugfs_create_files(struct dentry *parent, void *data,
+				 const struct blk_mq_debugfs_attr *attr)
 {
 }
 #endif
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index 236ecb2af845..0572dd584c53 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -295,6 +295,31 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 	finish_wait(&rqw->wait, &data.wq);
 }
 
+#ifdef CONFIG_BLK_DEBUG_FS
+static void rq_qos_debugfs_unregister(struct rq_qos *rqos)
+{
+	debugfs_remove_recursive(rqos->debugfs_dir);
+	rqos->debugfs_dir = NULL;
+}
+
+static void rq_qos_debugfs_register(struct rq_qos *rqos)
+{
+	struct request_queue *q = rqos->q;
+
+	if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs)
+		return;
+
+	if (!q->rqos_debugfs_dir)
+		q->rqos_debugfs_dir = debugfs_create_dir("rqos",
+							 q->debugfs_dir);
+
+	rqos->debugfs_dir = debugfs_create_dir(rqos->ops->name,
+					       rqos->q->rqos_debugfs_dir);
+
+	blk_mq_debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs);
+}
+#endif
+
 void rq_qos_exit(struct request_queue *q)
 {
 	/*
@@ -306,7 +331,10 @@ void rq_qos_exit(struct request_queue *q)
 		q->rq_qos = rqos->next;
 		rqos->ops->exit(rqos);
 	}
-	blk_mq_debugfs_unregister_queue_rqos(q);
+#ifdef CONFIG_BLK_DEBUG_FS
+	debugfs_remove_recursive(q->rqos_debugfs_dir);
+	q->rqos_debugfs_dir = NULL;
+#endif
 }
 
 static struct rq_qos *rq_qos_by_name(struct request_queue *q,
@@ -383,8 +411,10 @@ void rq_qos_activate(struct request_queue *q,
 	}
 	spin_unlock_irq(&q->rqos_lock);
 
+#ifdef CONFIG_BLK_DEBUG_FS
 	if (rqos->ops->debugfs_attrs)
-		blk_mq_debugfs_register_rqos(rqos);
+		rq_qos_debugfs_register(rqos);
+#endif
 }
 
 void rq_qos_deactivate(struct rq_qos *rqos)
@@ -406,7 +436,9 @@ void rq_qos_deactivate(struct rq_qos *rqos)
 		}
 	}
 	spin_unlock_irq(&q->rqos_lock);
-	blk_mq_debugfs_unregister_rqos(rqos);
+#ifdef CONFIG_BLK_DEBUG_FS
+	rq_qos_debugfs_unregister(rqos);
+#endif
 }
 
 static struct rq_qos_ops *rq_qos_op_find(const char *name)
diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
index 3d7df14edde3..463c64d28e8b 100644
--- a/block/blk-rq-qos.h
+++ b/block/blk-rq-qos.h
@@ -8,6 +8,7 @@
 #include <linux/atomic.h>
 #include <linux/wait.h>
 #include <linux/blk-mq.h>
+#include <linux/debugfs.h>
 
 #include "blk-mq-debugfs.h"
 
-- 
2.17.1


  parent reply	other threads:[~2022-02-24  9:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  9:06 [RFC V5 0/16] blk: blk-rq-qos framework refactor and cleanup Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 01/16] blk: make the whole blk_mq_submit_bio under q_usage_counter Wang Jianchao (Kuaishou)
2022-02-24 13:38   ` Christoph Hellwig
2022-02-25  2:11     ` Wang Jianchao
2022-02-24  9:06 ` [RFC V5 02/16] blk/rq-qos: prepare to make blk-rq-qos pluggable Wang Jianchao (Kuaishou)
2022-02-24 13:45   ` Christoph Hellwig
2022-02-24 16:55   ` Tejun Heo
2022-02-24  9:06 ` [RFC V5 03/16] blk-wbt: make wbt pluggable Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 04/16] blk-iolatency: make iolatency pluggable Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 05/16] blk-iocost: make iocost pluggable Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 06/16] blk-ioprio: make ioprio pluggable Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 07/16] blk/rq-qos: get rid of unused interfaces of rqos Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 08/16] blk/rq-qos: export the sysfs for switching qos Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 09/16] blk-wbt: show wbt_lat_us sysfs interface only when wbt is opened Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 10/16] blk-wbt: get rid of wbt_enable/disable_default() Wang Jianchao (Kuaishou)
2022-02-24 13:46   ` Christoph Hellwig
2022-02-24 16:56   ` Tejun Heo
2022-02-24  9:06 ` [RFC V5 11/16] blk/rq-qos: get rid of debugfs register in blk_mq_debugfs_register Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 12/16] blk/rq-qos: change queue_depth_changed to setting_changed Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 13/16] blk-wbt: move cache setting to rq_qos_setting_changed() Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` [RFC V5 14/16] blk-wbt: cleanup the blk-wbt.h Wang Jianchao (Kuaishou)
2022-02-24  9:06 ` Wang Jianchao (Kuaishou) [this message]
2022-02-24  9:06 ` [RFC V5 16/16] blk/rq-qos: add config to control the whole blk-rq-qos framework Wang Jianchao (Kuaishou)
2022-02-24 13:37 ` [RFC V5 0/16] blk: blk-rq-qos framework refactor and cleanup Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220224090654.54671-16-jianchao.wan9@gmail.com \
    --to=jianchao.wan9@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=jbacik@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®