All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] block: support debugfs on rq_qos & wbt
@ 2018-12-14 11:39 Ming Lei
  2018-12-14 11:39 ` [PATCH 1/2] blk-mq-debugfs: support rq_qos Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ming Lei @ 2018-12-14 11:39 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei

Hi,

The 1st patch provides support debugfs on rq_qos.

The 2nd patch exports blk-wbt's internal states via debugfs.


Ming Lei (2):
  blk-mq-debugfs: support rq_qos
  blk-wbt: export internal state via debugfs

 block/blk-mq-debugfs.c | 54 ++++++++++++++++++++++++++++++
 block/blk-mq-debugfs.h | 17 ++++++++++
 block/blk-rq-qos.c     |  2 ++
 block/blk-rq-qos.h     | 26 +++++++++++++++
 block/blk-wbt.c        | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/blkdev.h |  1 +
 6 files changed, 191 insertions(+)

-- 
2.9.5


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] blk-mq-debugfs: support rq_qos
  2018-12-14 11:39 [PATCH 0/2] block: support debugfs on rq_qos & wbt Ming Lei
@ 2018-12-14 11:39 ` Ming Lei
  2018-12-14 19:11   ` Bart Van Assche
  2018-12-14 11:39 ` [PATCH 2/2] blk-wbt: export internal state via debugfs Ming Lei
  2018-12-14 12:56 ` [PATCH 0/2] block: support debugfs on rq_qos & wbt Jens Axboe
  2 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2018-12-14 11:39 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Ming Lei, Bart Van Assche, Omar Sandoval,
	Christoph Hellwig, Josef Bacik

blk-mq-debugfs has been proved as very helpful for debug some
tough issues, such as IO hang.

We have seen blk-wbt related IO hang several times, even inside
Red Hat BZ, there is such report not sovled yet, so this patch
adds support debugfs on rq_qos.

Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq-debugfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 block/blk-mq-debugfs.h | 17 ++++++++++++++++
 block/blk-rq-qos.c     |  2 ++
 block/blk-rq-qos.h     | 26 ++++++++++++++++++++++++
 include/linux/blkdev.h |  1 +
 5 files changed, 100 insertions(+)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index a32bb79d6c95..bbcbc2ca0176 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -23,6 +23,7 @@
 #include "blk-mq.h"
 #include "blk-mq-debugfs.h"
 #include "blk-mq-tag.h"
+#include "blk-rq-qos.h"
 
 static void print_stat(struct seq_file *m, struct blk_rq_stat *stat)
 {
@@ -856,6 +857,15 @@ int blk_mq_debugfs_register(struct request_queue *q)
 			goto err;
 	}
 
+	if (q->rq_qos) {
+		struct rq_qos *rqos = q->rq_qos;
+
+		while (rqos) {
+			blk_mq_debugfs_register_rqos(rqos);
+			rqos = rqos->next;
+		}
+	}
+
 	return 0;
 
 err:
@@ -978,6 +988,50 @@ 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;
+}
+
+int blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
+{
+	struct request_queue *q = rqos->q;
+	char *dir_name = rq_qos_id_to_name(rqos->id);
+
+	if (!q->debugfs_dir)
+		return -ENOENT;
+
+	if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs)
+		return 0;
+
+	if (!q->rqos_debugfs_dir) {
+		q->rqos_debugfs_dir = debugfs_create_dir("rqos",
+							 q->debugfs_dir);
+		if (!q->rqos_debugfs_dir)
+			return -ENOMEM;
+	}
+
+	rqos->debugfs_dir = debugfs_create_dir(dir_name,
+					       rqos->q->rqos_debugfs_dir);
+	if (!rqos->debugfs_dir)
+		return -ENOMEM;
+
+	if (!debugfs_create_files(rqos->debugfs_dir, rqos,
+				  rqos->ops->debugfs_attrs))
+		goto err;
+	return 0;
+ err:
+	blk_mq_debugfs_unregister_rqos(rqos);
+	return -ENOMEM;
+}
+
+void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
+{
+	debugfs_remove_recursive(q->rqos_debugfs_dir);
+	q->rqos_debugfs_dir = NULL;
+}
+
 int blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 				       struct blk_mq_hw_ctx *hctx)
 {
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index a9160be12be0..8c9012a578c1 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -31,6 +31,10 @@ void blk_mq_debugfs_unregister_sched(struct request_queue *q);
 int 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);
+
+int 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);
 #else
 static inline int blk_mq_debugfs_register(struct request_queue *q)
 {
@@ -78,6 +82,19 @@ static inline int blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 static inline void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)
 {
 }
+
+static inline int blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
+{
+	return 0;
+}
+
+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)
+{
+}
 #endif
 
 #ifdef CONFIG_BLK_DEBUG_FS_ZONED
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index e932ef9d2718..d169d7188fa6 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -264,6 +264,8 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 
 void rq_qos_exit(struct request_queue *q)
 {
+	blk_mq_debugfs_unregister_queue_rqos(q);
+
 	while (q->rq_qos) {
 		struct rq_qos *rqos = q->rq_qos;
 		q->rq_qos = rqos->next;
diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
index 8678875de420..fd8a0c5debd3 100644
--- a/block/blk-rq-qos.h
+++ b/block/blk-rq-qos.h
@@ -7,6 +7,10 @@
 #include <linux/atomic.h>
 #include <linux/wait.h>
 
+#include "blk-mq-debugfs.h"
+
+struct blk_mq_debugfs_attr;
+
 enum rq_qos_id {
 	RQ_QOS_WBT,
 	RQ_QOS_CGROUP,
@@ -22,6 +26,9 @@ struct rq_qos {
 	struct request_queue *q;
 	enum rq_qos_id id;
 	struct rq_qos *next;
+#ifdef CONFIG_BLK_DEBUG_FS
+	struct dentry		*debugfs_dir;
+#endif
 };
 
 struct rq_qos_ops {
@@ -33,6 +40,9 @@ struct rq_qos_ops {
 	void (*done_bio)(struct rq_qos *, struct bio *);
 	void (*cleanup)(struct rq_qos *, struct bio *);
 	void (*exit)(struct rq_qos *);
+#ifdef CONFIG_BLK_DEBUG_FS
+	const struct blk_mq_debugfs_attr *debugfs_attrs;
+#endif
 };
 
 struct rq_depth {
@@ -66,6 +76,17 @@ static inline struct rq_qos *blkcg_rq_qos(struct request_queue *q)
 	return rq_qos_id(q, RQ_QOS_CGROUP);
 }
 
+static inline char *rq_qos_id_to_name(enum rq_qos_id id)
+{
+	switch (id) {
+	case RQ_QOS_WBT:
+		return "wbt";
+	case RQ_QOS_CGROUP:
+		return "cgroup";
+	}
+	return "unknown";
+}
+
 static inline void rq_wait_init(struct rq_wait *rq_wait)
 {
 	atomic_set(&rq_wait->inflight, 0);
@@ -76,6 +97,9 @@ static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
 {
 	rqos->next = q->rq_qos;
 	q->rq_qos = rqos;
+
+	if (rqos->ops->debugfs_attrs)
+		blk_mq_debugfs_register_rqos(rqos);
 }
 
 static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
@@ -91,6 +115,8 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
 		}
 		prev = cur;
 	}
+
+	blk_mq_debugfs_unregister_rqos(rqos);
 }
 
 typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_data);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 81f1b105946b..45552e6eae1e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -560,6 +560,7 @@ struct request_queue {
 #ifdef CONFIG_BLK_DEBUG_FS
 	struct dentry		*debugfs_dir;
 	struct dentry		*sched_debugfs_dir;
+	struct dentry		*rqos_debugfs_dir;
 #endif
 
 	bool			mq_sysfs_init_done;
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] blk-wbt: export internal state via debugfs
  2018-12-14 11:39 [PATCH 0/2] block: support debugfs on rq_qos & wbt Ming Lei
  2018-12-14 11:39 ` [PATCH 1/2] blk-mq-debugfs: support rq_qos Ming Lei
