Skip to contentSkip to conversation

blk-cgroup: Fix the recursive blkg rwstat

PATCH Jens Axboe 2 participants 2 messages Mar 5, 2021 – Mar 7, 2021 1 message not in the archive Block layer

lore
Share & tools
lore

Jens Axboe

author maintainer
#1 lore raw
In reply to a message not in the archive
Quoted 16 lines · Xunlei Pang

The current blkio.throttle.io_service_bytes_recursive doesn't work correctly.

As an example, for the following blkcg hierarchy:
(Made 1GB READ in test1, 512MB READ in test2)

     test
    /    \

test1 test2

$ head -n 1 test/test1/blkio.throttle.io_service_bytes_recursive
8:0 Read 1073684480
$ head -n 1 test/test2/blkio.throttle.io_service_bytes_recursive
8:0 Read 537448448
$ head -n 1 test/blkio.throttle.io_service_bytes_recursive
8:0 Read 537448448
Quoted 3 lines

Clearly, above data of "test" reflects "test2" not "test1"+"test2".

Do the correct summary in blkg_rwstat_recursive_sum().

LGTM, Tejun?

Quoted 28 lines
---
 block/blk-cgroup-rwstat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-cgroup-rwstat.c +2 -1
index 85d5790..3304e84 100644
@@ -109,6 +109,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
 
 	lockdep_assert_held(&blkg->q->queue_lock);
 
+	memset(sum, 0, sizeof(*sum));
 	rcu_read_lock();
 	blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
 		struct blkg_rwstat *rwstat;
@@ -122,7 +123,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
 			rwstat = (void *)pos_blkg + off;
 
 		for (i = 0; i < BLKG_RWSTAT_NR; i++)
-			sum->cnt[i] = blkg_rwstat_read_counter(rwstat, i);
+			sum->cnt[i] += blkg_rwstat_read_counter(rwstat, i);
 	}
 	rcu_read_unlock();
 }
Signature · 1 line
Jens Axboe
Acked-by
#2 lore raw
Quoted 17 lines · Jens Axboe
Quoted 16 lines · Xunlei Pang

The current blkio.throttle.io_service_bytes_recursive doesn't work correctly.

As an example, for the following blkcg hierarchy:
(Made 1GB READ in test1, 512MB READ in test2)

     test
    /    \

test1 test2

$ head -n 1 test/test1/blkio.throttle.io_service_bytes_recursive
8:0 Read 1073684480
$ head -n 1 test/test2/blkio.throttle.io_service_bytes_recursive
8:0 Read 537448448
$ head -n 1 test/blkio.throttle.io_service_bytes_recursive
8:0 Read 537448448
Quoted 5 lines
Quoted 3 lines

Clearly, above data of "test" reflects "test2" not "test1"+"test2".

Do the correct summary in blkg_rwstat_recursive_sum().

LGTM, Tejun?

Gees, that's horrible. Thanks for fixing this.

Signature · 1 line
tejun