Skip to content

Commit 7f2799c

Browse files
YuKuai-huaweiaxboe
authored andcommitted
blk-mq: cleanup shared tags case in blk_mq_update_nr_requests()
For shared tags case, all hctx->sched_tags/tags are the same, it doesn't make sense to call into blk_mq_tag_update_depth() multiple times for the same tags. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 626ff4f commit 7f2799c

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

block/blk-mq-tag.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,6 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
622622
struct blk_mq_tag_set *set = hctx->queue->tag_set;
623623
struct blk_mq_tags *new;
624624

625-
/*
626-
* Only the sbitmap needs resizing since we allocated the max
627-
* initially.
628-
*/
629-
if (blk_mq_is_shared_tags(set->flags))
630-
return 0;
631-
632625
new = blk_mq_alloc_map_and_rqs(set, hctx->queue_num, tdepth);
633626
if (!new)
634627
return -ENOMEM;

block/blk-mq.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,34 +4935,35 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
49354935

49364936
blk_mq_quiesce_queue(q);
49374937

4938-
queue_for_each_hw_ctx(q, hctx, i) {
4939-
if (!hctx->tags)
4940-
continue;
4941-
/*
4942-
* If we're using an MQ scheduler, just update the scheduler
4943-
* queue depth. This is similar to what the old code would do.
4944-
*/
4945-
if (hctx->sched_tags) {
4946-
ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags,
4947-
nr);
4948-
} else {
4949-
ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr);
4950-
}
4951-
if (ret)
4952-
goto out;
4953-
}
4954-
4955-
q->nr_requests = nr;
4956-
if (q->elevator && q->elevator->type->ops.depth_updated)
4957-
q->elevator->type->ops.depth_updated(q);
4958-
49594938
if (blk_mq_is_shared_tags(set->flags)) {
49604939
if (q->elevator)
49614940
blk_mq_tag_update_sched_shared_tags(q);
49624941
else
49634942
blk_mq_tag_resize_shared_tags(set, nr);
4943+
} else {
4944+
queue_for_each_hw_ctx(q, hctx, i) {
4945+
if (!hctx->tags)
4946+
continue;
4947+
/*
4948+
* If we're using an MQ scheduler, just update the
4949+
* scheduler queue depth. This is similar to what the
4950+
* old code would do.
4951+
*/
4952+
if (hctx->sched_tags)
4953+
ret = blk_mq_tag_update_depth(hctx,
4954+
&hctx->sched_tags, nr);
4955+
else
4956+
ret = blk_mq_tag_update_depth(hctx,
4957+
&hctx->tags, nr);
4958+
if (ret)
4959+
goto out;
4960+
}
49644961
}
49654962

4963+
q->nr_requests = nr;
4964+
if (q->elevator && q->elevator->type->ops.depth_updated)
4965+
q->elevator->type->ops.depth_updated(q);
4966+
49664967
out:
49674968
blk_mq_unquiesce_queue(q);
49684969

0 commit comments

Comments
 (0)