summaryrefslogtreecommitdiffstats
path: root/block/bfq-cgroup.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-06 06:26:23 -0400
committerJens Axboe <axboe@kernel.dk>2019-06-20 12:32:34 -0400
commitd6258980daf207f986676e59e6ea295204cdc84e (patch)
treee6d24147a5ada8d78231e7a5271ea1eb33befb2b /block/bfq-cgroup.c
parentc0ce79dca5b0e8373a546ebea2af7b3df94c584e (diff)
bfq-iosched: move bfq_stat_recursive_sum into the only caller
This function was moved from core block code and is way to generic. Fold it into the only caller and simplify it based on the actually passed arguments. Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bfq-cgroup.c')
-rw-r--r--block/bfq-cgroup.c62
1 files changed, 19 insertions, 43 deletions
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index a691dca7e966..d84302445e30 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -81,47 +81,6 @@ static inline void bfq_stat_add_aux(struct bfq_stat *to,
81} 81}
82 82
83/** 83/**
84 * bfq_stat_recursive_sum - collect hierarchical bfq_stat
85 * @blkg: blkg of interest
86 * @pol: blkcg_policy which contains the bfq_stat
87 * @off: offset to the bfq_stat in blkg_policy_data or @blkg
88 *
89 * Collect the bfq_stat specified by @blkg, @pol and @off and all its
90 * online descendants and their aux counts. The caller must be holding the
91 * queue lock for online tests.
92 *
93 * If @pol is NULL, bfq_stat is at @off bytes into @blkg; otherwise, it is
94 * at @off bytes into @blkg's blkg_policy_data of the policy.
95 */
96static u64 bfq_stat_recursive_sum(struct blkcg_gq *blkg,
97 struct blkcg_policy *pol, int off)
98{
99 struct blkcg_gq *pos_blkg;
100 struct cgroup_subsys_state *pos_css;
101 u64 sum = 0;
102
103 lockdep_assert_held(&blkg->q->queue_lock);
104
105 rcu_read_lock();
106 blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
107 struct bfq_stat *stat;
108
109 if (!pos_blkg->online)
110 continue;
111
112 if (pol)
113 stat = (void *)blkg_to_pd(pos_blkg, pol) + off;
114 else
115 stat = (void *)blkg + off;
116
117 sum += bfq_stat_read(stat) + atomic64_read(&stat->aux_cnt);
118 }
119 rcu_read_unlock();
120
121 return sum;
122}
123
124/**
125 * blkg_prfill_stat - prfill callback for bfq_stat 84 * blkg_prfill_stat - prfill callback for bfq_stat
126 * @sf: seq_file to print to 85 * @sf: seq_file to print to
127 * @pd: policy private data of interest 86 * @pd: policy private data of interest
@@ -1045,8 +1004,25 @@ static int bfqg_print_rwstat(struct seq_file *sf, void *v)
1045static u64 bfqg_prfill_stat_recursive(struct seq_file *sf, 1004static u64 bfqg_prfill_stat_recursive(struct seq_file *sf,
1046 struct blkg_policy_data *pd, int off) 1005 struct blkg_policy_data *pd, int off)
1047{ 1006{
1048 u64 sum = bfq_stat_recursive_sum(pd_to_blkg(pd), 1007 struct blkcg_gq *blkg = pd_to_blkg(pd);
1049 &blkcg_policy_bfq, off); 1008 struct blkcg_gq *pos_blkg;
1009 struct cgroup_subsys_state *pos_css;
1010 u64 sum = 0;
1011
1012 lockdep_assert_held(&blkg->q->queue_lock);
1013
1014 rcu_read_lock();
1015 blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
1016 struct bfq_stat *stat;
1017
1018 if (!pos_blkg->online)
1019 continue;
1020
1021 stat = (void *)blkg_to_pd(pos_blkg, &blkcg_policy_bfq) + off;
1022 sum += bfq_stat_read(stat) + atomic64_read(&stat->aux_cnt);
1023 }
1024 rcu_read_unlock();
1025
1050 return __blkg_prfill_u64(sf, pd, sum); 1026 return __blkg_prfill_u64(sf, pd, sum);
1051} 1027}
1052 1028