@ 2018-12-14 11:39 ` Ming Lei
  2018-12-14 19:15   ` Bart Van Assche
  2018-12-14 12:56 ` [PATCH 0/2] block: support debugfs on rq_qos & wbt Jens Axboe
  2 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2018-12-14 11:39 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Ming Lei, Bart Van Assche, Omar Sandoval,
	Christoph Hellwig, Josef Bacik

This information is helpful to either investigate issues, or understand
wbt's internal behaviour.

Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-wbt.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 463e4eb80287..2684bf2d112f 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -715,6 +715,94 @@ void wbt_disable_default(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(wbt_disable_default);
 
+#ifdef CONFIG_BLK_DEBUG_FS
+static int wbt_curr_window_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%llu ns\n", rwb->cur_win_nsec);
+	return 0;
+}
+
+static int wbt_enable_state_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%d\n", rwb->enable_state);
+	return 0;
+}
+
+static int wbt_id_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+
+	seq_printf(m, "%u\n", rqos->id);
+	return 0;
+}
+
+static int wbt_inflight_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+	int i;
+
+	for (i = 0; i < WBT_NUM_RWQ; i++)
+		seq_printf(m, "%d: inflight %d\n", i,
+			   atomic_read(&rwb->rq_wait[i].inflight));
+	return 0;
+}
+
+static int wbt_min_latency_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%luns\n", rwb->min_lat_nsec);
+	return 0;
+}
+
+static int wbt_unknown_cnt_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%u\n", rwb->unknown_cnt);
+	return 0;
+}
+
+static int wbt_normal_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%u\n", rwb->wb_normal);
+	return 0;
+}
+
+static int wbt_background_show(void *data, struct seq_file *m)
+{
+	struct rq_qos *rqos = data;
+	struct rq_wb *rwb = RQWB(rqos);
+
+	seq_printf(m, "%u\n", rwb->wb_background);
+	return 0;
+}
+
+static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
+	{"curr_window", 0400, wbt_curr_window_show},
+	{"enable_state", 0400, wbt_enable_state_show},
+	{"id", 0400, wbt_id_show},
+	{"inflight", 0400, wbt_inflight_show},
+	{"min_latency", 0400, wbt_min_latency_show},
+	{"unknown_cnt", 0400, wbt_unknown_cnt_show},
+	{"wb_normal", 0400, wbt_normal_show},
+	{"wb_background", 0400, wbt_background_show},
+	{},
+};
+#endif
+
 static struct rq_qos_ops wbt_rqos_ops = {
 	.throttle = wbt_wait,
 	.issue = wbt_issue,
@@ -723,6 +811,9 @@ static struct rq_qos_ops wbt_rqos_ops = {
 	.done = wbt_done,
 	.cleanup = wbt_cleanup,
 	.exit = wbt_exit,
+#ifdef CONFIG_BLK_DEBUG_FS
+	.debugfs_attrs = wbt_debugfs_attrs,
+#endif
 };
 
 int wbt_init(struct request_queue *q)
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] block: support debugfs on rq_qos & wbt
  2018-12-14 11:39 [PATCH 0/2] block: support debugfs on rq_qos & wbt Ming Lei
  2018-12-14 11:39 ` [PATCH 1/2] blk-mq-debugfs: support rq_qos Ming Lei
  2018-12-14 11:39 ` [PATCH 2/2] blk-wbt: export internal state via debugfs Ming Lei
@ 2018-12-14 12:56 ` Jens Axboe
  2 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2018-12-14 12:56 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-block

