Avoid that scsi-mq and dm-mq queue processing stalls sporadically
Subsystems (3)
v4 cover Avoid that scsi-mq and dm-mq queue processing stalls sporadically
Hello Jens,
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
Thanks,
Bart.
Changes between v3 and v4:
- Addressed the review comments on version three of this series about the patch that makes it safe to use RCU to iterate over .tag_list and also about the runtime performance and use of short variable names in patch 2/5.
- Clarified the description of the patch that fixes the scsi-mq stall.
- Added a patch to fix a dm-mq queue stall.
Changes between v2 and v3:
- Removed the blk_mq_ops.restart_hctx function pointer again.
- Modified blk_mq_sched_restart_queues() such that only a single hardware queue is restarted instead of multiple if hardware queues are shared.
- Introduced a new function in the block layer, namely blk_mq_delay_run_hw_queue().
Changes between v1 and v2:
- Reworked scsi_restart_queues() such that it no longer takes the SCSI host lock.
- Added two patches - one for exporting blk_mq_sched_restart_hctx() and another one to make iterating with RCU over blk_mq_tag_set.tag_list safe.
Bart Van Assche (6):
blk-mq: Make it safe to use RCU to iterate over
blk_mq_tag_set.tag_list
blk-mq: Restart a single queue if tag sets are shared
blk-mq: Clarify comments in blk_mq_dispatch_rq_list()
blk-mq: Introduce blk_mq_delay_run_hw_queue()
scsi: Avoid that SCSI queues get stuck
dm rq: Avoid that request processing stalls sporadically
block/blk-mq-sched.c | 63 +++++++++++++++++++++++++++++++++++------- block/blk-mq-sched.h | 16 +---------- block/blk-mq.c | 73 +++++++++++++++++++++++++++++++++++++++---------- drivers/md/dm-rq.c | 1 + drivers/scsi/scsi_lib.c | 6 ++-- include/linux/blk-mq.h | 2 ++ include/linux/blkdev.h | 1 - 7 files changed, 118 insertions(+), 44 deletions(-)
Signature · 1 line
2.12.0
PATCH v4 1/6 blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list
Since the next patch in this series will use RCU to iterate over tag_list, make this safe. Add lockdep_assert_held() statements in functions that iterate over tag_list to make clear that using list_for_each_entry() instead of list_for_each_entry_rcu() is fine in these functions.
--- block/blk-mq.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
block/blk-mq.c +9 -2
@@ -2076,6 +2076,8 @@ static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set, bool shared) {struct request_queue *q; +lockdep_assert_held (&set->tag_list_lock); +list_for_each_entry (q, &set->tag_list, tag_set_list) {blk_mq_freeze_queue (q);queue_set_hctx_shared (q, shared);
@@ -2088,7 +2090,8 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)struct blk_mq_tag_set *set = q->tag_set;mutex_lock (&set->tag_list_lock); -list_del_init (&q->tag_set_list); +list_del_rcu (&q->tag_set_list); +INIT_LIST_HEAD (&q->tag_set_list);if (list_is_singular (&set->tag_list)) {/* just transitioned to unshared */ set->flags &= ~BLK_MQ_F_TAG_SHARED ;
@@ -2096,6 +2099,8 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)blk_mq_update_tag_set_depth (set, false); }mutex_unlock (&set->tag_list_lock); + +synchronize_rcu (); } static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
@@ -2113,7 +2118,7 @@ static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set, }if (set->flags &BLK_MQ_F_TAG_SHARED )queue_set_hctx_shared (q, true); -list_add_tail (&q->tag_set_list, &set->tag_list); +list_add_tail_rcu (&q->tag_set_list, &set->tag_list);mutex_unlock (&set->tag_list_lock); }
@@ -2601,6 +2606,8 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues) {struct request_queue *q; +lockdep_assert_held (&set->tag_list_lock); +if (nr_hw_queues > nr_cpu_ids) nr_hw_queues = nr_cpu_ids;if (nr_hw_queues <1 || nr_hw_queues == set->nr_hw_queues)
Signature · 1 line
2.12.0
Re: [PATCH v4 1/6] blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list
Looks good,
PATCH v4 2/6 blk-mq: Restart a single queue if tag sets are shared
In reply to Bart Van AsscheTo improve scalability, if hardware queues are shared, restart a single hardware queue in round-robin fashion. Rename blk_mq_sched_restart_queues() to reflect the new semantics. Remove blk_mq_sched_mark_restart_queue() because this function has no callers. Remove flag QUEUE_FLAG_RESTART because this patch removes the code that uses this flag.
--- block/blk-mq-sched.c | 63 ++++++++++++++++++++++++++++++++++++++++++-------- block/blk-mq-sched.h | 16 +------------ block/blk-mq.c | 2 +- include/linux/blkdev.h | 1 - 4 files changed, 55 insertions(+), 27 deletions(-)
block/blk-mq-sched.c +53 -10
@@ -317,25 +317,68 @@ static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,return true; } -static void blk_mq_sched_restart_hctx (struct blk_mq_hw_ctx *hctx) +static bool blk_mq_sched_restart_hctx (struct blk_mq_hw_ctx *hctx) {if (test_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state)) {clear_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state); -if (blk_mq_hctx_has_pending (hctx)) +if (blk_mq_hctx_has_pending (hctx)) {blk_mq_run_hw_queue (hctx, true); +return true; + } } +return false; } -void blk_mq_sched_restart_queues (struct blk_mq_hw_ctx *hctx) -{ -struct request_queue *q = hctx->queue; -unsigned int i; +/** +* list_for_each_entry_rcu_rr - iterate in a round-robin fashion over rcu list +* @pos: loop cursor. +* @skip: the list element that will not be examined. Iteration starts at +* @skip->next. +* @head: head of the list to examine. This list must have at least one +* element, namely @skip. +* @member: name of the list_head structure within typeof(*pos). +*/ +#define list_for_each_entry_rcu_rr (pos, skip, head, member) \ + for ((pos) = (skip); \ + (pos = (pos)->member.next != (head) ? list_entry_rcu( \ + (pos)->member.next, typeof(*pos), member) : \ + list_entry_rcu((pos)->member.next->next, typeof(*pos), member)), \ + (pos) != (skip); ) -if (test_bit (QUEUE_FLAG_RESTART , &q->queue_flags)) { -if (test_and_clear_bit (QUEUE_FLAG_RESTART , &q->queue_flags)) { -queue_for_each_hw_ctx (q, hctx, i) -blk_mq_sched_restart_hctx (hctx); +/* +* Called after a driver tag has been freed to check whether a hctx needs to +* be restarted. Restarts @hctx if its tag set is not shared. Restarts hardware +* queues in a round-robin fashion if the tag set of @hctx is shared with other +* hardware queues. +*/ +void blk_mq_sched_restart (struct blk_mq_hw_ctx *const hctx) +{ +struct blk_mq_tags *const tags = hctx->tags; +struct blk_mq_tag_set *const set = hctx->queue->tag_set; +struct request_queue *const queue = hctx->queue, *q; +struct blk_mq_hw_ctx *hctx2; +unsigned int i, j; + +if (set->flags &BLK_MQ_F_TAG_SHARED ) { +rcu_read_lock (); +list_for_each_entry_rcu_rr (q, queue, &set->tag_list, + tag_set_list) { +queue_for_each_hw_ctx (q, hctx2, i) +if (hctx2->tags == tags && +blk_mq_sched_restart_hctx (hctx2)) + goto done; + } + j = hctx->queue_num +1 ; +for (i =0 ; i < queue->nr_hw_queues; i++, j++) { +if (j == queue->nr_hw_queues) + j =0 ; + hctx2 = queue->queue_hw_ctx[j]; +if (hctx2->tags == tags && +blk_mq_sched_restart_hctx (hctx2)) +break ; } +done: +rcu_read_unlock (); }else {blk_mq_sched_restart_hctx (hctx); }
block/blk-mq-sched.h +1 -15
@@ -19,7 +19,7 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, struct request **merged_request);bool __blk_mq_sched_bio_merge (struct request_queue *q,struct bio *bio);bool blk_mq_sched_try_insert_merge (struct request_queue *q,struct request *rq); -void blk_mq_sched_restart_queues (struct blk_mq_hw_ctx *hctx); +void blk_mq_sched_restart (struct blk_mq_hw_ctx *hctx);void blk_mq_sched_insert_request (struct request *rq,bool at_head,bool run_queue,bool async,bool can_block);
@@ -131,20 +131,6 @@ static inline void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx)set_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state); } -/* -* Mark a hardware queue and the request queue it belongs to as needing a -* restart. -*/ -static inline void blk_mq_sched_mark_restart_queue (struct blk_mq_hw_ctx *hctx) -{ -struct request_queue *q = hctx->queue; - -if (!test_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state)) -set_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state); -if (!test_bit (QUEUE_FLAG_RESTART , &q->queue_flags)) -set_bit (QUEUE_FLAG_RESTART , &q->queue_flags); -} -static inline bool blk_mq_sched_needs_restart (struct blk_mq_hw_ctx *hctx) {return test_bit (BLK_MQ_S_SCHED_RESTART , &hctx->state);
block/blk-mq.c +1 -1
@@ -351,7 +351,7 @@ void __blk_mq_finish_request(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,blk_mq_put_tag (hctx, hctx->tags, ctx, rq->tag);if (sched_tag !=-1 )blk_mq_sched_completed_request (hctx, rq); -blk_mq_sched_restart_queues (hctx); +blk_mq_sched_restart (hctx);blk_queue_exit (q); }
include/linux/blkdev.h +0 -1
@@ -615,7 +615,6 @@ struct request_queue {#define QUEUE_FLAG_FLUSH_NQ 25/* flush not queueuable */ #define QUEUE_FLAG_DAX 26/* device supports DAX */ #define QUEUE_FLAG_STATS 27/* track rq completion times */ -#define QUEUE_FLAG_RESTART 28/* queue needs restart at completion */ #define QUEUE_FLAG_POLL_STATS 29/* collecting stats for hybrid polling */ #define QUEUE_FLAG_REGISTERED 30/* queue has been registered to a disk */
Signature · 1 line
2.12.0
Re: [PATCH v4 2/6] blk-mq: Restart a single queue if tag sets are shared
Looks good,
PATCH v4 3/6 blk-mq: Clarify comments in blk_mq_dispatch_rq_list()
In reply to Bart Van AsscheThe blk_mq_dispatch_rq_list() implementation got modified several times but the comments in that function were not updated every time. Since it is nontrivial what is going on, update the comments in blk_mq_dispatch_rq_list().
--- block/blk-mq.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
block/blk-mq.c +18 -10
@@ -1063,8 +1063,8 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)*/ if (!list_empty (list)) {/* -* If we got a driver tag for the next request already, -* free it again. +* If an I/O scheduler has been configured and we got a driver +* tag for the next request already, free it again. */ rq = list_first_entry(list, struct request, queuelist);blk_mq_put_driver_tag (rq);
@@ -1074,16 +1074,24 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)spin_unlock (&hctx->lock);/* -* the queue is expected stopped with BLK_MQ_RQ_QUEUE_BUSY, but -* it's possible the queue is stopped and restarted again -* before this. Queue restart will dispatch requests. And since -* requests in rq_list aren't added into hctx->dispatch yet, -* the requests in rq_list might get lost. +* If SCHED_RESTART was set by the caller of this function and +* it is no longer set that means that it was cleared by another +* thread and hence that a queue rerun is needed. * -* blk_mq_run_hw_queue() already checks the STOPPED bit +* If TAG_WAITING is set that means that an I/O scheduler has +* been configured and another thread is waiting for a driver +* tag. To guarantee fairness, do not rerun this hardware queue +* but let the other thread grab the driver tag. * -* If RESTART or TAG_WAITING is set, then let completion restart -* the queue instead of potentially looping here. +* If no I/O scheduler has been configured it is possible that +* the hardware queue got stopped and restarted before requests +* were pushed back onto the dispatch list. Rerun the queue to +* avoid starvation. Notes: +* - blk_mq_run_hw_queue() checks whether or not a queue has +* been stopped before rerunning a queue. +* - Some but not all block drivers stop a queue before +* returning BLK_MQ_RQ_QUEUE_BUSY. Two exceptions are scsi-mq +* and dm-rq. */ if (!blk_mq_sched_needs_restart (hctx) && !test_bit (BLK_MQ_S_TAG_WAITING , &hctx->state))
Signature · 1 line
2.12.0
Re: [PATCH v4 3/6] blk-mq: Clarify comments in blk_mq_dispatch_rq_list()
Looks good,
PATCH v4 4/6 blk-mq: Introduce blk_mq_delay_run_hw_queue()
In reply to Bart Van AsscheIntroduce a function that runs a hardware queue unconditionally after a delay. Note: there is already a function that stops and restarts a hardware queue after a delay, namely blk_mq_delay_queue().
This function will be used in the next patch in this series.
--- block/blk-mq.c | 32 ++++++++++++++++++++++++++++++-- include/linux/blk-mq.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-)
block/blk-mq.c +30 -2
@@ -1146,7 +1146,8 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)return hctx->next_cpu; } -void blk_mq_run_hw_queue (struct blk_mq_hw_ctx *hctx,bool async) +static void __blk_mq_delay_run_hw_queue (struct blk_mq_hw_ctx *hctx,bool async, +unsigned long msecs) {if (unlikely (blk_mq_hctx_stopped (hctx) || !blk_mq_hw_queue_mapped (hctx)))
@@ -1163,7 +1164,24 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)put_cpu (); } -kblockd_schedule_work_on (blk_mq_hctx_next_cpu (hctx), &hctx->run_work); +if (msecs ==0 ) +kblockd_schedule_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->run_work); +else +kblockd_schedule_delayed_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->delayed_run_work, +msecs_to_jiffies (msecs)); +} + +void blk_mq_delay_run_hw_queue (struct blk_mq_hw_ctx *hctx,unsigned long msecs) +{ +__blk_mq_delay_run_hw_queue (hctx, true, msecs); +} +EXPORT_SYMBOL (blk_mq_delay_run_hw_queue); + +void blk_mq_run_hw_queue (struct blk_mq_hw_ctx *hctx,bool async) +{ +__blk_mq_delay_run_hw_queue (hctx, async,0 ); }void blk_mq_run_hw_queues (struct request_queue *q,bool async)
@@ -1266,6 +1284,15 @@ static void blk_mq_run_work_fn(struct work_struct *work)__blk_mq_run_hw_queue (hctx); } +static void blk_mq_delayed_run_work_fn (struct work_struct *work) +{ +struct blk_mq_hw_ctx *hctx; + + hctx = container_of(work, struct blk_mq_hw_ctx, delayed_run_work.work); + +__blk_mq_run_hw_queue (hctx); +} +static void blk_mq_delay_work_fn (struct work_struct *work) {struct blk_mq_hw_ctx *hctx;
@@ -1866,6 +1893,7 @@ static int blk_mq_init_hctx(struct request_queue *q, node = hctx->numa_node = set->numa_node;INIT_WORK (&hctx->run_work, blk_mq_run_work_fn); +INIT_DELAYED_WORK (&hctx->delayed_run_work, blk_mq_delayed_run_work_fn);INIT_DELAYED_WORK (&hctx->delay_work, blk_mq_delay_work_fn);spin_lock_init (&hctx->lock);INIT_LIST_HEAD (&hctx->dispatch);
include/linux/blk-mq.h +2 -0
@@ -51,6 +51,7 @@ struct blk_mq_hw_ctx {atomic_t nr_active; +struct delayed_work delayed_run_work;struct delayed_work delay_work;struct hlist_node cpuhp_dead;
@@ -236,6 +237,7 @@ void blk_mq_stop_hw_queues(struct request_queue *q);void blk_mq_start_hw_queues (struct request_queue *q);void blk_mq_start_stopped_hw_queue (struct blk_mq_hw_ctx *hctx,bool async);void blk_mq_start_stopped_hw_queues (struct request_queue *q,bool async); +void blk_mq_delay_run_hw_queue (struct blk_mq_hw_ctx *hctx,unsigned long msecs);void blk_mq_run_hw_queues (struct request_queue *q,bool async);void blk_mq_delay_queue (struct blk_mq_hw_ctx *hctx,unsigned long msecs); void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
Signature · 1 line
2.12.0
Re: [PATCH v4 4/6] blk-mq: Introduce blk_mq_delay_run_hw_queue()
block/blk-mq.c void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) · line 1174
Quoted 8 lines
block/blk-mq.c +8
-0+if (msecs ==0 ) +kblockd_schedule_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->run_work); +else +kblockd_schedule_delayed_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->delayed_run_work, +msecs_to_jiffies (msecs)); +}
I'd rather make run_work a delayed_work (again) and use kblockd_schedule_delayed_work_on with a timeout of zero for the immediate run case instead of having two competing work structs.
Jens Axboe
maintainerRe: [PATCH v4 4/6] blk-mq: Introduce blk_mq_delay_run_hw_queue()
Quoted 4 lines · Christoph Hellwig
Quoted 4 lines
block/blk-mq.c +4
-0+if (msecs ==0 ) +kblockd_schedule_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->run_work); +else
Quoted 8 lines
block/blk-mq.c void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) · line 1174
Quoted 4 lines
block/blk-mq.c +4
-0+kblockd_schedule_delayed_work_on (blk_mq_hctx_next_cpu (hctx), + &hctx->delayed_run_work, +msecs_to_jiffies (msecs)); +}I'd rather make
run_workadelayed_work(again) and usekblockd_schedule_delayed_work_onwith a timeout of zero for the immediate run case instead of having two competing work structs.
Yeah that's a good point, it'd have to be an incremental patch at this point though. Also note that blk_mq_stop_hw_queue() isn't currently canceling the new ->delayed_run_work, that looks like a bug.
And looking at it, right now we have 3 (three!) work items in the hardware queue. The two delayed items differ in that one of them only runs the queue it was previously stopped, that's it. The non-delayed one is identical to the non stopped checking delayed variant.
I'll send out a patch.
Signature · 1 line
Jens Axboe
PATCH v4 5/6 scsi: Avoid that SCSI queues get stuck
In reply to Bart Van AsscheIf a .queue_rq() function returns BLK_MQ_RQ_QUEUE_BUSY then the block driver that implements that function is responsible for rerunning the hardware queue once requests can be queued again successfully.
commit 52d7f1b5c2f3 ("blk-mq: Avoid that requeueing starts stopped queues") removed the blk_mq_stop_hw_queue() call from scsi_queue_rq() for the BLK_MQ_RQ_QUEUE_BUSY case. Hence change all calls to functions that are intended to rerun a busy queue such that these examine all hardware queues instead of only stopped queues.
Since no other functions than scsi_internal_device_block() and scsi_internal_device_unblock() should ever stop or restart a SCSI queue, change the blk_mq_delay_queue() call into a blk_mq_delay_run_hw_queue() call.
--- drivers/scsi/scsi_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/scsi_lib.c +3 -3
@@ -496,7 +496,7 @@ static void scsi_run_queue(struct request_queue *q)scsi_starved_list_run (sdev->host);if (q->mq_ops) -blk_mq_start_stopped_hw_queues (q, false); +blk_mq_run_hw_queues (q, false);else blk_run_queue (q); }
@@ -667,7 +667,7 @@ static bool scsi_end_request(struct request *req, int error, !list_empty(&sdev->host->starved_list))kblockd_schedule_work (&sdev->requeue_work); else -blk_mq_start_stopped_hw_queues (q ,true ); +blk_mq_run_hw_queues (q ,true ); }else {unsigned long flags;
@@ -1974,7 +1974,7 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx,case BLK_MQ_RQ_QUEUE_BUSY :if (atomic_read (&sdev->device_busy) ==0 && !scsi_device_blocked (sdev)) -blk_mq_delay_queue (hctx,SCSI_QUEUE_DELAY ); +blk_mq_delay_run_hw_queue (hctx,SCSI_QUEUE_DELAY );break ;case BLK_MQ_RQ_QUEUE_ERROR :/*
Signature · 1 line
2.12.0
Re: [PATCH v4 5/6] scsi: Avoid that SCSI queues get stuck
Looks good,
PATCH v4 6/6 dm rq: Avoid that request processing stalls sporadically
In reply to Bart Van AsscheWhile running the srp-test software I noticed that request processing stalls sporadically at the beginning of a test, namely when mkfs is run against a dm-mpath device. Every time when that happened the following command was sufficient to resume request processing:
echo run >/sys/kernel/debug/block/dm-0/state
This patch avoids that such request processing stalls occur. The test I ran is as follows:
while srp-test/run_tests -d -r 30 -t 02-mq; do :; done
--- drivers/md/dm-rq.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-rq.c +1 -0
@@ -755,6 +755,7 @@ static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,/* Undo dm_start_request() before requeuing */ rq_end_stats (md, rq);rq_completed (md,rq_data_dir (rq), false); +blk_mq_delay_run_hw_queue (hctx,100 /*ms*/ );return BLK_MQ_RQ_QUEUE_BUSY ; }
Signature · 1 line
2.12.0
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 35 lines · Bart Van Assche
While running the srp-test software I noticed that request processing stalls sporadically at the beginning of a test, namely when mkfs is run against a dm-mpath device. Every time when that happened the following command was sufficient to resume request processing:
echo run >/sys/kernel/debug/block/dm-0/state
This patch avoids that such request processing stalls occur. The test I ran is as follows:
while srp-test/run_tests -d -r 30 -t 02-mq; do :; doneSigned-off-by Bart Van Assche <[email protected]>Cc Mike Snitzer <[email protected]>--- drivers/md/dm-rq.c | 1 + 1 file changed, 1 insertion(+)drivers/md/dm-rq.c +1
-0@@ -755,6 +755,7 @@ static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,/* Undo dm_start_request() before requeuing */ rq_end_stats (md, rq);rq_completed (md,rq_data_dir (rq), false); +blk_mq_delay_run_hw_queue (hctx,100 /*ms*/ );return BLK_MQ_RQ_QUEUE_BUSY ; }Signature · 1 line
2.12.0
I really appreciate your hard work Bart but this looks like a cheap hack.
I'm clearly too late to stop this from going in (given Jens got it merged for -rc6) but: this has no place in dm-mq (or any blk-mq driver). If it is needed it should be elevated to blk-mq core to trigger blk_mq_delay_run_hw_queue() when BLK_MQ_RQ_QUEUE_BUSY is returned from blk_mq_ops' .queue_rq.
If this dm-mq specific commit is justified the case certainly is spelled out in the commit header.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 4 lines · Mike Snitzer
This has no place in dm-mq (or any blk-mq
driver). If it is needed it should be elevated to blk-mq core to triggerblk_mq_delay_run_hw_queue()whenBLK_MQ_RQ_QUEUE_BUSYis returned fromblk_mq_ops' .queue_rq.
Hello Mike,
If the blk-mq core would have to figure out whether or not a queue is no longer busy without any cooperation from the blk-mq driver all the blk-mq core could do is to attempt to rerun that queue from time to time. But at which intervals should the blk-mq core check whether or not a queue is still busy? Would it be possible to choose intervals at which to check the queue state that work well for all block drivers? Consider e.g. at the dm-mpath driver. multipath_busy() returns true as long as path initialization is in progress. Path initialization can take a long time. The (indirect) call to blk_mq_run_queue() from pg_init_done() resumes request processing immediately after path initialization has finished. Sorry but I don't think it is possible to invent an algorithm for the blk-mq core that guarantees not only that a queue is rerun as soon as it is no longer busy but also that avoids that plenty of CPU cycles are wasted by the blk-mq core for checking whether a queue is no longer busy.
Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 8 lines · Bart Van Assche
Quoted 4 lines · Mike Snitzer
This has no place in dm-mq (or any blk-mq
driver). If it is needed it should be elevated to blk-mq core to triggerblk_mq_delay_run_hw_queue()whenBLK_MQ_RQ_QUEUE_BUSYis returned fromblk_mq_ops' .queue_rq.Hello Mike,
Quoted 14 lines
If the blk-mq core would have to figure out whether or not a queue is no longer busy without any cooperation from the blk-mq driver all the blk-mq core could do is to attempt to rerun that queue from time to time. But at which intervals should the blk-mq core check whether or not a queue is still busy? Would it be possible to choose intervals at which to check the queue state that work well for all block drivers? Consider e.g. at the dm-mpath driver.
multipath_busy()returns true as long as path initialization is in progress. Path initialization can take a long time. The (indirect) call toblk_mq_run_queue()frompg_init_done()resumes request processing immediately after path initialization has finished. Sorry but I don't think it is possible to invent an algorithm for the blk-mq core that guarantees not only that a queue is rerun as soon as it is no longer busy but also that avoids that plenty of CPU cycles are wasted by the blk-mq core for checking whether a queue is no longer busy.
Sorry but that isn't a very strong argument for what you've done.
I mean I do appreciate your point that the 2 BLK_MQ_RQ_QUEUE_BUSY returns in dm_mq_queue_rq() are not equal but that could easily be conveyed using a new return value.
Anyway, point is, no blk-mq driver should need to have concern about whether their request will get resubmitted (and the associated hw queue re-ran) if they return BLK_MQ_RQ_QUEUE_BUSY.
Your change is a means to an end but it just solves the problem in a very hackish way. Other drivers will very likely be caught about by this blk-mq quirk in the future.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 2 lines · Mike Snitzer
Other drivers will very likely be caught about by
this blk-mq quirk in the future.
Hello Mike,
Are you aware that the requirement that blk-mq drivers rerun the queue after having returned BLK_MQ_RQ_QUEUE_BUSY is a requirement that is shared with traditional block drivers? From dm_old_request_fn():
if (... || (ti->type->busy && ti->type->busy(ti))) {
blk_delay_queue(q, 10);
return;
}Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Mike Snitzer
Other drivers will very likely be caught about by
this blk-mq quirk in the future.Hello Mike,
Quoted 8 lines
Are you aware that the requirement that blk-mq drivers rerun the queue after having returned
BLK_MQ_RQ_QUEUE_BUSYis a requirement that is shared with traditional block drivers? Fromdm_old_request_fn():if (... || (ti->type->busy && ti->type->busy(ti))) { blk_delay_queue(q, 10); return; }
No, and pointing to DM code that does something with the old .request_fn case to justify why blk-mq requires the same is pretty specious.
Rather than working so hard to use DM code against me, your argument should be: "blk-mq drivers X, Y and Z rerun the hw queue; this is a well established pattern"
I see drivers/nvme/host/fc.c:nvme_fc_start_fcp_op() does. But that is only one other driver out of ~20 BLK_MQ_RQ_QUEUE_BUSY returns tree-wide.
Could be there are some others, but hardly a well-established pattern.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 9 lines · Mike Snitzer
Rather than working so hard to use DM code against me, your argument should be: "blk-mq drivers X, Y and Z rerun the hw queue; this is a well established pattern"
I see drivers/nvme/host/fc.c:nvme_fc_start_fcp_op() does. But that is only one other driver out of ~20
BLK_MQ_RQ_QUEUE_BUSYreturns tree-wide.Could be there are some others, but hardly a well-established pattern.
Hello Mike,
Several blk-mq drivers that can return BLK_MQ_RQ_QUEUE_BUSY from their .queue_rq() implementation stop the request queue (blk_mq_stop_hw_queue()) before returning "busy" and restart the queue after the busy condition has been cleared (blk_mq_start_stopped_hw_queues()). Examples are virtio_blk and xen-blkfront. However, this approach is not appropriate for the dm-mq core nor for the scsi core since both drivers already use the "stopped" state for another purpose than tracking whether or not a hardware queue is busy. Hence the blk_mq_delay_run_hw_queue() and blk_mq_run_hw_queue() calls in these last two drivers to rerun a hardware queue after the busy state has been cleared.
Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 13 lines · Bart Van Assche
Quoted 9 lines · Mike Snitzer
Rather than working so hard to use DM code against me, your argument should be: "blk-mq drivers X, Y and Z rerun the hw queue; this is a well established pattern"
I see drivers/nvme/host/fc.c:nvme_fc_start_fcp_op() does. But that is only one other driver out of ~20
BLK_MQ_RQ_QUEUE_BUSYreturns tree-wide.Could be there are some others, but hardly a well-established pattern.
Hello Mike,
Quoted 9 lines
Several blk-mq drivers that can return
BLK_MQ_RQ_QUEUE_BUSYfrom their .queue_rq() implementation stop the request queue (blk_mq_stop_hw_queue()) before returning "busy" and restart the queue after the busy condition has been cleared (blk_mq_start_stopped_hw_queues()). Examples arevirtio_blkand xen-blkfront. However, this approach is not appropriate for the dm-mq core nor for the scsi core since both drivers already use the "stopped" state for another purpose than tracking whether or not a hardware queue is busy. Hence theblk_mq_delay_run_hw_queue()andblk_mq_run_hw_queue()calls in these last two drivers to rerun a hardware queue after the busy state has been cleared.
But looks this patch just reruns the hw queue after 100ms, which isn't that after the busy state has been cleared, right?
Actually if BLK_MQ_RQ_QUEUE_BUSY is returned from .queue_rq(), blk-mq will buffer this request into hctx->dispatch and run the hw queue again, so looks blk_mq_delay_run_hw_queue() in this situation shouldn't have been needed at my 1st impression. Or maybe Bart has more stories about this usage, better to comments it?
Thanks,
Ming
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 24 lines · Ming Lei
Quoted 13 lines · Bart Van Assche
Quoted 9 lines · Mike Snitzer
Rather than working so hard to use DM code against me, your argument should be: "blk-mq drivers X, Y and Z rerun the hw queue; this is a well established pattern"
I see drivers/nvme/host/fc.c:nvme_fc_start_fcp_op() does. But that is only one other driver out of ~20
BLK_MQ_RQ_QUEUE_BUSYreturns tree-wide.Could be there are some others, but hardly a well-established pattern.
Hello Mike,
Quoted 9 lines
Several blk-mq drivers that can return
BLK_MQ_RQ_QUEUE_BUSYfrom their .queue_rq() implementation stop the request queue (blk_mq_stop_hw_queue()) before returning "busy" and restart the queue after the busy condition has been cleared (blk_mq_start_stopped_hw_queues()). Examples arevirtio_blkand xen-blkfront. However, this approach is not appropriate for the dm-mq core nor for the scsi core since both drivers already use the "stopped" state for another purpose than tracking whether or not a hardware queue is busy. Hence theblk_mq_delay_run_hw_queue()andblk_mq_run_hw_queue()calls in these last two drivers to rerun a hardware queue after the busy state has been cleared.
Quoted 2 lines
But looks this patch just reruns the hw queue after 100ms, which isn't that after the busy state has been cleared, right?
Hello Ming,
That patch can be considered as a first step that can be refined further, namely by modifying the dm-rq code further such that dm-rq queues are only rerun after the busy condition has been cleared. The patch at the start of this thread is easier to review and easier to test than any patch that would only rerun dm-rq queues after the busy condition has been cleared.
Quoted 4 lines
Actually if
BLK_MQ_RQ_QUEUE_BUSYis returned from .queue_rq(), blk-mq will buffer this request intohctx->dispatchand run the hw queue again, so looksblk_mq_delay_run_hw_queue()in this situation shouldn't have been needed at my 1st impression.
If the blk-mq core would always rerun a hardware queue if a block driver returns BLK_MQ_RQ_QUEUE_BUSY then that would cause 100% of a single CPU core to be busy with polling a hardware queue until the "busy" condition has been cleared. One can see easily that that's not what the blk-mq core does. From blk_mq_sched_dispatch_requests():
if (!list_empty(&rq_list)) {
blk_mq_sched_mark_restart_hctx(hctx);
did_work = blk_mq_dispatch_rq_list(q, &rq_list);
}From the end of blk_mq_dispatch_rq_list():
if (!list_empty(list)) {
[ ... ]
if (!blk_mq_sched_needs_restart(hctx) &&
!test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state))
blk_mq_run_hw_queue(hctx, true);
}In other words, the BLK_MQ_S_SCHED_RESTART flag is set before the dispatch list is examined and only if that flag gets cleared while blk_mq_dispatch_rq_list() is in progress by a concurrent blk_mq_sched_restart_hctx() call then the dispatch list will be rerun after a block driver returned BLK_MQ_RQ_QUEUE_BUSY.
Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 28 lines · Bart Van Assche
Quoted 24 lines · Ming Lei
Quoted 13 lines · Bart Van Assche
Quoted 9 lines · Mike Snitzer
Rather than working so hard to use DM code against me, your argument should be: "blk-mq drivers X, Y and Z rerun the hw queue; this is a well established pattern"
I see drivers/nvme/host/fc.c:nvme_fc_start_fcp_op() does. But that is only one other driver out of ~20
BLK_MQ_RQ_QUEUE_BUSYreturns tree-wide.Could be there are some others, but hardly a well-established pattern.
Hello Mike,
Quoted 9 lines
Several blk-mq drivers that can return
BLK_MQ_RQ_QUEUE_BUSYfrom their .queue_rq() implementation stop the request queue (blk_mq_stop_hw_queue()) before returning "busy" and restart the queue after the busy condition has been cleared (blk_mq_start_stopped_hw_queues()). Examples arevirtio_blkand xen-blkfront. However, this approach is not appropriate for the dm-mq core nor for the scsi core since both drivers already use the "stopped" state for another purpose than tracking whether or not a hardware queue is busy. Hence theblk_mq_delay_run_hw_queue()andblk_mq_run_hw_queue()calls in these last two drivers to rerun a hardware queue after the busy state has been cleared.Quoted 2 lines
But looks this patch just reruns the hw queue after 100ms, which isn't that after the busy state has been cleared, right?
Quoted 7 lines
Hello Ming,
That patch can be considered as a first step that can be refined further, namely by modifying the dm-rq code further such that dm-rq queues are only rerun after the busy condition has been cleared. The patch at the start of this thread is easier to review and easier to test than any patch that would only rerun dm-rq queues after the busy condition has been cleared.
OK, got it, it should have been better to add comments about this change since reruning the queue after 100ms is actually a workaround, instead of final solution.
Quoted 8 lines
Quoted 5 lines
Actually if
BLK_MQ_RQ_QUEUE_BUSYis returned from .queue_rq(), blk-mq will buffer this request intohctx->dispatchand run the hw queue again, so looksblk_mq_delay_run_hw_queue()in this situation shouldn't have been needed at my 1st impression.If the blk-mq core would always rerun a hardware queue if a block driver returns
BLK_MQ_RQ_QUEUE_BUSYthen that would cause 100% of a single CPU core
It won't casue 100% CPU utilization since we restart queue in completion path and at that time at least one tag is available, then progress can be made.
Quoted 9 lines
to be busy with polling a hardware queue until the "busy" condition has been cleared. One can see easily that that's not what the blk-mq core does. From
blk_mq_sched_dispatch_requests():if (!list_empty(&rq_list)) { blk_mq_sched_mark_restart_hctx(hctx); did_work = blk_mq_dispatch_rq_list(q, &rq_list); }
Quoted 8 lines
From the end of
blk_mq_dispatch_rq_list():if (!list_empty(list)) { [ ... ] if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) blk_mq_run_hw_queue(hctx, true); }
That is exactly what I meant, blk-mq already provides this mechanism to rerun the queue automatically in case of BLK_MQ_RQ_QUEUE_BUSY. If the mechanism doesn't work well, we need to fix that, then why bother drivers to workaround it?
Quoted 5 lines
In other words, the
BLK_MQ_S_SCHED_RESTARTflag is set before the dispatch list is examined and only if that flag gets cleared whileblk_mq_dispatch_rq_list()is in progress by a concurrentblk_mq_sched_restart_hctx()call then the dispatch list will be rerun after a block driver returned BLK_MQ_RQ_QUEUE_BUSY.
Yes, the queue is rerun either in completion path when BLK_MQ_S_SCHED_RESTART is set, or just .queue_rq() returning _BUSY and the flag is cleared at the same time from completion path.
So in theroy we can make sure the queue will be run again if _BUSY happened, then what is the root cause why we have to add blk_mq_delay_run_hw_queue(hctx, 100) in dm's .queue_rq()?
Thanks,
Ming
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 7 lines · Ming Lei
Quoted 2 lines · Bart Van Assche
If the blk-mq core would always rerun a hardware queue if a block driver returns
BLK_MQ_RQ_QUEUE_BUSYthen that would cause 100% of a single CPU coreIt won't casue 100% CPU utilization since we restart queue in completion path and at that time at least one tag is available, then progress can be made.
Hello Ming,
Sorry but you are wrong. If .queue_rq() returns BLK_MQ_RQ_QUEUE_BUSY then it's likely that calling .queue_rq() again after only a few microseconds will cause it to return BLK_MQ_RQ_QUEUE_BUSY again. If you don't believe me, change "if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) blk_mq_run_hw_queue(hctx, true);" into "blk_mq_run_hw_queue(hctx, true);", trigger a busy condition for either a SCSI LLD or a dm-rq driver, run top and you will see that the CPU usage of a kworker thread jumps up to 100%.
Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 9 lines · Bart Van Assche
Quoted 7 lines · Ming Lei
Quoted 2 lines · Bart Van Assche
If the blk-mq core would always rerun a hardware queue if a block driver returns
BLK_MQ_RQ_QUEUE_BUSYthen that would cause 100% of a single CPU coreIt won't casue 100% CPU utilization since we restart queue in completion path and at that time at least one tag is available, then progress can be made.
Quoted 8 lines
Hello Ming,
Sorry but you are wrong. If .queue_rq() returns
BLK_MQ_RQ_QUEUE_BUSYthen it's likely that calling .queue_rq() again after only a few microseconds will cause it to returnBLK_MQ_RQ_QUEUE_BUSYagain. If you don't believe me, change "if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING,&hctx->state))blk_mq_run_hw_queue(hctx, true);" into "blk_mq_run_hw_queue(hctx, true);", trigger a busy
Yes, that can be true, but I mean it is still OK to run the queue again with
if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) blk_mq_run_hw_queue(hctx, true);
and restarting queue in __blk_mq_finish_request() when BLK_MQ_RQ_QUEUE_BUSY is returned from .queue_rq(). And both are in current blk-mq implementation.
Then why do we need blk_mq_delay_run_hw_queue(hctx, 100/*ms*/) in dm?
Thanks,
Ming
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 26 lines · Ming Lei
Quoted 9 lines · Bart Van Assche
Quoted 7 lines · Ming Lei
Quoted 2 lines · Bart Van Assche
If the blk-mq core would always rerun a hardware queue if a block driver returns
BLK_MQ_RQ_QUEUE_BUSYthen that would cause 100% of a single CPU coreIt won't casue 100% CPU utilization since we restart queue in completion path and at that time at least one tag is available, then progress can be made.
Quoted 8 lines
Hello Ming,
Sorry but you are wrong. If .queue_rq() returns
BLK_MQ_RQ_QUEUE_BUSYthen it's likely that calling .queue_rq() again after only a few microseconds will cause it to returnBLK_MQ_RQ_QUEUE_BUSYagain. If you don't believe me, change "if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING,&hctx->state))blk_mq_run_hw_queue(hctx, true);" into "blk_mq_run_hw_queue(hctx, true);", trigger a busyYes, that can be true, but I mean it is still OK to run the queue again with
if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) blk_mq_run_hw_queue(hctx, true);
Quoted 5 lines
and restarting queue in
__blk_mq_finish_request()whenBLK_MQ_RQ_QUEUE_BUSYis returned from .queue_rq(). And both are in current blk-mq implementation.Then why do we need
blk_mq_delay_run_hw_queue(hctx, 100/*ms*/)in dm?
Because if dm_mq_queue_rq() returns BLK_MQ_RQ_QUEUE_BUSY that there is no guarantee that __blk_mq_finish_request() will be called later on for the same queue. dm_mq_queue_rq() can e.g. return BLK_MQ_RQ_QUEUE_BUSY while no dm requests are in progress because the SCSI error handler is active for all underlying paths. See also scsi_lld_busy() and scsi_host_in_recovery().
Bart.
Re: [PATCH v4 6/6] dm rq: Avoid that request processing stalls sporadically
Quoted 31 lines · Bart Van Assche
Quoted 30 lines · Ming Lei
Quoted 9 lines · Bart Van Assche
Quoted 7 lines · Ming Lei
Quoted 2 lines · Bart Van Assche
If the blk-mq core would always rerun a hardware queue if a block driver returns
BLK_MQ_RQ_QUEUE_BUSYthen that would cause 100% of a single CPU coreIt won't casue 100% CPU utilization since we restart queue in completion path and at that time at least one tag is available, then progress can be made.
Quoted 8 lines
Hello Ming,
Sorry but you are wrong. If .queue_rq() returns
BLK_MQ_RQ_QUEUE_BUSYthen it's likely that calling .queue_rq() again after only a few microseconds will cause it to returnBLK_MQ_RQ_QUEUE_BUSYagain. If you don't believe me, change "if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING,&hctx->state))blk_mq_run_hw_queue(hctx, true);" into "blk_mq_run_hw_queue(hctx, true);", trigger a busyYes, that can be true, but I mean it is still OK to run the queue again with
if (!blk_mq_sched_needs_restart(hctx) && !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) blk_mq_run_hw_queue(hctx, true);and restarting queue in
__blk_mq_finish_request()whenBLK_MQ_RQ_QUEUE_BUSYis returned from .queue_rq(). And both are in current blk-mq implementation.
Quoted 7 lines
Quoted 1 line
Then why do we need
blk_mq_delay_run_hw_queue(hctx, 100/*ms*/)in dm?Because if
dm_mq_queue_rq()returnsBLK_MQ_RQ_QUEUE_BUSYthat there is no guarantee that__blk_mq_finish_request()will be called later on for the same queue.dm_mq_queue_rq()can e.g. returnBLK_MQ_RQ_QUEUE_BUSYwhile no dm requests are in progress because the SCSI error handler is active for all underlying paths. See alsoscsi_lld_busy()andscsi_host_in_recovery().
OK, thanks Bart for the explanation.
Looks a very interesting BLK_MQ_RQ_QUEUE_BUSY case which isn't casued by too many pending I/O, and will study more about this case.
Thanks,
Ming
Jens Axboe
maintainerQuoted 5 lines · Bart Van Assche
Hello Jens,
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
Some of this we need in 4.11, but not all of it. I can't be applying patches that "improve scalability" at this point.
4-6 looks like what we want for 4.11, I'll see if those apply directly. Then we can put 1-3 on top in 4.12, with the others pulled in first.
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 5 lines · Bart Van Assche
Hello Jens,
=20
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.=20
Some of this we need in 4.11, but not all of it. I can't be applying patc=
hes
Quoted 3 lines
that "improve scalability" at this point.
=20
4-6 looks like what we want for 4.11, I'll see if those apply directly. T=
hen
Quoted 1 line
we can put 1-3 on top in 4.12, with the others pulled in first.
Hello Jens,
Please note that patch 2/6 is a bug fix. The current implementation of blk_mq_sched_restart_queues() only considers hardware queues associated wit= h
the same request queue as the hardware queue that has been passed as an argument. If a tag set is shared across request queues - as is the case for SCSI - then all request queues that share a tag set with the hctx argument must be considered.
Bart.=
Quoted 6 lines · Bart Van Assche
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Bart Van Assche
Hello Jens,
=20
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patch=
es
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
for inclusion in the upstream kernel.
=20
Some of this we need in 4.11, but not all of it. I can't be applying pa=
tches
Quoted 3 lines
Quoted 3 lines
that "improve scalability" at this point.
=20
4-6 looks like what we want for 4.11, I'll see if those apply directly.=
Then
Quoted 6 lines
Quoted 1 line
we can put 1-3 on top in 4.12, with the others pulled in first.
=20
Hello Jens,
=20
Please note that patch 2/6 is a bug fix. The current implementation ofblk_mq_sched_restart_queues()only considers hardware queues associated w=
ith
Quoted 2 lines
the same request queue as the hardware queue that has been passed as an argument. If a tag set is shared across request queues - as is the case f=
or
Quoted 1 line
SCSI - then all request queues that share a tag set with the hctx argumen=
t
Quoted 1 line
must be considered.
(replying to my own e-mail)
Hello Jens,
If you want I can split that patch into two patches - one that runs all har= dware
queues with which the tag set is shared and one that switches from rerunnin= g
all hardware queues to one hardware queue.
Bart.=
Jens Axboe
maintainerQuoted 24 lines · Bart Van Assche
Quoted 14 lines · Bart Van Assche
Quoted 7 lines · Jens Axboe
Quoted 5 lines · Bart Van Assche
Hello Jens,
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
Quoted 5 lines
Some of this we need in 4.11, but not all of it. I can't be applying patches that "improve scalability" at this point.
4-6 looks like what we want for 4.11, I'll see if those apply directly. Then we can put 1-3 on top in 4.12, with the others pulled in first.
Quoted 8 lines
Hello Jens,
Please note that patch 2/6 is a bug fix. The current implementation of
blk_mq_sched_restart_queues()only considers hardware queues associated with the same request queue as the hardware queue that has been passed as an argument. If a tag set is shared across request queues - as is the case for SCSI - then all request queues that share a tag set with the hctx argument must be considered.
Quoted 7 lines
(replying to my own e-mail)
Hello Jens,
If you want I can split that patch into two patches - one that runs all hardware queues with which the tag set is shared and one that switches from rerunning all hardware queues to one hardware queue.
I already put it in, but this is getting very awkward. We're at -rc5 time, patches going into mainline should be TINY. And now I'm sitting on this, that I have to justify:
15 files changed, 281 insertions(+), 164 deletions(-)
and where one of the patches reads like it's a performance improvement, when in reality it's fixing a hang. So yes, the patch should have been split in two, and the series should have been ordered so that the first patches could go into 4.11, and the rest on top of that in 4.12. Did we really need a patch clarifying comments in that series? Probably not.
Signature · 1 line
Jens Axboe
Quoted 6 lines · Bart Van Assche
Hello Jens,
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
Hey Bart,
just out of curiosity. Is this maybe related to similar stuff happening when CPUs are hot plugged - at least in that the stack gets stuck? Like in this thread here:
https://www.mail-archive.com/[email protected]/msg06057.html
Would be interesting, because we recently saw similar stuff happening.
Beste Grüße / Best regards,
- Benjamin Block
Signature · 4 lines
Linux on z Systems Development / IBM Systems & Technology Group IBM Deutschland Research & Development GmbH Vorsitz. AufsR.: Martina Koederitz / Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
Quoted 11 lines · Benjamin Block
Quoted 3 lines · Bart Van Assche
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
=20
just out of curiosity. Is this maybe related to similar stuff happening when CPUs are hot plugged - at least in that the stack gets stuck? Like in this thread here:
https://www.mail-archive.com/[email protected]/msg06057.html
=20
Would be interesting, because we recently saw similar stuff happening.
Hello Benjamin,
My proposal is to repeat that test with Jens' for-next branch. If the issue still occurs with that tree then please check the contents of /sys/kernel/debug/block/*/mq/*/{dispatch,*/rq_list}. That will allow to determine whether or not any block layer requests are still pending. If running the command below resolves the deadlock then it means that a trigger to run a block layer queue is still missing somewhere:
for a in /sys/kernel/debug/block/*/mq/state; do echo run >$a;=A0done
See also git://git.kernel.dk/linux-block.git.
Bart.=
Quoted 22 lines · Bart Van Assche
Quoted 11 lines · Benjamin Block
Quoted 3 lines · Bart Van Assche
The six patches in this patch series fix the queue lockup I reported recently on the linux-block mailing list. Please consider these patches for inclusion in the upstream kernel.
just out of curiosity. Is this maybe related to similar stuff happening when CPUs are hot plugged - at least in that the stack gets stuck? Like in this thread here:
https://www.mail-archive.com/[email protected]/msg06057.htmlWould be interesting, because we recently saw similar stuff happening.
Hello Benjamin,
My proposal is to repeat that test with Jens' for-next branch. If the issue still occurs with that tree then please check the contents of
/sys/kernel/debug/block/*/mq/*/{dispatch,*/rq_list}. That will allow to determine whether or not any block layer requests are still pending. If running the command below resolves the deadlock then it means that a trigger to run a block layer queue is still missing somewhere:
Quoted 4 lines
for a in
/sys/kernel/debug/block/*/mq/state; do echo run >$a;�doneSee also
git://git.kernel.dk/linux-block.git.
Thx for the hint! I'll forward that and see if the affected folks are willing to reproduce.
Beste Gr��e / Best regards,
- Benjamin Block
--
Linux on z Systems Development / IBM Systems & Technology Group
IBM Deutschland Research & Development GmbH
Vorsitz. AufsR.: Martina Koederitz / Gesch�ftsf�hrung: Dirk Wittkopp
Sitz der Gesellschaft: B�blingen / Registergericht: AmtsG Stuttgart, HRB 243294