mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] blk-cgroup: Fix the recursive blkg rwstat
       [not found] <1614932007-97224-1-git-send-email-xlpang@linux.alibaba.com>
@ 2021-03-05 18:32 ` Jens Axboe
  2021-03-07 12:42   ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Axboe @ 2021-03-05 18:32 UTC (permalink / raw)
  To: Xunlei Pang; +Cc: linux-block, linux-kernel, tj

On 3/5/21 1:13 AM, Xunlei Pang wrote:
> 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
> 
> Clearly, above data of "test" reflects "test2" not "test1"+"test2".
> 
> Do the correct summary in blkg_rwstat_recursive_sum().

LGTM, Tejun?

> 
> Signed-off-by: Xunlei Pang <xlpang@linux.alibaba.com>
> ---
>  block/blk-cgroup-rwstat.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-cgroup-rwstat.c b/block/blk-cgroup-rwstat.c
> index 85d5790..3304e84 100644
> --- a/block/blk-cgroup-rwstat.c
> +++ b/block/blk-cgroup-rwstat.c
> @@ -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();
>  }
> 


-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] blk-cgroup: Fix the recursive blkg rwstat
  2021-03-05 18:32 ` [PATCH] blk-cgroup: Fix the recursive blkg rwstat Jens Axboe
@ 2021-03-07 12:42   ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2021-03-07 12:42 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Xunlei Pang, linux-block, linux-kernel

On Fri, Mar 05, 2021 at 11:32:05AM -0700, Jens Axboe wrote:
> On 3/5/21 1:13 AM, Xunlei Pang wrote:
> > 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
> > 
> > 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.

Acked-by: Tejun Heo <tj@kernel.org>

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-07 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1614932007-97224-1-git-send-email-xlpang@linux.alibaba.com>
2021-03-05 18:32 ` [PATCH] blk-cgroup: Fix the recursive blkg rwstat Jens Axboe
2021-03-07 12:42   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®