[PATCH] block: optimize sq_hctx assignment

Fanhui Meng posted 1 patch 8 months, 3 weeks ago
block/blk-mq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] block: optimize sq_hctx assignment
Posted by Fanhui Meng 8 months, 3 weeks ago
Optimizing code for greater standardization.

Signed-off-by: Fanhui Meng <mengfanhui@kylinos.cn>
---
 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 40490ac88045..182557019832 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2384,10 +2384,9 @@ static struct blk_mq_hw_ctx *blk_mq_get_sq_hctx(struct request_queue *q)
  */
 void blk_mq_run_hw_queues(struct request_queue *q, bool async)
 {
-	struct blk_mq_hw_ctx *hctx, *sq_hctx;
+	struct blk_mq_hw_ctx *hctx, *sq_hctx = NULL;
 	unsigned long i;
 
-	sq_hctx = NULL;
 	if (blk_queue_sq_sched(q))
 		sq_hctx = blk_mq_get_sq_hctx(q);
 	queue_for_each_hw_ctx(q, hctx, i) {
-- 
2.25.1
Re: [PATCH] block: optimize sq_hctx assignment
Posted by Christoph Hellwig 8 months, 3 weeks ago
On Fri, Mar 28, 2025 at 11:13:21AM +0800, Fanhui Meng wrote:
> Optimizing code for greater standardization.

not sure what is an optimization here.  I personally really like
initializing variables at declaration time, but it's not an optimization
and without other changes it the area this really just feels like churn.