This is a note to let you know that I've just added the patch titled blk-mq: prealloc tags when increase tagset nr_hw_queues to the 6.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: blk-mq-prealloc-tags-when-increase-tagset-nr_hw_queues.patch and it can be found in the queue-6.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 7222657e51b5626d10154b3e48ad441c33b5da96 Mon Sep 17 00:00:00 2001 From: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx> Date: Mon, 21 Aug 2023 17:56:02 +0800 Subject: blk-mq: prealloc tags when increase tagset nr_hw_queues From: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx> commit 7222657e51b5626d10154b3e48ad441c33b5da96 upstream. Just like blk_mq_alloc_tag_set(), it's better to prepare all tags before using to map to queue ctxs in blk_mq_map_swqueue(), which now have to consider empty set->tags[]. The good point is that we can fallback easily if increasing nr_hw_queues fail, instead of just mapping to hctx[0] when fail in blk_mq_map_swqueue(). And the fallback path already has tags free & clean handling, so all is good. Signed-off-by: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx> Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230821095602.70742-3-chengming.zhou@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/blk-mq.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4420,6 +4420,16 @@ static int blk_mq_realloc_tag_set_tags(s sizeof(*set->tags)); kfree(set->tags); set->tags = new_tags; + + for (i = set->nr_hw_queues; i < new_nr_hw_queues; i++) { + if (!__blk_mq_alloc_map_and_rqs(set, i)) { + while (--i >= set->nr_hw_queues) + __blk_mq_free_map_and_rqs(set, i); + return -ENOMEM; + } + cond_resched(); + } + done: set->nr_hw_queues = new_nr_hw_queues; return 0; Patches currently in stable-queue which might be from zhouchengming@xxxxxxxxxxxxx are queue-6.5/blk-mq-prealloc-tags-when-increase-tagset-nr_hw_queues.patch queue-6.5/blk-mq-fix-tags-leak-when-shrink-nr_hw_queues.patch queue-6.5/blk-mq-fix-tags-uaf-when-shrinking-q-nr_hw_queues.patch