Commit 5765033c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

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.

Suggested-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20220927065425.257876-1-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8237c01f
Loading
Loading
Loading
Loading
+4 −13
Original line number Original line Diff line number Diff line
@@ -263,14 +263,6 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
	return NULL;
	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
 * 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.
 * 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);
	spin_lock_irqsave(&q->queue_lock, flags);
	blkg = blkg_lookup(blkcg, q);
	blkg = blkg_lookup(blkcg, q);
	if (blkg) {
	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;
		goto found;
	}
	}


@@ -680,10 +674,8 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
	}
	}


	blkg = blkg_lookup(blkcg, q);
	blkg = blkg_lookup(blkcg, q);
	if (blkg) {
	if (blkg)
		blkg_update_hint(blkcg, blkg);
		goto success;
		goto success;
	}


	/*
	/*
	 * Create blkgs walking down from blkcg_root to @blkcg, so that all
	 * 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);
		blkg = blkg_lookup(pos, q);
		if (blkg) {
		if (blkg) {
			blkg_update_hint(pos, blkg);
			blkg_free(new_blkg);
			blkg_free(new_blkg);
		} else {
		} else {
			blkg = blkg_create(pos, disk, new_blkg);
			blkg = blkg_create(pos, disk, new_blkg);