diff options
author | Tejun Heo <tj@kernel.org> | 2015-08-18 17:55:23 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-08-18 18:49:17 -0400 |
commit | f12c74cab1635d67077ce8cc40da88b57980f637 (patch) | |
tree | 250f9f3c6aa271f8a6899da86598666f67bce20c | |
parent | 24bdb8ef068ebdc2a57ce715f0ab22d5da32832a (diff) |
blkcg: make blkg_[rw]stat_recursive_sum() to be able to index into blkcg_gq
Currently, blkg_[rw]stat_recursive_sum() assume that the target
counter is located in pd (blkg_policy_data); however, some counters
are planned to be moved to blkg (blkcg_gq).
This patch updates blkg_[rw]stat_recursive_sum() to take blkg and
blkg_policy pointers instead of pd. If policy is NULL, it indexes
into blkg. If non-NULL, into the blkg's pd of the policy.
The existing usages are updated to maintain the current behaviors.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/blk-cgroup.c | 69 | ||||
-rw-r--r-- | block/cfq-iosched.c | 8 | ||||
-rw-r--r-- | include/linux/blk-cgroup.h | 7 |
3 files changed, 50 insertions, 34 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 02a2d029b5a5..b26320720a3c 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -581,30 +581,39 @@ EXPORT_SYMBOL_GPL(blkg_prfill_rwstat); | |||
581 | 581 | ||
582 | /** | 582 | /** |
583 | * blkg_stat_recursive_sum - collect hierarchical blkg_stat | 583 | * blkg_stat_recursive_sum - collect hierarchical blkg_stat |
584 | * @pd: policy private data of interest | 584 | * @blkg: blkg of interest |
585 | * @off: offset to the blkg_stat in @pd | 585 | * @pol: blkcg_policy which contains the blkg_stat |
586 | * @off: offset to the blkg_stat in blkg_policy_data or @blkg | ||
586 | * | 587 | * |
587 | * Collect the blkg_stat specified by @off from @pd and all its online | 588 | * Collect the blkg_stat specified by @blkg, @pol and @off and all its |
588 | * descendants and their aux counts. The caller must be holding the queue | 589 | * online descendants and their aux counts. The caller must be holding the |
589 | * lock for online tests. | 590 | * queue lock for online tests. |
591 | * | ||
592 | * If @pol is NULL, blkg_stat is at @off bytes into @blkg; otherwise, it is | ||
593 | * at @off bytes into @blkg's blkg_policy_data of the policy. | ||
590 | */ | 594 | */ |
591 | u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off) | 595 | u64 blkg_stat_recursive_sum(struct blkcg_gq *blkg, |
596 | struct blkcg_policy *pol, int off) | ||
592 | { | 597 | { |
593 | struct blkcg_policy *pol = blkcg_policy[pd->plid]; | ||
594 | struct blkcg_gq *pos_blkg; | 598 | struct blkcg_gq *pos_blkg; |
595 | struct cgroup_subsys_state *pos_css; | 599 | struct cgroup_subsys_state *pos_css; |
596 | u64 sum = 0; | 600 | u64 sum = 0; |
597 | 601 | ||
598 | lockdep_assert_held(pd->blkg->q->queue_lock); | 602 | lockdep_assert_held(blkg->q->queue_lock); |
599 | 603 | ||
600 | rcu_read_lock(); | 604 | rcu_read_lock(); |
601 | blkg_for_each_descendant_pre(pos_blkg, pos_css, pd_to_blkg(pd)) { | 605 | blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) { |
602 | struct blkg_policy_data *pos_pd = blkg_to_pd(pos_blkg, pol); | 606 | struct blkg_stat *stat; |
603 | struct blkg_stat *stat = (void *)pos_pd + off; | 607 | |
608 | if (!pos_blkg->online) | ||
609 | continue; | ||
604 | 610 | ||
605 | if (pos_blkg->online) | 611 | if (pol) |
606 | sum += blkg_stat_read(stat) + | 612 | stat = (void *)blkg_to_pd(pos_blkg, pol) + off; |
607 | atomic64_read(&stat->aux_cnt); | 613 | else |
614 | stat = (void *)blkg + off; | ||
615 | |||
616 | sum += blkg_stat_read(stat) + atomic64_read(&stat->aux_cnt); | ||
608 | } | 617 | } |
609 | rcu_read_unlock(); | 618 | rcu_read_unlock(); |
610 | 619 | ||
@@ -614,33 +623,39 @@ EXPORT_SYMBOL_GPL(blkg_stat_recursive_sum); | |||
614 | 623 | ||
615 | /** | 624 | /** |
616 | * blkg_rwstat_recursive_sum - collect hierarchical blkg_rwstat | 625 | * blkg_rwstat_recursive_sum - collect hierarchical blkg_rwstat |
617 | * @pd: policy private data of interest | 626 | * @blkg: blkg of interest |
618 | * @off: offset to the blkg_stat in @pd | 627 | * @pol: blkcg_policy which contains the blkg_rwstat |
628 | * @off: offset to the blkg_rwstat in blkg_policy_data or @blkg | ||
619 | * | 629 | * |
620 | * Collect the blkg_rwstat specified by @off from @pd and all its online | 630 | * Collect the blkg_rwstat specified by @blkg, @pol and @off and all its |
621 | * descendants and their aux counts. The caller must be holding the queue | 631 | * online descendants and their aux counts. The caller must be holding the |
622 | * lock for online tests. | 632 | * queue lock for online tests. |
633 | * | ||
634 | * If @pol is NULL, blkg_rwstat is at @off bytes into @blkg; otherwise, it | ||
635 | * is at @off bytes into @blkg's blkg_policy_data of the policy. | ||
623 | */ | 636 | */ |
624 | struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd, | 637 | struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, |
625 | int off) | 638 | struct blkcg_policy *pol, int off) |
626 | { | 639 | { |
627 | struct blkcg_policy *pol = blkcg_policy[pd->plid]; | ||
628 | struct blkcg_gq *pos_blkg; | 640 | struct blkcg_gq *pos_blkg; |
629 | struct cgroup_subsys_state *pos_css; | 641 | struct cgroup_subsys_state *pos_css; |
630 | struct blkg_rwstat sum = { }; | 642 | struct blkg_rwstat sum = { }; |
631 | int i; | 643 | int i; |
632 | 644 | ||
633 | lockdep_assert_held(pd->blkg->q->queue_lock); | 645 | lockdep_assert_held(blkg->q->queue_lock); |
634 | 646 | ||
635 | rcu_read_lock(); | 647 | rcu_read_lock(); |
636 | blkg_for_each_descendant_pre(pos_blkg, pos_css, pd_to_blkg(pd)) { | 648 | blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) { |
637 | struct blkg_policy_data *pos_pd = blkg_to_pd(pos_blkg, pol); | 649 | struct blkg_rwstat *rwstat, tmp; |
638 | struct blkg_rwstat *rwstat = (void *)pos_pd + off; | ||
639 | struct blkg_rwstat tmp; | ||
640 | 650 | ||
641 | if (!pos_blkg->online) | 651 | if (!pos_blkg->online) |
642 | continue; | 652 | continue; |
643 | 653 | ||
654 | if (pol) | ||
655 | rwstat = (void *)blkg_to_pd(pos_blkg, pol) + off; | ||
656 | else | ||
657 | rwstat = (void *)pos_blkg + off; | ||
658 | |||
644 | tmp = blkg_rwstat_read(rwstat); | 659 | tmp = blkg_rwstat_read(rwstat); |
645 | 660 | ||
646 | for (i = 0; i < BLKG_RWSTAT_NR; i++) | 661 | for (i = 0; i < BLKG_RWSTAT_NR; i++) |
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 71e55c91ee98..e861cc1ebd62 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -1886,16 +1886,16 @@ static int cfqg_print_rwstat(struct seq_file *sf, void *v) | |||
1886 | static u64 cfqg_prfill_stat_recursive(struct seq_file *sf, | 1886 | static u64 cfqg_prfill_stat_recursive(struct seq_file *sf, |
1887 | struct blkg_policy_data *pd, int off) | 1887 | struct blkg_policy_data *pd, int off) |
1888 | { | 1888 | { |
1889 | u64 sum = blkg_stat_recursive_sum(pd, off); | 1889 | u64 sum = blkg_stat_recursive_sum(pd_to_blkg(pd), |
1890 | 1890 | &blkcg_policy_cfq, off); | |
1891 | return __blkg_prfill_u64(sf, pd, sum); | 1891 | return __blkg_prfill_u64(sf, pd, sum); |
1892 | } | 1892 | } |
1893 | 1893 | ||
1894 | static u64 cfqg_prfill_rwstat_recursive(struct seq_file *sf, | 1894 | static u64 cfqg_prfill_rwstat_recursive(struct seq_file *sf, |
1895 | struct blkg_policy_data *pd, int off) | 1895 | struct blkg_policy_data *pd, int off) |
1896 | { | 1896 | { |
1897 | struct blkg_rwstat sum = blkg_rwstat_recursive_sum(pd, off); | 1897 | struct blkg_rwstat sum = blkg_rwstat_recursive_sum(pd_to_blkg(pd), |
1898 | 1898 | &blkcg_policy_cfq, off); | |
1899 | return __blkg_prfill_rwstat(sf, pd, &sum); | 1899 | return __blkg_prfill_rwstat(sf, pd, &sum); |
1900 | } | 1900 | } |
1901 | 1901 | ||
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index fdc7ac08b1ce..4630ce8f9425 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h | |||
@@ -191,9 +191,10 @@ u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off); | |||
191 | u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | 191 | u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, |
192 | int off); | 192 | int off); |
193 | 193 | ||
194 | u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off); | 194 | u64 blkg_stat_recursive_sum(struct blkcg_gq *blkg, |
195 | struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd, | 195 | struct blkcg_policy *pol, int off); |
196 | int off); | 196 | struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, |
197 | struct blkcg_policy *pol, int off); | ||
197 | 198 | ||
198 | struct blkg_conf_ctx { | 199 | struct blkg_conf_ctx { |
199 | struct gendisk *disk; | 200 | struct gendisk *disk; |