diff mbox series

[3/3] blk-cgroup: bypass blkcg_deactivate_policy after destroying

Message ID 20231117023527.3188627-4-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series blk-cgroup: three small fixes | expand

Commit Message

Ming Lei Nov. 17, 2023, 2:35 a.m. UTC
blkcg_deactivate_policy() can be called after blkg_destroy_all()
returns, and it isn't necessary since blkg_destroy_all has covered
policy deactivation.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-cgroup.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Tejun Heo Nov. 19, 2023, 2:57 p.m. UTC | #1
Hello, Ming.

On Fri, Nov 17, 2023 at 10:35:24AM +0800, Ming Lei wrote:
> blkcg_deactivate_policy() can be called after blkg_destroy_all()
> returns, and it isn't necessary since blkg_destroy_all has covered
> policy deactivation.

Does this actually affect anything? This would matter iff a policy is
deactivated for the queue between blkg_destroy_all() and the rest of the
queue destruction, right? That's a really small window against very rare
operations. The patch is already in and I'm not necessarily against the
change but I'm curious what the motivation is.

Thanks.
Ming Lei Nov. 20, 2023, 12:51 a.m. UTC | #2
On Sun, Nov 19, 2023 at 04:57:46AM -1000, Tejun Heo wrote:
> Hello, Ming.
> 
> On Fri, Nov 17, 2023 at 10:35:24AM +0800, Ming Lei wrote:
> > blkcg_deactivate_policy() can be called after blkg_destroy_all()
> > returns, and it isn't necessary since blkg_destroy_all has covered
> > policy deactivation.
> 
> Does this actually affect anything? This would matter iff a policy is
> deactivated for the queue between blkg_destroy_all() and the rest of the
> queue destruction, right?

Yeah, it is true actually for throttle code.



thanks,
Ming
diff mbox series

Patch

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4a42ea2972ad..4b48c2c44098 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -577,6 +577,7 @@  static void blkg_destroy_all(struct gendisk *disk)
 	struct request_queue *q = disk->queue;
 	struct blkcg_gq *blkg, *n;
 	int count = BLKG_DESTROY_BATCH_SIZE;
+	int i;
 
 restart:
 	spin_lock_irq(&q->queue_lock);
@@ -602,6 +603,18 @@  static void blkg_destroy_all(struct gendisk *disk)
 		}
 	}
 
+	/*
+	 * Mark policy deactivated since policy offline has been done, and
+	 * the free is scheduled, so future blkcg_deactivate_policy() can
+	 * be bypassed
+	 */
+	for (i = 0; i < BLKCG_MAX_POLS; i++) {
+		struct blkcg_policy *pol = blkcg_policy[i];
+
+		if (pol)
+			__clear_bit(pol->plid, q->blkcg_pols);
+	}
+
 	q->root_blkg = NULL;
 	spin_unlock_irq(&q->queue_lock);
 }