Skip to content

Commit ddc2123

Browse files
arndbaxboe
authored andcommitted
blkcg: simplify statistic accumulation code
Some older compilers (gcc-4.4 through 4.6 in particular) struggle with the way that blkg_rwstat_read() returns a structure, leading to excessive stack usage and rather inefficient code: block/blk-cgroup.c: In function 'blkg_destroy': block/blk-cgroup.c:354:1: error: the frame size of 1296 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] block/cfq-iosched.c: In function 'cfqg_stats_add_aux': block/cfq-iosched.c:753:1: error: the frame size of 1928 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] block/bfq-cgroup.c: In function 'bfqg_stats_add_aux': block/bfq-cgroup.c:299:1: error: the frame size of 1928 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] I also notice that there is no point in using atomic accesses for the local variables, so storing the temporaries in simple 'u64' variables not only avoids the stack usage on older compilers but also improves the object code on modern versions. Fixes: e6269c4 ("blkcg: add blkg_[rw]stat->aux_cnt and replace cfq_group->dead_stats with it") Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c100ec4 commit ddc2123

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎include/linux/blk-cgroup.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,14 @@ static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
660660
static inline void blkg_rwstat_add_aux(struct blkg_rwstat *to,
661661
struct blkg_rwstat *from)
662662
{
663-
struct blkg_rwstat v = blkg_rwstat_read(from);
663+
u64 sum[BLKG_RWSTAT_NR];
664664
int i;
665665

666666
for (i = 0; i < BLKG_RWSTAT_NR; i++)
667-
atomic64_add(atomic64_read(&v.aux_cnt[i]) +
668-
atomic64_read(&from->aux_cnt[i]),
667+
sum[i] = percpu_counter_sum_positive(&from->cpu_cnt[i]);
668+
669+
for (i = 0; i < BLKG_RWSTAT_NR; i++)
670+
atomic64_add(sum[i] + atomic64_read(&from->aux_cnt[i]),
669671
&to->aux_cnt[i]);
670672
}
671673

0 commit comments

Comments
 (0)