On 12/14/18 4:39 AM, Ming Lei wrote:
> Hi,
> 
> The 1st patch provides support debugfs on rq_qos.
> 
> The 2nd patch exports blk-wbt's internal states via debugfs.

This is great! We do indeed badly need it, not just to diagnose
hangs, but also to get a better idea of what is going on. I've
got a wbt-trace script that I use, but this is easier for a quick
inspection.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] blk-mq-debugfs: support rq_qos
  2018-12-14 11:39 ` [PATCH 1/2] blk-mq-debugfs: support rq_qos Ming Lei
@ 2018-12-14 19:11   ` Bart Van Assche
  2018-12-16 16:04     ` Jens Axboe
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2018-12-14 19:11 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe
  Cc: linux-block, Bart Van Assche, Omar Sandoval, Christoph Hellwig,
	Josef Bacik

On Fri, 2018-12-14 at 19:39 +0800, Ming Lei wrote:
>  static void print_stat(struct seq_file *m, struct blk_rq_stat *stat)
>  {
> @@ -856,6 +857,15 @@ int blk_mq_debugfs_register(struct request_queue *q)
>  			goto err;
>  	}
>  
> +	if (q->rq_qos) {
> +		struct rq_qos *rqos = q->rq_qos;
> +
> +		while (rqos) {
> +			blk_mq_debugfs_register_rqos(rqos);
> +			rqos = rqos->next;
> +		}
> +	}

Have you considered to use a for-loop instead of a while loop? That would
allow to remove the if-statement and hence would make the code more compact.

> +int blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
> +{
> +	struct request_queue *q = rqos->q;
> +	char *dir_name = rq_qos_id_to_name(rqos->id);

Please change "char *" into "const char *".

>  enum rq_qos_id {
>  	RQ_QOS_WBT,
>  	RQ_QOS_CGROUP,
> @@ -22,6 +26,9 @@ struct rq_qos {
>  	struct request_queue *q;
>  	enum rq_qos_id id;
>  	struct rq_qos *next;
> +#ifdef CONFIG_BLK_DEBUG_FS
> +	struct dentry		*debugfs_dir;
> +#endif
>  };

The indentation of "debugfs_dir" looks odd to me.

> +static inline char *rq_qos_id_to_name(enum rq_qos_id id)
> +{
> +	switch (id) {
> +	case RQ_QOS_WBT:
> +		return "wbt";
> +	case RQ_QOS_CGROUP:
> +		return "cgroup";
> +	}
> +	return "unknown";
> +}

Same comment here as earlier: please use "const char *" instead of "char *"
for constant strings. Otherwise this patch looks fine to me.

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] blk-wbt: export internal state via debugfs
  2018-12-14 11:39 ` [PATCH 2/2] blk-wbt: export internal state via debugfs Ming Lei
