Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3419260pxf; Mon, 29 Mar 2021 01:30:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpuSzEaopNjmOy2sGY7kQ7va29jaTmvcQIY9uDv1NDDknYHJp+acpNnTSTKWpM3dHNbVss X-Received: by 2002:a17:906:6683:: with SMTP id z3mr27850006ejo.390.1617006620167; Mon, 29 Mar 2021 01:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006620; cv=none; d=google.com; s=arc-20160816; b=otxWNt7KCWqdUdC1EiWuKuMlix9WjdJH5abVKs9jgHVo651nVtw34OFAsIGuZv533a eAhQLUB9gi2YvomImu/L1FnEAjL8LNEO+4JAgHHNS2U5TIq5dDqw3stLH4Mk16V4AKAm 1PhVCHAgiCiTZOlZcw+HBifNSZuM3NrpYjM8o5R5Ynw4L6TXpIb67BG0KriWMtNgg8Vi WnKL8eZFW2CJSq2gcTaSesGvEQ/YLdXnil25jMP8qJSn2bvyCYt7fEaHVco8QYtHQ1Ix e699rJ4Xs1CR5K6ZcUQBLskD9Jtt1Tlis/ljuGwdtcHeh57e7FtUmLdRb9DA/yGqQWnK aM/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8tS1a8tcJdG6vYiqCKMy6NkaFjLPQwsHa7Fl2jfrhjc=; b=ATNA7J80qpAMddvvxIlPgpBM5w6smEAedMgPZfVTHDMoUaskeoZ5+JibzL2wGYLHwq Sr92gZoZ4x4UMI3f16+vbioppo4HYunqD45e1/U6DtyY1nsRovMVZYihd1sk9tfOo3Mr iwL32qWCBSz92Cxdn6cmTGijaYTCJFntMwvisGCdNhVK72lq1mxJ8HDFF82H43VcZDHo cPBAtBPopLpDvEpRG6K1AaATDbsjhXCe82n+M+pIFSdZwEvBz4GJkZcbp9nGpf8XSXmq DqVmbj1xAvQSS1ZDhPRlInH9nJS5d0VVf/W2iHU1sCQWojCq9MbyuHglRZeYUwQGDvbj VumA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vT79fWYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si13088737ejr.444.2021.03.29.01.29.52; Mon, 29 Mar 2021 01:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vT79fWYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbhC2I0i (ORCPT + 99 others); Mon, 29 Mar 2021 04:26:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:59086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233216AbhC2IRJ (ORCPT ); Mon, 29 Mar 2021 04:17:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 581B261960; Mon, 29 Mar 2021 08:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005807; bh=O/0q2JjobzsUmuE+dvnraPV+i669n5v5EMZTYrRvoEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vT79fWYiAl85eInY4SPdpsrTMYL4QM123+Epl0QhQ/bBxf5A1RcIQdU7cW+fUf4je R1njm//PltpJLAbVCbq/qLkCOwwbMrMIhs3frfDsyLxqHfbEhn2Pn1Q6Lnz/IxhEOT ksh2YzCXnbSEiBagrLHP0ONwcbubTqU7N6/vRhtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xunlei Pang , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 013/221] blk-cgroup: Fix the recursive blkg rwstat Date: Mon, 29 Mar 2021 09:55:44 +0200 Message-Id: <20210329075629.620477384@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xunlei Pang [ Upstream commit 4f44657d74873735e93a50eb25014721a66aac19 ] 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(). Signed-off-by: Xunlei Pang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 85d5790ac49b..3304e841df7c 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(); } -- 2.30.1