blk-mq: avoid to starve tag allocation after allocation process migrates
Subsystems (3)
PATCH 1/1 blk-mq: avoid to starve tag allocation after allocation process migrates
When the allocation process is scheduled back and the mapped hw queue is changed, do one extra wake up on orignal queue for compensating wake up miss, so other allocations on the orignal queue won't be starved.
This patch fixes one request allocation hang issue, which can be triggered easily in case of very low nr_request.
Cc <[email protected]>
Cc Omar Sandoval <[email protected]>
Signed-off-by Ming Lei <[email protected]>
--- block/blk-mq-tag.c | 13 +++++++++++++ include/linux/sbitmap.h | 7 +++++++ lib/sbitmap.c | 6 ++++++ 3 files changed, 26 insertions(+)
block/blk-mq-tag.c +13 -0
@@ -134,6 +134,8 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) ws =bt_wait_ptr (bt, data->hctx); drop_ctx = data->ctx ==NULL ; do { + struct sbitmap_queue *bt_orig; + /* * We're out of tags on this hardware queue, kick any * pending IO submits before going to sleep waiting for
@@ -159,6 +161,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)if (data->ctx)blk_mq_put_ctx (data->ctx); + bt_orig = bt;io_schedule (); data->ctx =blk_mq_get_ctx (data->q);
@@ -170,6 +173,16 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) bt = &tags->bitmap_tags;finish_wait (&ws->wait, &wait); + +/* +* If destination hw queue is changed, wake up original +* queue one extra time for compensating the wake up +* miss, so other allocations on original queue won't +* be starved. +*/ +if (bt != bt_orig) +sbitmap_queue_wake (bt_orig); + ws =bt_wait_ptr (bt, data->hctx); }while (1 );
include/linux/sbitmap.h +7 -0
@@ -484,6 +484,13 @@ static inline struct sbq_wait_state *sbq_wait_ptr(struct sbitmap_queue *sbq,void sbitmap_queue_wake_all (struct sbitmap_queue *sbq);/** +* sbitmap_wake_up() - Do a regular wake up compensation if the queue +* allocated from is changed after scheduling back. +* @sbq: Bitmap queue to wake up. +*/ +void sbitmap_queue_wake_up (struct sbitmap_queue *sbq); + +/** * sbitmap_queue_show() - Dump &struct sbitmap_queue information to a &struct * seq_file. * @sbq: Bitmap queue to show.
lib/sbitmap.c +6 -0
@@ -466,6 +466,12 @@ static void sbq_wake_up(struct sbitmap_queue *sbq) } } +void sbitmap_queue_wake_up (struct sbitmap_queue *sbq) +{ +sbq_wake_up (sbq); +} +EXPORT_SYMBOL_GPL (sbitmap_queue_wake_up); +void sbitmap_queue_clear (struct sbitmap_queue *sbq,unsigned int nr,unsigned int cpu) {
Signature · 1 line
2.9.5