Skip to content

Commit

Permalink
blk-mq: add hctx->restart to blk-mq debugfs
Browse files Browse the repository at this point in the history
This info is useful to diagnose either IO hang or performance issue
related with blk-mq restart mechanism.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
  • Loading branch information
Ming Lei committed Jan 18, 2018
1 parent 6c4f43d commit dfd672c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions block/blk-mq-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,23 @@ static ssize_t hctx_run_write(void *data, const char __user *buf, size_t count,
return count;
}

static int hctx_restart_show(void *data, struct seq_file *m)
{
struct blk_mq_hw_ctx *hctx = data;

seq_printf(m, "%lu\n", hctx->restart);
return 0;
}

static ssize_t hctx_restart_write(void *data, const char __user *buf,
size_t count, loff_t *ppos)
{
struct blk_mq_hw_ctx *hctx = data;

hctx->restart = 0;
return count;
}

static int hctx_active_show(void *data, struct seq_file *m)
{
struct blk_mq_hw_ctx *hctx = data;
Expand Down Expand Up @@ -765,6 +782,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = {
{"dispatched", 0600, hctx_dispatched_show, hctx_dispatched_write},
{"queued", 0600, hctx_queued_show, hctx_queued_write},
{"run", 0600, hctx_run_show, hctx_run_write},
{"restart", 0600, hctx_restart_show, hctx_restart_write},
{"active", 0400, hctx_active_show},
{},
};
Expand Down
7 changes: 6 additions & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,8 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
* that is where we will continue on next queue run.
*/
if (!list_empty(list)) {
bool needs_restart;

spin_lock(&hctx->lock);
list_splice_init(list, &hctx->dispatch);
spin_unlock(&hctx->lock);
Expand All @@ -1281,9 +1283,12 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
* returning BLK_STS_RESOURCE. Two exceptions are scsi-mq
* and dm-rq.
*/
if (!blk_mq_sched_needs_restart(hctx) ||
needs_restart = blk_mq_sched_needs_restart(hctx);
if (!needs_restart ||
(no_tag && list_empty_careful(&hctx->dispatch_wait.entry)))
blk_mq_run_hw_queue(hctx, true);
else if (needs_restart)
hctx->restart++;
}

return (queued + errors) != 0;
Expand Down
1 change: 1 addition & 0 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct blk_mq_hw_ctx {

unsigned long queued;
unsigned long run;
unsigned long restart;
#define BLK_MQ_MAX_DISPATCH_ORDER 7
unsigned long dispatched[BLK_MQ_MAX_DISPATCH_ORDER];

Expand Down

0 comments on commit dfd672c

Please sign in to comment.