Skip to content

Commit 1082541

Browse files
Laibin Qiuaxboe
authored andcommitted
blk-mq: Fix wrong wakeup batch configuration which will cause hang
Commit 180dccb ("blk-mq: fix tag_get wait task can't be awakened") will recalculate wake_batch when incrementing or decrementing active_queues to avoid wake_batch > hctx_max_depth. At the same time, in order to not affect performance as much as possible, the minimum wakeup batch is set to 4. But when the QD is small (such as QD=1), if inc or dec active_queues increases wakeup batch, that can lead to a hang: Fix this problem with the following strategies: QD : >= 32 | < 32 --------------------------------- wakeup batch: 8~4 | 3~1 Fixes: 180dccb ("blk-mq: fix tag_get wait task can't be awakened") Link: https://lore.kernel.org/linux-block/[email protected]/T/#t Reported-by: Alex Xu (Hello71) <[email protected]> Signed-off-by: Laibin Qiu <[email protected]> Tested-by: Alex Xu (Hello71) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3c8cef9 commit 1082541

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/sbitmap.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,13 @@ void sbitmap_queue_recalculate_wake_batch(struct sbitmap_queue *sbq,
488488
unsigned int users)
489489
{
490490
unsigned int wake_batch;
491+
unsigned int min_batch;
492+
unsigned int depth = (sbq->sb.depth + users - 1) / users;
491493

492-
wake_batch = clamp_val((sbq->sb.depth + users - 1) /
493-
users, 4, SBQ_WAKE_BATCH);
494+
min_batch = sbq->sb.depth >= (4 * SBQ_WAIT_QUEUES) ? 4 : 1;
495+
496+
wake_batch = clamp_val(depth / SBQ_WAIT_QUEUES,
497+
min_batch, SBQ_WAKE_BATCH);
494498
__sbitmap_queue_update_wake_batch(sbq, wake_batch);
495499
}
496500
EXPORT_SYMBOL_GPL(sbitmap_queue_recalculate_wake_batch);

0 commit comments

Comments
 (0)