diff mbox series

[4/4] blk-throttle: cleanup throtl_dequeue_tg()

Message ID 20220823013810.406075-5-yukuai1@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series blk-throttle cleanups | expand

Commit Message

Yu Kuai Aug. 23, 2022, 1:38 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

Now that throtl_dequeue_tg() is called when the last bio is dispatched,
there is no need to check the flag THROTL_TG_PENDING, since it's ensured
to be set when bio is throttled.

There are no functional changes.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-throttle.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Tejun Heo Aug. 23, 2022, 6:34 p.m. UTC | #1
On Tue, Aug 23, 2022 at 09:38:10AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Now that throtl_dequeue_tg() is called when the last bio is dispatched,
> there is no need to check the flag THROTL_TG_PENDING, since it's ensured
> to be set when bio is throttled.
> 
> There are no functional changes.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  block/blk-throttle.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 47142a1dd102..e47506a8ef47 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -570,14 +570,11 @@ static void throtl_enqueue_tg(struct throtl_grp *tg)
>  
>  static void throtl_dequeue_tg(struct throtl_grp *tg)
>  {
> -	if (tg->flags & THROTL_TG_PENDING) {
> -		struct throtl_service_queue *parent_sq =
> -			tg->service_queue.parent_sq;
> +	struct throtl_service_queue *parent_sq = tg->service_queue.parent_sq;
>  
> -		throtl_rb_erase(&tg->rb_node, parent_sq);
> -		--parent_sq->nr_pending;
> -		tg->flags &= ~THROTL_TG_PENDING;
> -	}
> +	throtl_rb_erase(&tg->rb_node, parent_sq);
> +	--parent_sq->nr_pending;
> +	tg->flags &= ~THROTL_TG_PENDING;

Yeah, I don't know about this one. This breaks the symmetry with
throtl_enqueue_tg() and it's a bit odd that we aren't at least
WARN_ON_ONCE() on the flag given what the flag tracks. If you want to do
this, I think the prev approach of just removing the flag is better as that
was symmetric at least.

Thanks.
Yu Kuai Aug. 24, 2022, 1:19 a.m. UTC | #2
Hi, Tejun

在 2022/08/24 2:34, Tejun Heo 写道:
> On Tue, Aug 23, 2022 at 09:38:10AM +0800, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Now that throtl_dequeue_tg() is called when the last bio is dispatched,
>> there is no need to check the flag THROTL_TG_PENDING, since it's ensured
>> to be set when bio is throttled.
>>
>> There are no functional changes.
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   block/blk-throttle.c | 11 ++++-------
>>   1 file changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
>> index 47142a1dd102..e47506a8ef47 100644
>> --- a/block/blk-throttle.c
>> +++ b/block/blk-throttle.c
>> @@ -570,14 +570,11 @@ static void throtl_enqueue_tg(struct throtl_grp *tg)
>>   
>>   static void throtl_dequeue_tg(struct throtl_grp *tg)
>>   {
>> -	if (tg->flags & THROTL_TG_PENDING) {
>> -		struct throtl_service_queue *parent_sq =
>> -			tg->service_queue.parent_sq;
>> +	struct throtl_service_queue *parent_sq = tg->service_queue.parent_sq;
>>   
>> -		throtl_rb_erase(&tg->rb_node, parent_sq);
>> -		--parent_sq->nr_pending;
>> -		tg->flags &= ~THROTL_TG_PENDING;
>> -	}
>> +	throtl_rb_erase(&tg->rb_node, parent_sq);
>> +	--parent_sq->nr_pending;
>> +	tg->flags &= ~THROTL_TG_PENDING;
> 
> Yeah, I don't know about this one. This breaks the symmetry with
> throtl_enqueue_tg() and it's a bit odd that we aren't at least
> WARN_ON_ONCE() on the flag given what the flag tracks. If you want to do
> this, I think the prev approach of just removing the flag is better as that
> was symmetric at least.

Yes, you are right, thanks for the advice. Since now it's a bit
ambivalent, we might as well just remove this patch?

Thanks,
Kuai
> 
> Thanks.
>
diff mbox series

Patch

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 47142a1dd102..e47506a8ef47 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -570,14 +570,11 @@  static void throtl_enqueue_tg(struct throtl_grp *tg)
 
 static void throtl_dequeue_tg(struct throtl_grp *tg)
 {
-	if (tg->flags & THROTL_TG_PENDING) {
-		struct throtl_service_queue *parent_sq =
-			tg->service_queue.parent_sq;
+	struct throtl_service_queue *parent_sq = tg->service_queue.parent_sq;
 
-		throtl_rb_erase(&tg->rb_node, parent_sq);
-		--parent_sq->nr_pending;
-		tg->flags &= ~THROTL_TG_PENDING;
-	}
+	throtl_rb_erase(&tg->rb_node, parent_sq);
+	--parent_sq->nr_pending;
+	tg->flags &= ~THROTL_TG_PENDING;
 }
 
 /* Call with queue lock held */