Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] blk-mq: cleanup set->nr_hw_queues assignement
@ 2021-04-19  2:08 Jeffle Xu
  0 siblings, 0 replies; only message in thread
From: Jeffle Xu @ 2021-04-19  2:08 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

Move 'set->nr_hw_queues = new_nr_hw_queues' assignment into
blk_mq_realloc_tag_set_tags() when
'cur_nr_hw_queues >= new_nr_hw_queues', to make the assignement
encapsulated in one function. Besides, it can reduce the redundant
assignement when 'cur_nr_hw_queues < new_nr_hw_queues' called from
__blk_mq_update_nr_hw_queues().

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
Changes since v1:
Make 'set->nr_hw_queues = new_nr_hw_queues' assigenment when
'cur_nr_hw_queues >= new_nr_hw_queues' in blk_mq_realloc_tag_set_tags().
---
 block/blk-mq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 55ef6b975169..a32345bbadd6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3373,7 +3373,7 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
 	struct blk_mq_tags **new_tags;
 
 	if (cur_nr_hw_queues >= new_nr_hw_queues)
-		return 0;
+		goto out;
 
 	new_tags = kcalloc_node(new_nr_hw_queues, sizeof(struct blk_mq_tags *),
 				GFP_KERNEL, set->numa_node);
@@ -3385,8 +3385,9 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
 		       sizeof(*set->tags));
 	kfree(set->tags);
 	set->tags = new_tags;
-	set->nr_hw_queues = new_nr_hw_queues;
 
+out:
+	set->nr_hw_queues = new_nr_hw_queues;
 	return 0;
 }
 
@@ -3672,7 +3673,6 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 	    0)
 		goto reregister;
 
-	set->nr_hw_queues = nr_hw_queues;
 fallback:
 	blk_mq_update_queue_map(set);
 	list_for_each_entry(q, &set->tag_list, tag_set_list) {
-- 
2.27.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19  2:08 [PATCH v2] blk-mq: cleanup set->nr_hw_queues assignement Jeffle Xu

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git