Patch "blk-cgroup: Properly propagate the iostat update up the hierarchy" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    blk-cgroup: Properly propagate the iostat update up the hierarchy

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     blk-cgroup-properly-propagate-the-iostat-update-up-t.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5b7a2ddaaf27f7d3c27825a26bec1d79ddd6d7fb
Author: Waiman Long <longman@xxxxxxxxxx>
Date:   Wed May 15 10:30:59 2024 -0400

    blk-cgroup: Properly propagate the iostat update up the hierarchy
    
    [ Upstream commit 9d230c09964e6e18c8f6e4f0d41ee90eef45ec1c ]
    
    During a cgroup_rstat_flush() call, the lowest level of nodes are flushed
    first before their parents. Since commit 3b8cc6298724 ("blk-cgroup:
    Optimize blkcg_rstat_flush()"), iostat propagation was still done to
    the parent. Grandparent, however, may not get the iostat update if the
    parent has no blkg_iostat_set queued in its lhead lockless list.
    
    Fix this iostat propagation problem by queuing the parent's global
    blkg->iostat into one of its percpu lockless lists to make sure that
    the delta will always be propagated up to the grandparent and so on
    toward the root blkcg.
    
    Note that successive calls to __blkcg_rstat_flush() are serialized by
    the cgroup_rstat_lock. So no special barrier is used in the reading
    and writing of blkg->iostat.lqueued.
    
    Fixes: 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
    Reported-by: Dan Schatzberg <schatzberg.dan@xxxxxxxxx>
    Closes: https://lore.kernel.org/lkml/ZkO6l%2FODzadSgdhC@dschatzberg-fedora-PF3DHTBV/
    Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
    Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>
    Acked-by: Tejun Heo <tj@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240515143059.276677-1-longman@xxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 8102a23b24871..4fb045d26bd5a 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -323,6 +323,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
 	blkg->q = disk->queue;
 	INIT_LIST_HEAD(&blkg->q_node);
 	blkg->blkcg = blkcg;
+	blkg->iostat.blkg = blkg;
 #ifdef CONFIG_BLK_CGROUP_PUNT_BIO
 	spin_lock_init(&blkg->async_bio_lock);
 	bio_list_init(&blkg->async_bios);
@@ -1047,6 +1048,8 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
 		smp_mb();
 
 		WRITE_ONCE(bisc->lqueued, false);
+		if (bisc == &blkg->iostat)
+			goto propagate_up; /* propagate up to parent only */
 
 		/* fetch the current per-cpu values */
 		do {
@@ -1056,10 +1059,24 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
 
 		blkcg_iostat_update(blkg, &cur, &bisc->last);
 
+propagate_up:
 		/* propagate global delta to parent (unless that's root) */
-		if (parent && parent->parent)
+		if (parent && parent->parent) {
 			blkcg_iostat_update(parent, &blkg->iostat.cur,
 					    &blkg->iostat.last);
+			/*
+			 * Queue parent->iostat to its blkcg's lockless
+			 * list to propagate up to the grandparent if the
+			 * iostat hasn't been queued yet.
+			 */
+			if (!parent->iostat.lqueued) {
+				struct llist_head *plhead;
+
+				plhead = per_cpu_ptr(parent->blkcg->lhead, cpu);
+				llist_add(&parent->iostat.lnode, plhead);
+				parent->iostat.lqueued = true;
+			}
+		}
 	}
 	raw_spin_unlock_irqrestore(&blkg_stat_lock, flags);
 out:




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux