All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next v3] block, bfq: cleanup 'bfqg->online'
@ 2023-02-02 13:49 ` Yu Kuai
  0 siblings, 0 replies; 4+ messages in thread
From: Yu Kuai @ 2023-02-02 13:49 UTC (permalink / raw)
  To: jack, paolo.valente, axboe, tj, josef
  Cc: linux-block, cgroups, linux-kernel, yukuai3, yukuai1, yi.zhang,
	yangerkun

From: Yu Kuai <yukuai3@huawei.com>

After commit dfd6200a0954 ("blk-cgroup: support to track if policy is
online"), there is no need to do this again in bfq.

However, 'pd->online' is not protected by 'bfqd->lock', in order to make
sure bfq won't see that 'pd->online' is still set after bfq_pd_offline(),
clear it before bfq_pd_offline() is called. This is fine because other
polices doesn't use 'pd->online' and bfq_pd_offline() will move active
bfqq to root cgroup anyway.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
Changes in v3:
 - in commit message: protected -> not protected, bfq_pd_offline_() ->
 bfq_pd_offline().
Changes in v2:
 - clear 'pd->online' before calling bfq_pd_offline()

 block/bfq-cgroup.c  | 4 +---
 block/bfq-iosched.h | 2 --
 block/blk-cgroup.c  | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index b42956ab5550..a35136dae713 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -551,7 +551,6 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
 	bfqg->bfqd = bfqd;
 	bfqg->active_entities = 0;
 	bfqg->num_queues_with_pending_reqs = 0;
-	bfqg->online = true;
 	bfqg->rq_pos_tree = RB_ROOT;
 }
 
@@ -614,7 +613,7 @@ struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
 			continue;
 		}
 		bfqg = blkg_to_bfqg(blkg);
-		if (bfqg->online) {
+		if (bfqg->pd.online) {
 			bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
 			return bfqg;
 		}
@@ -985,7 +984,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
 
 put_async_queues:
 	bfq_put_async_queues(bfqd, bfqg);
-	bfqg->online = false;
 
 	spin_unlock_irqrestore(&bfqd->lock, flags);
 	/*
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 75cc6a324267..69aaee52285a 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -1009,8 +1009,6 @@ struct bfq_group {
 
 	/* reference counter (see comments in bfq_bic_update_cgroup) */
 	refcount_t ref;
-	/* Is bfq_group still online? */
-	bool online;
 
 	struct bfq_entity entity;
 	struct bfq_sched_data sched_data;
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index cb110fc51940..a228dfe65253 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -491,9 +491,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)
 		struct blkcg_policy *pol = blkcg_policy[i];
 
 		if (blkg->pd[i] && blkg->pd[i]->online) {
+			blkg->pd[i]->online = false;
 			if (pol->pd_offline_fn)
 				pol->pd_offline_fn(blkg->pd[i]);
-			blkg->pd[i]->online = false;
 		}
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH -next v3] block, bfq: cleanup 'bfqg->online'
@ 2023-02-02 13:49 ` Yu Kuai
  0 siblings, 0 replies; 4+ messages in thread
From: Yu Kuai @ 2023-02-02 13:49 UTC (permalink / raw)
  To: jack-AlSwsSmVLrQ, paolo.valente-QSEj5FYQhm4dnm+yROfE0A,
	axboe-tSWWG44O7X1aa/9Udqfwiw, tj-DgEjT+Ai2ygdnm+yROfE0A,
	josef-DigfWCa+lFGyeJad7bwFQA
  Cc: linux-block-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	yukuai3-hv44wF8Li93QT0dZR+AlfA, yukuai1-XF6JlduFytWkHkcT6e4Xnw,
	yi.zhang-hv44wF8Li93QT0dZR+AlfA,
	yangerkun-hv44wF8Li93QT0dZR+AlfA

From: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

After commit dfd6200a0954 ("blk-cgroup: support to track if policy is
online"), there is no need to do this again in bfq.

However, 'pd->online' is not protected by 'bfqd->lock', in order to make
sure bfq won't see that 'pd->online' is still set after bfq_pd_offline(),
clear it before bfq_pd_offline() is called. This is fine because other
polices doesn't use 'pd->online' and bfq_pd_offline() will move active
bfqq to root cgroup anyway.

Signed-off-by: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
Changes in v3:
 - in commit message: protected -> not protected, bfq_pd_offline_() ->
 bfq_pd_offline().
Changes in v2:
 - clear 'pd->online' before calling bfq_pd_offline()

 block/bfq-cgroup.c  | 4 +---
 block/bfq-iosched.h | 2 --
 block/blk-cgroup.c  | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index b42956ab5550..a35136dae713 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -551,7 +551,6 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
 	bfqg->bfqd = bfqd;
 	bfqg->active_entities = 0;
 	bfqg->num_queues_with_pending_reqs = 0;
-	bfqg->online = true;
 	bfqg->rq_pos_tree = RB_ROOT;
 }
 
@@ -614,7 +613,7 @@ struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
 			continue;
 		}
 		bfqg = blkg_to_bfqg(blkg);
