From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Paolo Valente <paolo.valente@linaro.org>,
linux-block@vger.kernel.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/6] blk-cgroup: factor out a helper to read rwstat counter
Date: Thu, 6 Jun 2019 12:26:19 +0200 [thread overview]
Message-ID: <20190606102624.3847-2-hch@lst.de> (raw)
In-Reply-To: <20190606102624.3847-1-hch@lst.de>
Trying to break up the crazy statements to something readable.
Also switch to an unsigned counter as it can't ever turn negative.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 5 ++---
include/linux/blk-cgroup.h | 7 +++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index b97b479e4f64..6f79ace02be4 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -750,7 +750,7 @@ struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkcg_gq *blkg,
struct blkcg_gq *pos_blkg;
struct cgroup_subsys_state *pos_css;
struct blkg_rwstat sum = { };
- int i;
+ unsigned int i;
lockdep_assert_held(&blkg->q->queue_lock);
@@ -767,8 +767,7 @@ struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkcg_gq *blkg,
rwstat = (void *)pos_blkg + off;
for (i = 0; i < BLKG_RWSTAT_NR; i++)
- atomic64_add(atomic64_read(&rwstat->aux_cnt[i]) +
- percpu_counter_sum_positive(&rwstat->cpu_cnt[i]),
+ atomic64_add(blkg_rwstat_read_counter(rwstat, i),
&sum.aux_cnt[i]);
}
rcu_read_unlock();
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 76c61318fda5..06236f56a840 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -198,6 +198,13 @@ int blkcg_activate_policy(struct request_queue *q,
void blkcg_deactivate_policy(struct request_queue *q,
const struct blkcg_policy *pol);
+static inline u64 blkg_rwstat_read_counter(struct blkg_rwstat *rwstat,
+ unsigned int idx)
+{
+ return atomic64_read(&rwstat->aux_cnt[idx]) +
+ percpu_counter_sum_positive(&rwstat->cpu_cnt[idx]);
+}
+
const char *blkg_dev_name(struct blkcg_gq *blkg);
void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
u64 (*prfill)(struct seq_file *,
--
2.20.1
next prev parent reply other threads:[~2019-06-06 10:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 10:26 blk-cgroup cleanups Christoph Hellwig
2019-06-06 10:26 ` Christoph Hellwig [this message]
2019-06-06 15:03 ` [PATCH 1/6] blk-cgroup: factor out a helper to read rwstat counter Chaitanya Kulkarni
2019-06-06 10:26 ` [PATCH 2/6] blk-cgroup: pass blkg_rwstat structures by reference Christoph Hellwig
2019-06-06 10:26 ` [PATCH 3/6] blk-cgroup: introduce a new struct blkg_rwstat_sample Christoph Hellwig
2019-06-06 10:26 ` [PATCH 4/6] blk-cgroup: move struct blkg_stat to bfq Christoph Hellwig
2019-06-07 6:07 ` Paolo Valente
2019-06-06 10:26 ` [PATCH 5/6] bfq-iosched: move bfq_stat_recursive_sum into the only caller Christoph Hellwig
2019-06-07 6:07 ` Paolo Valente
2019-06-06 10:26 ` [PATCH 6/6] block: rename CONFIG_DEBUG_BLK_CGROUP to CONFIG_BFQ_CGROUP_DEBUG Christoph Hellwig
2019-06-07 6:07 ` Paolo Valente
2019-06-10 18:23 ` blk-cgroup cleanups Tejun Heo
2019-06-20 9:42 ` Christoph Hellwig
2019-06-20 16:32 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190606102624.3847-2-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).