@ 2018-12-14 19:15   ` Bart Van Assche
  2018-12-16 16:07     ` Jens Axboe
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2018-12-14 19:15 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe
  Cc: linux-block, Bart Van Assche, Omar Sandoval, Christoph Hellwig,
	Josef Bacik

On Fri, 2018-12-14 at 19:39 +0800, Ming Lei wrote:
> This information is helpful to either investigate issues, or understand
> wbt's internal behaviour.
> 
> Cc: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  block/blk-wbt.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> index 463e4eb80287..2684bf2d112f 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -715,6 +715,94 @@ void wbt_disable_default(struct request_queue *q)
>  }
>  EXPORT_SYMBOL_GPL(wbt_disable_default);
>  
> +#ifdef CONFIG_BLK_DEBUG_FS
> +static int wbt_curr_window_show(void *data, struct seq_file *m)
> +{
> +	struct rq_qos *rqos = data;
> +	struct rq_wb *rwb = RQWB(rqos);
> +
> +	seq_printf(m, "%llu ns\n", rwb->cur_win_nsec);
> +	return 0;
> +}

Please consider to embed the unit ("ns") in the attribute name instead of
in the attribute value. That will make it easier to process this attribute
in developer debug scripts.

> +static int wbt_min_latency_show(void *data, struct seq_file *m)
> +{
> +	struct rq_qos *rqos = data;
> +	struct rq_wb *rwb = RQWB(rqos);
> +
> +	seq_printf(m, "%luns\n", rwb->min_lat_nsec);
> +	return 0;
> +}

Same comment here about the unit.

