[PATCH 6/7] blk-mq: Remove unnecessary hctx check in function blk_mq_alloc_and_init_hctx

From: Kemeng Shi
Date: Thu Feb 09 2023 - 07:12:02 EST


We can remove hctx from list when a valid hctx is found to avoid
extra valid check.

Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
---
block/blk-mq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4d2ab01549cd..1aa3cdc55c4e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4121,11 +4121,10 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
list_for_each_entry(tmp, &q->unused_hctx_list, hctx_list) {
if (tmp->numa_node == node) {
hctx = tmp;
+ list_del_init(&hctx->hctx_list);
break;
}
}
- if (hctx)
- list_del_init(&hctx->hctx_list);
spin_unlock(&q->unused_hctx_lock);

if (!hctx)
--
2.30.0