-		if (bfqg->online) {
+		if (bfqg->pd.online) {
 			bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
 			return bfqg;
 		}
@@ -985,7 +984,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
 
 put_async_queues:
 	bfq_put_async_queues(bfqd, bfqg);
-	bfqg->online = false;
 
 	spin_unlock_irqrestore(&bfqd->lock, flags);
 	/*
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 75cc6a324267..69aaee52285a 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -1009,8 +1009,6 @@ struct bfq_group {
 
 	/* reference counter (see comments in bfq_bic_update_cgroup) */
 	refcount_t ref;
-	/* Is bfq_group still online? */
-	bool online;
 
 	struct bfq_entity entity;
 	struct bfq_sched_data sched_data;
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index cb110fc51940..a228dfe65253 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -491,9 +491,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)
 		struct blkcg_policy *pol = blkcg_policy[i];
 
 		if (blkg->pd[i] && blkg->pd[i]->online) {
+			blkg->pd[i]->online = false;
 			if (pol->pd_offline_fn)
 				pol->pd_offline_fn(blkg->pd[i]);
-			blkg->pd[i]->online = false;
 		}
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next v3] block, bfq: cleanup 'bfqg->online'
  2023-02-02 13:49 ` Yu Kuai
  (?)
@ 2023-02-07 10:07 ` Jan Kara
  -1 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2023-02-07 10:07 UTC (permalink / raw)
  To: Yu Kuai
  Cc: jack, paolo.valente, axboe, tj, josef, linux-block, cgroups,
	linux-kernel, yukuai3, yi.zhang, yangerkun

On Thu 02-02-23 21:49:13, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> After commit dfd6200a0954 ("blk-cgroup: support to track if policy is
> online"), there is no need to do this again in bfq.
> 
> However, 'pd->online' is not protected by 'bfqd->lock', in order to make
> sure bfq won't see that 'pd->online' is still set after bfq_pd_offline(),
> clear it before bfq_pd_offline() is called. This is fine because other
> polices doesn't use 'pd->online' and bfq_pd_offline() will move active
> bfqq to root cgroup anyway.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

The patch looks good to me now. Thanks! Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> Changes in v3:
>  - in commit message: protected -> not protected, bfq_pd_offline_() ->
>  bfq_pd_offline().
> Changes in v2:
>  - clear 'pd->online' before calling bfq_pd_offline()
> 
>  block/bfq-cgroup.c  | 4 +---
>  block/bfq-iosched.h | 2 --
>  block/blk-cgroup.c  | 2 +-
>  3 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index b42956ab5550..a35136dae713 100644
> --- a/block/bfq-cgroup.c
> +++ b/block/bfq-cgroup.c
> @@ -551,7 +551,6 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
>  	bfqg->bfqd = bfqd;
>  	bfqg->active_entities = 0;
>  	bfqg->num_queues_with_pending_reqs = 0;
> -	bfqg->online = true;
>  	bfqg->rq_pos_tree = RB_ROOT;
>  }
>  
> @@ -614,7 +613,7 @@ struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
>  			continue;
>  		}
>  		bfqg = blkg_to_bfqg(blkg);
> -		if (bfqg->online) {
> +		if (bfqg->pd.online) {
>  			bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
>  			return bfqg;
>  		}
> @@ -985,7 +984,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
>  
>  put_async_queues:
>  	bfq_put_async_queues(bfqd, bfqg);
> -	bfqg->online = false;
>  
>  	spin_unlock_irqrestore(&bfqd->lock, flags);
>  	/*
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 75cc6a324267..69aaee52285a 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -1009,8 +1009,6 @@ struct bfq_group {
>  
>  	/* reference counter (see comments in bfq_bic_update_cgroup) */
>  	refcount_t ref;
> -	/* Is bfq_group still online? */
> -	bool online;
>  
>  	struct bfq_entity entity;
>  	struct bfq_sched_data sched_data;
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index cb110fc51940..a228dfe65253 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -491,9 +491,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)
>  		struct blkcg_policy *pol = blkcg_policy[i];
>  
>  		if (blkg->pd[i] && blkg->pd[i]->online) {
> +			blkg->pd[i]->online = false;
>  			if (pol->pd_offline_fn)
>  				pol->pd_offline_fn(blkg->pd[i]);
> -			blkg->pd[i]->online = false;
>  		}
>  	}
>  
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next v3] block, bfq: cleanup 'bfqg->online'
  2023-02-02 13:49 ` Yu Kuai
  (?)
  (?)
@ 2023-02-07 17:21 ` Jens Axboe
  -1 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-02-07 17:21 UTC (permalink / raw)
  To: jack, paolo.valente, tj, josef, Yu Kuai
  Cc: linux-block, cgroups, linux-kernel, yukuai3, yi.zhang, yangerkun


On Thu, 02 Feb 2023 21:49:13 +0800, Yu Kuai wrote:
> After commit dfd6200a0954 ("blk-cgroup: support to track if policy is
> online"), there is no need to do this again in bfq.
> 
> However, 'pd->online' is not protected by 'bfqd->lock', in order to make
> sure bfq won't see that 'pd->online' is still set after bfq_pd_offline(),
> clear it before bfq_pd_offline() is called. This is fine because other
> polices doesn't use 'pd->online' and bfq_pd_offline() will move active
> bfqq to root cgroup anyway.
> 
> [...]

Applied, thanks!

[1/1] block, bfq: cleanup 'bfqg->online'
      commit: f37bf75ca73d523ebaa7ceb44c45d8ecd05374fe

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-07 17:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 13:49 [PATCH -next v3] block, bfq: cleanup 'bfqg->online' Yu Kuai
2023-02-02 13:49 ` Yu Kuai
2023-02-07 10:07 ` Jan Kara
2023-02-07 17:21 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.