> +static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
> +	{"curr_window", 0400, wbt_curr_window_show},
> +	{"enable_state", 0400, wbt_enable_state_show},

How about using "enabled" instead of "enable_state"?

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] blk-mq-debugfs: support rq_qos
  2018-12-14 19:11   ` Bart Van Assche
@ 2018-12-16 16:04     ` Jens Axboe
  2018-12-16 16:09       ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Jens Axboe @ 2018-12-16 16:04 UTC (permalink / raw)
  To: Bart Van Assche, Ming Lei
  Cc: linux-block, Bart Van Assche, Omar Sandoval, Christoph Hellwig,
	Josef Bacik

On 12/14/18 12:11 PM, Bart Van Assche wrote:
> On Fri, 2018-12-14 at 19:39 +0800, Ming Lei wrote:
>>  static void print_stat(struct seq_file *m, struct blk_rq_stat *stat)
>>  {
>> @@ -856,6 +857,15 @@ int blk_mq_debugfs_register(struct request_queue *q)
>>  			goto err;
>>  	}
>>  
>> +	if (q->rq_qos) {
>> +		struct rq_qos *rqos = q->rq_qos;
>> +
>> +		while (rqos) {
>> +			blk_mq_debugfs_register_rqos(rqos);
>> +			rqos = rqos->next;
>> +		}
>> +	}
> 
> Have you considered to use a for-loop instead of a while loop? That would
> allow to remove the if-statement and hence would make the code more compact.

It would fit better with the style in that code do to:

rqos = q->rq_qos;
while (rqos) {
    ....
    rqos = rqos->next;
}

