diff options
author | Christoph Hellwig <hch@lst.de> | 2019-06-06 06:26:21 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-06-20 12:32:34 -0400 |
commit | 7af6fd9112ba310a889c60d0606b4b74049cfe14 (patch) | |
tree | 82110ea85453bdc5860bdba93d791f8f367070e7 /block | |
parent | 5d0b6e48cbef3219c0ed75e0e746c4ed259303c2 (diff) |
blk-cgroup: introduce a new struct blkg_rwstat_sample
When sampling the blkcg counts we don't need atomics or per-cpu
variables. Introduce a new structure just containing plain u64
counters.
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/bfq-cgroup.c | 10 | ||||
-rw-r--r-- | block/blk-cgroup.c | 39 |
2 files changed, 23 insertions, 26 deletions
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 66abc82179f3..624374a99c6e 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c | |||
@@ -935,7 +935,7 @@ static u64 bfqg_prfill_stat_recursive(struct seq_file *sf, | |||
935 | static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf, | 935 | static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf, |
936 | struct blkg_policy_data *pd, int off) | 936 | struct blkg_policy_data *pd, int off) |
937 | { | 937 | { |
938 | struct blkg_rwstat sum; | 938 | struct blkg_rwstat_sample sum; |
939 | 939 | ||
940 | blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off, &sum); | 940 | blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off, &sum); |
941 | return __blkg_prfill_rwstat(sf, pd, &sum); | 941 | return __blkg_prfill_rwstat(sf, pd, &sum); |
@@ -975,15 +975,13 @@ static int bfqg_print_stat_sectors(struct seq_file *sf, void *v) | |||
975 | static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf, | 975 | static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf, |
976 | struct blkg_policy_data *pd, int off) | 976 | struct blkg_policy_data *pd, int off) |
977 | { | 977 | { |
978 | struct blkg_rwstat tmp; | 978 | struct blkg_rwstat_sample tmp; |
979 | u64 sum; | ||
980 | 979 | ||
981 | blkg_rwstat_recursive_sum(pd->blkg, NULL, | 980 | blkg_rwstat_recursive_sum(pd->blkg, NULL, |
982 | offsetof(struct blkcg_gq, stat_bytes), &tmp); | 981 | offsetof(struct blkcg_gq, stat_bytes), &tmp); |
983 | sum = atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_READ]) + | ||
984 | atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_WRITE]); | ||
985 | 982 | ||
986 | return __blkg_prfill_u64(sf, pd, sum >> 9); | 983 | return __blkg_prfill_u64(sf, pd, |
984 | (tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE]) >> 9); | ||
987 | } | 985 | } |
988 | 986 | ||
989 | static int bfqg_print_stat_sectors_recursive(struct seq_file *sf, void *v) | 987 | static int bfqg_print_stat_sectors_recursive(struct seq_file *sf, void *v) |
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index db039a869d95..664c09866839 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -544,7 +544,7 @@ EXPORT_SYMBOL_GPL(__blkg_prfill_u64); | |||
544 | * Print @rwstat to @sf for the device assocaited with @pd. | 544 | * Print @rwstat to @sf for the device assocaited with @pd. |
545 | */ | 545 | */ |
546 | u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | 546 | u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, |
547 | const struct blkg_rwstat *rwstat) | 547 | const struct blkg_rwstat_sample *rwstat) |
548 | { | 548 | { |
549 | static const char *rwstr[] = { | 549 | static const char *rwstr[] = { |
550 | [BLKG_RWSTAT_READ] = "Read", | 550 | [BLKG_RWSTAT_READ] = "Read", |
@@ -562,12 +562,12 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | |||
562 | 562 | ||
563 | for (i = 0; i < BLKG_RWSTAT_NR; i++) | 563 | for (i = 0; i < BLKG_RWSTAT_NR; i++) |
564 | seq_printf(sf, "%s %s %llu\n", dname, rwstr[i], | 564 | seq_printf(sf, "%s %s %llu\n", dname, rwstr[i], |
565 | (unsigned long long)atomic64_read(&rwstat->aux_cnt[i])); | 565 | rwstat->cnt[i]); |
566 | 566 | ||
567 | v = atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_READ]) + | 567 | v = rwstat->cnt[BLKG_RWSTAT_READ] + |
568 | atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_WRITE]) + | 568 | rwstat->cnt[BLKG_RWSTAT_WRITE] + |
569 | atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_DISCARD]); | 569 | rwstat->cnt[BLKG_RWSTAT_DISCARD]; |
570 | seq_printf(sf, "%s Total %llu\n", dname, (unsigned long long)v); | 570 | seq_printf(sf, "%s Total %llu\n", dname, v); |
571 | return v; | 571 | return v; |
572 | } | 572 | } |
573 | EXPORT_SYMBOL_GPL(__blkg_prfill_rwstat); | 573 | EXPORT_SYMBOL_GPL(__blkg_prfill_rwstat); |
@@ -597,7 +597,7 @@ EXPORT_SYMBOL_GPL(blkg_prfill_stat); | |||
597 | u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | 597 | u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, |
598 | int off) | 598 | int off) |
599 | { | 599 | { |
600 | struct blkg_rwstat rwstat = { }; | 600 | struct blkg_rwstat_sample rwstat = { }; |
601 | 601 | ||
602 | blkg_rwstat_read((void *)pd + off, &rwstat); | 602 | blkg_rwstat_read((void *)pd + off, &rwstat); |
603 | return __blkg_prfill_rwstat(sf, pd, &rwstat); | 603 | return __blkg_prfill_rwstat(sf, pd, &rwstat); |
@@ -607,7 +607,7 @@ EXPORT_SYMBOL_GPL(blkg_prfill_rwstat); | |||
607 | static u64 blkg_prfill_rwstat_field(struct seq_file *sf, | 607 | static u64 blkg_prfill_rwstat_field(struct seq_file *sf, |
608 | struct blkg_policy_data *pd, int off) | 608 | struct blkg_policy_data *pd, int off) |
609 | { | 609 | { |
610 | struct blkg_rwstat rwstat = { }; | 610 | struct blkg_rwstat_sample rwstat = { }; |
611 | 611 | ||
612 | blkg_rwstat_read((void *)pd->blkg + off, &rwstat); | 612 | blkg_rwstat_read((void *)pd->blkg + off, &rwstat); |
613 | return __blkg_prfill_rwstat(sf, pd, &rwstat); | 613 | return __blkg_prfill_rwstat(sf, pd, &rwstat); |
@@ -651,7 +651,7 @@ static u64 blkg_prfill_rwstat_field_recursive(struct seq_file *sf, | |||
651 | struct blkg_policy_data *pd, | 651 | struct blkg_policy_data *pd, |
652 | int off) | 652 | int off) |
653 | { | 653 | { |
654 | struct blkg_rwstat rwstat; | 654 | struct blkg_rwstat_sample rwstat; |
655 | 655 | ||
656 | blkg_rwstat_recursive_sum(pd->blkg, NULL, off, &rwstat); | 656 | blkg_rwstat_recursive_sum(pd->blkg, NULL, off, &rwstat); |
657 | return __blkg_prfill_rwstat(sf, pd, &rwstat); | 657 | return __blkg_prfill_rwstat(sf, pd, &rwstat); |
@@ -734,7 +734,7 @@ EXPORT_SYMBOL_GPL(blkg_stat_recursive_sum); | |||
734 | * @blkg: blkg of interest | 734 | * @blkg: blkg of interest |
735 | * @pol: blkcg_policy which contains the blkg_rwstat | 735 | * @pol: blkcg_policy which contains the blkg_rwstat |
736 | * @off: offset to the blkg_rwstat in blkg_policy_data or @blkg | 736 | * @off: offset to the blkg_rwstat in blkg_policy_data or @blkg |
737 | * @sum: blkg_rwstat structure containing the results | 737 | * @sum: blkg_rwstat_sample structure containing the results |
738 | * | 738 | * |
739 | * Collect the blkg_rwstat specified by @blkg, @pol and @off and all its | 739 | * Collect the blkg_rwstat specified by @blkg, @pol and @off and all its |
740 | * online descendants and their aux counts. The caller must be holding the | 740 | * online descendants and their aux counts. The caller must be holding the |
@@ -744,7 +744,7 @@ EXPORT_SYMBOL_GPL(blkg_stat_recursive_sum); | |||
744 | * is at @off bytes into @blkg's blkg_policy_data of the policy. | 744 | * is at @off bytes into @blkg's blkg_policy_data of the policy. |
745 | */ | 745 | */ |
746 | void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol, | 746 | void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol, |
747 | int off, struct blkg_rwstat *sum) | 747 | int off, struct blkg_rwstat_sample *sum) |
748 | { | 748 | { |
749 | struct blkcg_gq *pos_blkg; | 749 | struct blkcg_gq *pos_blkg; |
750 | struct cgroup_subsys_state *pos_css; | 750 | struct cgroup_subsys_state *pos_css; |
@@ -765,8 +765,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol, | |||
765 | rwstat = (void *)pos_blkg + off; | 765 | rwstat = (void *)pos_blkg + off; |
766 | 766 | ||
767 | for (i = 0; i < BLKG_RWSTAT_NR; i++) | 767 | for (i = 0; i < BLKG_RWSTAT_NR; i++) |
768 | atomic64_set(&sum->aux_cnt[i], | 768 | sum->cnt[i] = blkg_rwstat_read_counter(rwstat, i); |
769 | blkg_rwstat_read_counter(rwstat, i)); | ||
770 | } | 769 | } |
771 | rcu_read_unlock(); | 770 | rcu_read_unlock(); |
772 | } | 771 | } |
@@ -934,7 +933,7 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) | |||
934 | hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) { | 933 | hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) { |
935 | const char *dname; | 934 | const char *dname; |
936 | char *buf; | 935 | char *buf; |
937 | struct blkg_rwstat rwstat; | 936 | struct blkg_rwstat_sample rwstat; |
938 | u64 rbytes, wbytes, rios, wios, dbytes, dios; | 937 | u64 rbytes, wbytes, rios, wios, dbytes, dios; |
939 | size_t size = seq_get_buf(sf, &buf), off = 0; | 938 | size_t size = seq_get_buf(sf, &buf), off = 0; |
940 | int i; | 939 | int i; |
@@ -956,15 +955,15 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) | |||
956 | 955 | ||
957 | blkg_rwstat_recursive_sum(blkg, NULL, | 956 | blkg_rwstat_recursive_sum(blkg, NULL, |
958 | offsetof(struct blkcg_gq, stat_bytes), &rwstat); | 957 | offsetof(struct blkcg_gq, stat_bytes), &rwstat); |
959 | rbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); | 958 | rbytes = rwstat.cnt[BLKG_RWSTAT_READ]; |
960 | wbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); | 959 | wbytes = rwstat.cnt[BLKG_RWSTAT_WRITE]; |
961 | dbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]); | 960 | dbytes = rwstat.cnt[BLKG_RWSTAT_DISCARD]; |
962 | 961 | ||
963 | blkg_rwstat_recursive_sum(blkg, NULL, | 962 | blkg_rwstat_recursive_sum(blkg, NULL, |
964 | offsetof(struct blkcg_gq, stat_ios), &rwstat); | 963 | offsetof(struct blkcg_gq, stat_ios), &rwstat); |
965 | rios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); | 964 | rios = rwstat.cnt[BLKG_RWSTAT_READ]; |
966 | wios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); | 965 | wios = rwstat.cnt[BLKG_RWSTAT_WRITE]; |
967 | dios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]); | 966 | dios = rwstat.cnt[BLKG_RWSTAT_DISCARD]; |
968 | 967 | ||
969 | spin_unlock_irq(&blkg->q->queue_lock); | 968 | spin_unlock_irq(&blkg->q->queue_lock); |
970 | 969 | ||