[PATCH] blk-mq-sched: Remove redundant code in blk_mq_sched_mark_restart_hctx().

Chaohai Chen posted 1 patch 3 weeks, 2 days ago
block/blk-mq-sched.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] blk-mq-sched: Remove redundant code in blk_mq_sched_mark_restart_hctx().
Posted by Chaohai Chen 3 weeks, 2 days ago
The current purpose of the blk_mq_sched_mark_restart_hctx() function
is to set the BLK_MQ_S_SCHED_RESTART flag in hctx->state. Just remove
the redundant judgement.

Signed-off-by: Chaohai Chen <wdhh6@aliyun.com>
---
 block/blk-mq-sched.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index e26898128a7e..2f6c353cb6d0 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -21,9 +21,6 @@
  */
 void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx)
 {
-	if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
-		return;
-
 	set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
 }
 EXPORT_SYMBOL_GPL(blk_mq_sched_mark_restart_hctx);
-- 
2.43.7
Re: [PATCH] blk-mq-sched: Remove redundant code in blk_mq_sched_mark_restart_hctx().
Posted by Yu Kuai 3 weeks, 1 day ago
Hi,

在 2026/1/16 14:19, Chaohai Chen 写道:
> The current purpose of the blk_mq_sched_mark_restart_hctx() function
> is to set the BLK_MQ_S_SCHED_RESTART flag in hctx->state. Just remove
> the redundant judgement.

I don't think this is just redundant. This function is called from IO hot path,
and test_bit() should have less performance overhead than set_bit() if the
state is already set.

>
> Signed-off-by: Chaohai Chen <wdhh6@aliyun.com>
> ---
>   block/blk-mq-sched.c | 3 ---
>   1 file changed, 3 deletions(-)
>
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index e26898128a7e..2f6c353cb6d0 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -21,9 +21,6 @@
>    */
>   void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx)
>   {
> -	if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
> -		return;
> -
>   	set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
>   }
>   EXPORT_SYMBOL_GPL(blk_mq_sched_mark_restart_hctx);

-- 
Thansk,
Kuai