> 
>> +int blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
>> +{
>> +	struct request_queue *q = rqos->q;
>> +	char *dir_name = rq_qos_id_to_name(rqos->id);
> 
> Please change "char *" into "const char *".
> 
>>  enum rq_qos_id {
>>  	RQ_QOS_WBT,
>>  	RQ_QOS_CGROUP,
>> @@ -22,6 +26,9 @@ struct rq_qos {
>>  	struct request_queue *q;
>>  	enum rq_qos_id id;
>>  	struct rq_qos *next;
>> +#ifdef CONFIG_BLK_DEBUG_FS
>> +	struct dentry		*debugfs_dir;
>> +#endif
>>  };
> 
> The indentation of "debugfs_dir" looks odd to me.
> 
>> +static inline char *rq_qos_id_to_name(enum rq_qos_id id)
>> +{
>> +	switch (id) {
>> +	case RQ_QOS_WBT:
>> +		return "wbt";
>> +	case RQ_QOS_CGROUP:
>> +		return "cgroup";
>> +	}
>> +	return "unknown";
>> +}
> 
> Same comment here as earlier: please use "const char *" instead of "char *"
> for constant strings. Otherwise this patch looks fine to me.

Agree on the rest of your comments.


-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] blk-wbt: export internal state via debugfs
  2018-12-14 19:15   ` Bart Van Assche
@ 2018-12-16 16:07     ` Jens Axboe
  2018-12-17  1:10       ` Ming Lei
  0 siblings, 1 reply; 11+ messages in thread
From: Jens Axboe @ 2018-12-16 16:07 UTC (permalink / raw)
  To: Bart Van Assche, Ming Lei
  Cc: linux-block, Bart Van Assche, Omar Sandoval, Christoph Hellwig,
	Josef Bacik

On 12/14/18 12:15 PM, Bart Van Assche wrote:
> On Fri, 2018-12-14 at 19:39 +0800, Ming Lei wrote:
>> This information is helpful to either investigate issues, or understand
>> wbt's internal behaviour.
>>
>> Cc: Bart Van Assche <bart.vanassche@wdc.com>
>> Cc: Omar Sandoval <osandov@fb.com>
>> Cc: Christoph Hellwig <hch@lst.de>
>> Cc: Josef Bacik <josef@toxicpanda.com>
>> Signed-off-by: Ming Lei <ming.lei@redhat.com>
>> ---
>>  block/blk-wbt.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 91 insertions(+)
>>
>> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
>> index 463e4eb80287..2684bf2d112f 100644
>> --- a/block/blk-wbt.c
>> +++ b/block/blk-wbt.c
>> @@ -715,6 +715,94 @@ void wbt_disable_default(struct request_queue *q)
>>  }
>>  EXPORT_SYMBOL_GPL(wbt_disable_default);
>>  
>> +#ifdef CONFIG_BLK_DEBUG_FS
>> +static int wbt_curr_window_show(void *data, struct seq_file *m)
>> +{
>> +	struct rq_qos *rqos = data;
>> +	struct rq_wb *rwb = RQWB(rqos);
>> +
>> +	seq_printf(m, "%llu ns\n", rwb->cur_win_nsec);
>> +	return 0;
>> +}
> 
> Please consider to embed the unit ("ns") in the attribute name instead of
> in the attribute value. That will make it easier to process this attribute
> in developer debug scripts.
> 
>> +static int wbt_min_latency_show(void *data, struct seq_file *m)
>> +{
>> +	struct rq_qos *rqos = data;
>> +	struct rq_wb *rwb = RQWB(rqos);
>> +
>> +	seq_printf(m, "%luns\n", rwb->min_lat_nsec);
>> +	return 0;
>> +}
> 
> Same comment here about the unit.
> 
>> +static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
>> +	{"curr_window", 0400, wbt_curr_window_show},
>> +	{"enable_state", 0400, wbt_enable_state_show},
> 
> How about using "enabled" instead of "enable_state"?

Agree on all of these. Ming, I had to amend so I dropped the previous
commits, so I could also drop the compilation fixup for
!CONFIG_BLK_DEBUG_FS. Can you resend with those fixed, and also apply
this incremental?

diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
index fd8a0c5debd3..210567ddfa40 100644
--- a/block/blk-rq-qos.h
+++ b/block/blk-rq-qos.h
@@ -40,9 +40,7 @@ struct rq_qos_ops {
 	void (*done_bio)(struct rq_qos *, struct bio *);
 	void (*cleanup)(struct rq_qos *, struct bio *);
 	void (*exit)(struct rq_qos *);
-#ifdef CONFIG_BLK_DEBUG_FS
 	const struct blk_mq_debugfs_attr *debugfs_attrs;
-#endif
 };
 
 struct rq_depth {

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] blk-mq-debugfs: support rq_qos
  2018-12-16 16:04     ` Jens Axboe
@ 2018-12-16 16:09       ` Christoph Hellwig
  2018-12-16 16:13         ` Jens Axboe
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2018-12-16 16:09 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Bart Van Assche, Ming Lei, linux-block, Bart Van Assche,
	Omar Sandoval, Christoph Hellwig, Josef Bacik

On Sun, Dec 16, 2018 at 09:04:37AM -0700, Jens Axboe wrote:
> It would fit better with the style in that code do to:
> 
> rqos = q->rq_qos;
> while (rqos) {
>     ....
>     rqos = rqos->next;
> }

But that is just a really strangly written for loop to start with..

Maybe Bart need to send a cleanup patch for the whole file, especially
given that this patch has been applied already.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] blk-mq-debugfs: support rq_qos
  2018-12-16 16:09       ` Christoph Hellwig
@ 2018-12-16 16:13         ` Jens Axboe
  0 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2018-12-16 16:13 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bart Van Assche, Ming Lei, linux-block, Bart Van Assche,
	Omar Sandoval, Josef Bacik

On 12/16/18 9:09 AM, Christoph Hellwig wrote:
> On Sun, Dec 16, 2018 at 09:04:37AM -0700, Jens Axboe wrote:
>> It would fit better with the style in that code do to:
>>
>> rqos = q->rq_qos;
>> while (rqos) {
>>     ....
>>     rqos = rqos->next;
>> }
> 
> But that is just a really strangly written for loop to start with..

I think it looks fine, and it's more readable than using a for()
loop for something like this.

> Maybe Bart need to send a cleanup patch for the whole file, especially
> given that this patch has been applied already.

