summaryrefslogtreecommitdiffstats
path: root/block/blk-mq-tag.c
diff options
context:
space:
mode:
authorJianchao Wang <jianchao.w.wang@oracle.com>2018-08-09 08:34:17 -0600
committerJens Axboe <axboe@kernel.dk>2018-08-09 08:34:17 -0600
commitd263ed9926823c462f99a7679e18f0c9e5b8550d (patch)
treecffbdef4fa64044fe0bdb356d2412062ab9160e6 /block/blk-mq-tag.c
parentd6c02a9beb67f13d5f14f23e72fa9981e8b84477 (diff)
downloadlinux-stable-d263ed9926823c462f99a7679e18f0c9e5b8550d.tar.gz
linux-stable-d263ed9926823c462f99a7679e18f0c9e5b8550d.tar.bz2
linux-stable-d263ed9926823c462f99a7679e18f0c9e5b8550d.zip
blk-mq: count the hctx as active before allocating tag
Currently, we count the hctx as active after allocate driver tag successfully. If a previously inactive hctx try to get tag first time, it may fails and need to wait. However, due to the stale tag ->active_queues, the other shared-tags users are still able to occupy all driver tags while there is someone waiting for tag. Consequently, even if the previously inactive hctx is waked up, it still may not be able to get a tag and could be starved. To fix it, we count the hctx as active before try to allocate driver tag, then when it is waiting the tag, the other shared-tag users will reserve budget for it. Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq-tag.c')
-rw-r--r--block/blk-mq-tag.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index c43b3398d7b4..c0c4e63583ae 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -23,6 +23,9 @@ bool blk_mq_has_free_tags(struct blk_mq_tags *tags)
/*
* If a previously inactive queue goes active, bump the active user count.
+ * We need to do this before try to allocate driver tag, then even if fail
+ * to get tag when first time, the other shared-tag users could reserve
+ * budget for it.
*/
bool __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
{