aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2018-07-18 07:47:41 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-18 10:44:23 -0400
commit636620b66d5d4012c4a9c86206013964d3986c4f (patch)
tree89ecba6057c7ca99ee3a500438a6281b7c261faf /block/blk-cgroup.c
parentbdca3c87fb7ad1cc61d231d37eb0d8f90d001e0c (diff)
blkcg: Track DISCARD statistics and output them in cgroup io.stat
Add tracking of REQ_OP_DISCARD ios to the per-cgroup io.stat. Two fields, dbytes and dios, to respectively count the total bytes and number of discards are added. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Andy Newell <newella@fb.com> Cc: Michael Callahan <michaelcallahan@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 7e2c19ce1a08..1942357d7165 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -567,6 +567,7 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
567 [BLKG_RWSTAT_WRITE] = "Write", 567 [BLKG_RWSTAT_WRITE] = "Write",
568 [BLKG_RWSTAT_SYNC] = "Sync", 568 [BLKG_RWSTAT_SYNC] = "Sync",
569 [BLKG_RWSTAT_ASYNC] = "Async", 569 [BLKG_RWSTAT_ASYNC] = "Async",
570 [BLKG_RWSTAT_DISCARD] = "Discard",
570 }; 571 };
571 const char *dname = blkg_dev_name(pd->blkg); 572 const char *dname = blkg_dev_name(pd->blkg);
572 u64 v; 573 u64 v;
@@ -580,7 +581,8 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
580 (unsigned long long)atomic64_read(&rwstat->aux_cnt[i])); 581 (unsigned long long)atomic64_read(&rwstat->aux_cnt[i]));
581 582
582 v = atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_READ]) + 583 v = atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_READ]) +
583 atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_WRITE]); 584 atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_WRITE]) +
585 atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_DISCARD]);
584 seq_printf(sf, "%s Total %llu\n", dname, (unsigned long long)v); 586 seq_printf(sf, "%s Total %llu\n", dname, (unsigned long long)v);
585 return v; 587 return v;
586} 588}
@@ -959,7 +961,7 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
959 const char *dname; 961 const char *dname;
960 char *buf; 962 char *buf;
961 struct blkg_rwstat rwstat; 963 struct blkg_rwstat rwstat;
962 u64 rbytes, wbytes, rios, wios; 964 u64 rbytes, wbytes, rios, wios, dbytes, dios;
963 size_t size = seq_get_buf(sf, &buf), off = 0; 965 size_t size = seq_get_buf(sf, &buf), off = 0;
964 int i; 966 int i;
965 bool has_stats = false; 967 bool has_stats = false;
@@ -982,19 +984,22 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
982 offsetof(struct blkcg_gq, stat_bytes)); 984 offsetof(struct blkcg_gq, stat_bytes));
983 rbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); 985 rbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]);
984 wbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); 986 wbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]);
987 dbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]);
985 988
986 rwstat = blkg_rwstat_recursive_sum(blkg, NULL, 989 rwstat = blkg_rwstat_recursive_sum(blkg, NULL,
987 offsetof(struct blkcg_gq, stat_ios)); 990 offsetof(struct blkcg_gq, stat_ios));
988 rios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); 991 rios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]);
989 wios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); 992 wios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]);
993 dios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]);
990 994
991 spin_unlock_irq(blkg->q->queue_lock); 995 spin_unlock_irq(blkg->q->queue_lock);
992 996
993 if (rbytes || wbytes || rios || wios) { 997 if (rbytes || wbytes || rios || wios) {
994 has_stats = true; 998 has_stats = true;
995 off += scnprintf(buf+off, size-off, 999 off += scnprintf(buf+off, size-off,
996 "rbytes=%llu wbytes=%llu rios=%llu wios=%llu", 1000 "rbytes=%llu wbytes=%llu rios=%llu wios=%llu dbytes=%llu dios=%llu",
997 rbytes, wbytes, rios, wios); 1001 rbytes, wbytes, rios, wios,
1002 dbytes, dios);
998 } 1003 }
999 1004
1000 if (!blkcg_debug_stats) 1005 if (!blkcg_debug_stats)