Commit 76bea5f8 authored by John Garry's avatar John Garry Committed by Zheng Zengkai
Browse files

blk-mq: Relocate shared sbitmap resize in blk_mq_update_nr_requests()

mainline inclusion
from mainline-v5.16-rc1
commit 8fa04464
category: performance
bugzilla: 186917, https://gitee.com/openeuler/kernel/issues/I5N1S5
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8fa044640f128c0cd015f72cda42989a664889fc



--------------------------------

For shared sbitmap, if the call to blk_mq_tag_update_depth() was
successful for any hctx when hctx->sched_tags is not set, then it would be
successful for all (due to nature in which blk_mq_tag_update_depth()
fails).

As such, there is no need to call blk_mq_tag_resize_shared_sbitmap() for
each hctx. So relocate the call until after the hctx iteration under the
!q->elevator check, which is equivalent (to !hctx->sched_tags).

Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/1633429419-228500-4-git-send-email-john.garry@huawei.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 1bc13e6d
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -3767,8 +3767,6 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
		if (!hctx->sched_tags) {
			ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr,
							false);
			if (!ret && blk_mq_is_sbitmap_shared(set->flags))
				blk_mq_tag_resize_shared_sbitmap(set, nr);
		} else {
			ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags,
							nr, true);
@@ -3786,9 +3784,13 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
	}
	if (!ret) {
		q->nr_requests = nr;
		if (q->elevator && blk_mq_is_sbitmap_shared(set->flags))
		if (blk_mq_is_sbitmap_shared(set->flags)) {
			if (q->elevator)
				sbitmap_queue_resize(&q->sched_bitmap_tags,
						     nr - set->reserved_tags);
			else
				blk_mq_tag_resize_shared_sbitmap(set, nr);
		}
	}

	blk_mq_unquiesce_queue(q);