diff mbox

blk-mq-debugfs: add mapping show for hw queue to cpu

Message ID 20170712165400.GA9696@localhost.didichuxing.com (mailing list archive)
State New, archived
Headers show

Commit Message

weiping zhang July 12, 2017, 4:54 p.m. UTC
A mapping show as following:

hctx		cpus
hctx0		  0   1
hctx1		  2
hctx2		  3
hctx3		  4   5

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 block/blk-mq-debugfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Jens Axboe July 12, 2017, 4:57 p.m. UTC | #1
On 07/12/2017 10:54 AM, weiping zhang wrote:
> A mapping show as following:
> 
> hctx		cpus
> hctx0		  0   1
> hctx1		  2
> hctx2		  3
> hctx3		  4   5

We already have that information in the /sys/block/<dev>/mq/X/cpu_list

where X is the hardware queue number. Why do we need it in debugfs as
well, presented differently?
weiping zhang July 12, 2017, 5:13 p.m. UTC | #2
On Wed, Jul 12, 2017 at 10:57:37AM -0600, Jens Axboe wrote:
> On 07/12/2017 10:54 AM, weiping zhang wrote:
> > A mapping show as following:
> > 
> > hctx		cpus
> > hctx0		  0   1
> > hctx1		  2
> > hctx2		  3
> > hctx3		  4   5
> 
> We already have that information in the /sys/block/<dev>/mq/X/cpu_list
> 
> where X is the hardware queue number. Why do we need it in debugfs as
> well, presented differently?

this arribute give a more obviously showing, only by 1 "cat" command.
/sys/bloc/<dev>/mq/X/cpu_list not easy get mapping for all hctx by 1
command.
also /sys/kernel/debug/block/xxx/hctxN/cpuX can export that info, but
these two methods both not obviously.
Jens Axboe July 12, 2017, 5:25 p.m. UTC | #3
On 07/12/2017 11:13 AM, weiping zhang wrote:
> On Wed, Jul 12, 2017 at 10:57:37AM -0600, Jens Axboe wrote:
>> On 07/12/2017 10:54 AM, weiping zhang wrote:
>>> A mapping show as following:
>>>
>>> hctx		cpus
>>> hctx0		  0   1
>>> hctx1		  2
>>> hctx2		  3
>>> hctx3		  4   5
>>
>> We already have that information in the /sys/block/<dev>/mq/X/cpu_list
>>
>> where X is the hardware queue number. Why do we need it in debugfs as
>> well, presented differently?
> 
> this arribute give a more obviously showing, only by 1 "cat" command.
> /sys/bloc/<dev>/mq/X/cpu_list not easy get mapping for all hctx by 1
> command.
> also /sys/kernel/debug/block/xxx/hctxN/cpuX can export that info, but
> these two methods both not obviously.

The point is the information is there, and I'm sure most people can
work out the shell logic to collect this info. I see zero benefit to
adding this to debugfs.
weiping zhang July 13, 2017, 2:09 p.m. UTC | #4
On Wed, Jul 12, 2017 at 11:25:12AM -0600, Jens Axboe wrote:
> On 07/12/2017 11:13 AM, weiping zhang wrote:
> > On Wed, Jul 12, 2017 at 10:57:37AM -0600, Jens Axboe wrote:
> >> On 07/12/2017 10:54 AM, weiping zhang wrote:
> >>> A mapping show as following:
> >>>
> >>> hctx		cpus
> >>> hctx0		  0   1
> >>> hctx1		  2
> >>> hctx2		  3
> >>> hctx3		  4   5
> >>
> >> We already have that information in the /sys/block/<dev>/mq/X/cpu_list
> >>
> >> where X is the hardware queue number. Why do we need it in debugfs as
> >> well, presented differently?
> > 
> > this arribute give a more obviously showing, only by 1 "cat" command.
> > /sys/bloc/<dev>/mq/X/cpu_list not easy get mapping for all hctx by 1
> > command.
> > also /sys/kernel/debug/block/xxx/hctxN/cpuX can export that info, but
> > these two methods both not obviously.
> 
> The point is the information is there, and I'm sure most people can
> work out the shell logic to collect this info. I see zero benefit to
> adding this to debugfs.
> 

Hi Jens,

It seems no other people wanna this patch, please skip it, thanks for
your replay ^_^.

--
weiping
diff mbox

Patch

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 9ebc294..a311d5a 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -175,6 +175,23 @@  static int queue_poll_stat_show(void *data, struct seq_file *m)
 	return 0;
 }
 
+static int queue_mapping_show(void *data, struct seq_file *m)
+{
+       struct request_queue *q = data;
+       struct blk_mq_hw_ctx *hctx;
+       struct blk_mq_ctx *ctx;
+       int i, j;
+
+       seq_puts(m, "hctx\t\tcpus\n");
+       queue_for_each_hw_ctx(q, hctx, i) {
+               seq_printf(m, "hctx%u\t\t", hctx->queue_num);
+               hctx_for_each_ctx(hctx, ctx, j)
+                       seq_printf(m, "%3u ", ctx->cpu);
+               seq_puts(m, "\n");
+       }
+       return 0;
+}
+
 #define HCTX_STATE_NAME(name) [BLK_MQ_S_##name] = #name
 static const char *const hctx_state_name[] = {
 	HCTX_STATE_NAME(STOPPED),
@@ -754,6 +771,7 @@  static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = {
 	{"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},
+	{"mapping", 0400, queue_mapping_show},
 	{},
 };