As mentioned in the same thread, I dropped these since I had to
amend a commit anyway. So we're free to do whatever.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] blk-wbt: export internal state via debugfs
  2018-12-16 16:07     ` Jens Axboe
@ 2018-12-17  1:10       ` Ming Lei
  0 siblings, 0 replies; 11+ messages in thread
From: Ming Lei @ 2018-12-17  1:10 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Bart Van Assche, linux-block, Bart Van Assche, Omar Sandoval,
	Christoph Hellwig, Josef Bacik

On Sun, Dec 16, 2018 at 09:07:38AM -0700, Jens Axboe wrote:
> On 12/14/18 12:15 PM, Bart Van Assche wrote:
> > On Fri, 2018-12-14 at 19:39 +0800, Ming Lei wrote:
> >> This information is helpful to either investigate issues, or understand
> >> wbt's internal behaviour.
> >>
> >> Cc: Bart Van Assche <bart.vanassche@wdc.com>
> >> Cc: Omar Sandoval <osandov@fb.com>
> >> Cc: Christoph Hellwig <hch@lst.de>
> >> Cc: Josef Bacik <josef@toxicpanda.com>
> >> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> >> ---
> >>  block/blk-wbt.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>  1 file changed, 91 insertions(+)
> >>
> >> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> >> index 463e4eb80287..2684bf2d112f 100644
> >> --- a/block/blk-wbt.c
> >> +++ b/block/blk-wbt.c
> >> @@ -715,6 +715,94 @@ void wbt_disable_default(struct request_queue *q)
> >>  }
> >>  EXPORT_SYMBOL_GPL(wbt_disable_default);
> >>  
> >> +#ifdef CONFIG_BLK_DEBUG_FS
> >> +static int wbt_curr_window_show(void *data, struct seq_file *m)
> >> +{
> >> +	struct rq_qos *rqos = data;
> >> +	struct rq_wb *rwb = RQWB(rqos);
> >> +
> >> +	seq_printf(m, "%llu ns\n", rwb->cur_win_nsec);
> >> +	return 0;
> >> +}
> > 
> > Please consider to embed the unit ("ns") in the attribute name instead of
> > in the attribute value. That will make it easier to process this attribute
> > in developer debug scripts.
> > 
> >> +static int wbt_min_latency_show(void *data, struct seq_file *m)
> >> +{
> >> +	struct rq_qos *rqos = data;
> >> +	struct rq_wb *rwb = RQWB(rqos);
> >> +
> >> +	seq_printf(m, "%luns\n", rwb->min_lat_nsec);
> >> +	return 0;
> >> +}
> > 
> > Same comment here about the unit.
> > 
> >> +static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
> >> +	{"curr_window", 0400, wbt_curr_window_show},
> >> +	{"enable_state", 0400, wbt_enable_state_show},
> > 
> > How about using "enabled" instead of "enable_state"?
> 
> Agree on all of these. Ming, I had to amend so I dropped the previous
> commits, so I could also drop the compilation fixup for
> !CONFIG_BLK_DEBUG_FS. Can you resend with those fixed, and also apply
> this incremental?

OK.

Thanks,
Ming

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-12-17  1:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 11:39 [PATCH 0/2] block: support debugfs on rq_qos & wbt Ming Lei
2018-12-14 11:39 ` [PATCH 1/2] blk-mq-debugfs: support rq_qos Ming Lei
2018-12-14 19:11   ` Bart Van Assche
2018-12-16 16:04     ` Jens Axboe
2018-12-16 16:09       ` Christoph Hellwig
2018-12-16 16:13         ` Jens Axboe
2018-12-14 11:39 ` [PATCH 2/2] blk-wbt: export internal state via debugfs Ming Lei
2018-12-14 19:15   ` Bart Van Assche
2018-12-16 16:07     ` Jens Axboe
2018-12-17  1:10       ` Ming Lei
2018-12-14 12:56 ` [PATCH 0/2] block: support debugfs on rq_qos & wbt Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.