Skip to contentSkip to conversation

blk-cgroup: don't update the blkg lookup hint in blkg_conf_prep

PATCH Applied Christoph Hellwig 3 participants 3 messages Sep 27, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-cgroup: don't update the blkg lookup hint in blkg_conf_prep

blkg_conf_prep just creates a new blkg structure, there is no real need to update the lookup hint which should only be done on a successful lookup in the I/O path.

---
 block/blk-cgroup.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
block/blk-cgroup.c +4 -13
index 94af5f3f3620b..6a5c849ee061b 100644
@@ -263,14 +263,6 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
 	return NULL;
 }
 
-static void blkg_update_hint(struct blkcg *blkcg, struct blkcg_gq *blkg)
-{
-	lockdep_assert_held(&blkg->q->queue_lock);
-
-	if (blkcg != &blkcg_root && blkg != rcu_dereference(blkcg->blkg_hint))
-		rcu_assign_pointer(blkcg->blkg_hint, blkg);
-}
-
 /*
  * If @new_blkg is %NULL, this function tries to allocate a new one as
  * necessary using %GFP_NOWAIT.  @new_blkg is always consumed on return.
@@ -383,7 +375,9 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
 	spin_lock_irqsave(&q->queue_lock, flags);
 	blkg = blkg_lookup(blkcg, q);
 	if (blkg) {
-		blkg_update_hint(blkcg, blkg);
+		if (blkcg != &blkcg_root &&
+		    blkg != rcu_dereference(blkcg->blkg_hint))
+			rcu_assign_pointer(blkcg->blkg_hint, blkg);
 		goto found;
 	}
 
@@ -680,10 +674,8 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 	}
 
 	blkg = blkg_lookup(blkcg, q);
-	if (blkg) {
-		blkg_update_hint(blkcg, blkg);
+	if (blkg)
 		goto success;
-	}
 
 	/*
 	 * Create blkgs walking down from blkcg_root to @blkcg, so that all
@@ -727,7 +719,6 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 
 		blkg = blkg_lookup(pos, q);
 		if (blkg) {
-			blkg_update_hint(pos, blkg);
 			blkg_free(new_blkg);
 		} else {
 			blkg = blkg_create(pos, disk, new_blkg);
Signature · 1 line
2.30.2
maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

blkg_conf_prep just creates a new blkg structure, there is no real need to update the lookup hint which should only be done on a successful lookup in the I/O path.

Applied, thanks!

[1/1] blk-cgroup: don't update the blkg lookup hint in blkg_conf_prep

      commit: 5765033cf77c54897848df683420bb62b6cc3d05

Best regards,

Signature · 1 line
Jens Axboe