Commit 702747ca authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

blkcg: remove cfqg_stats->sectors

cfq_stats->sectors is a blkg_stat which keeps track of the total
number of sectors serviced; however, this can be trivially calculated
from blkcg_gq->stat_bytes.  The only thing necessary is adding up
READs and WRITEs and then dividing by sector size.

Remove cfqg_stats->sectors and make cfq print "sectors" and
"sectors_recursive" from stat_bytes.

While this is a bit more code, it removes duplicate stat allocations
and updates and ensures that the reported stats stay in tune with each
other.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 77ea7338
...@@ -185,8 +185,6 @@ struct cfqg_stats { ...@@ -185,8 +185,6 @@ struct cfqg_stats {
struct blkg_rwstat wait_time; struct blkg_rwstat wait_time;
/* number of IOs queued up */ /* number of IOs queued up */
struct blkg_rwstat queued; struct blkg_rwstat queued;
/* total sectors transferred */
struct blkg_stat sectors;
/* total disk time and nr sectors dispatched by this group */ /* total disk time and nr sectors dispatched by this group */
struct blkg_stat time; struct blkg_stat time;
#ifdef CONFIG_DEBUG_BLK_CGROUP #ifdef CONFIG_DEBUG_BLK_CGROUP
...@@ -688,12 +686,6 @@ static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw) ...@@ -688,12 +686,6 @@ static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw)
blkg_rwstat_add(&cfqg->stats.merged, rw, 1); blkg_rwstat_add(&cfqg->stats.merged, rw, 1);
} }
static inline void cfqg_stats_update_dispatch(struct cfq_group *cfqg,
uint64_t bytes, int rw)
{
blkg_stat_add(&cfqg->stats.sectors, bytes >> 9);
}
static inline void cfqg_stats_update_completion(struct cfq_group *cfqg, static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
uint64_t start_time, uint64_t io_start_time, int rw) uint64_t start_time, uint64_t io_start_time, int rw)
{ {
...@@ -782,8 +774,6 @@ static inline void cfqg_stats_update_timeslice_used(struct cfq_group *cfqg, ...@@ -782,8 +774,6 @@ static inline void cfqg_stats_update_timeslice_used(struct cfq_group *cfqg,
unsigned long time, unsigned long unaccounted_time) { } unsigned long time, unsigned long unaccounted_time) { }
static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw) { } static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw) { }
static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw) { } static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw) { }
static inline void cfqg_stats_update_dispatch(struct cfq_group *cfqg,
uint64_t bytes, int rw) { }
static inline void cfqg_stats_update_completion(struct cfq_group *cfqg, static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
uint64_t start_time, uint64_t io_start_time, int rw) { } uint64_t start_time, uint64_t io_start_time, int rw) { }
...@@ -1538,8 +1528,6 @@ static void cfqg_stats_exit(struct cfqg_stats *stats) ...@@ -1538,8 +1528,6 @@ static void cfqg_stats_exit(struct cfqg_stats *stats)
blkg_rwstat_exit(&stats->service_time); blkg_rwstat_exit(&stats->service_time);
blkg_rwstat_exit(&stats->wait_time); blkg_rwstat_exit(&stats->wait_time);
blkg_rwstat_exit(&stats->queued); blkg_rwstat_exit(&stats->queued);
blkg_stat_exit(&stats->sectors);
blkg_stat_exit(&stats->time); blkg_stat_exit(&stats->time);
#ifdef CONFIG_DEBUG_BLK_CGROUP #ifdef CONFIG_DEBUG_BLK_CGROUP
blkg_stat_exit(&stats->unaccounted_time); blkg_stat_exit(&stats->unaccounted_time);
...@@ -1558,8 +1546,6 @@ static int cfqg_stats_init(struct cfqg_stats *stats, gfp_t gfp) ...@@ -1558,8 +1546,6 @@ static int cfqg_stats_init(struct cfqg_stats *stats, gfp_t gfp)
blkg_rwstat_init(&stats->service_time, gfp) || blkg_rwstat_init(&stats->service_time, gfp) ||
blkg_rwstat_init(&stats->wait_time, gfp) || blkg_rwstat_init(&stats->wait_time, gfp) ||
blkg_rwstat_init(&stats->queued, gfp) || blkg_rwstat_init(&stats->queued, gfp) ||
blkg_stat_init(&stats->sectors, gfp) ||
blkg_stat_init(&stats->time, gfp)) blkg_stat_init(&stats->time, gfp))
goto err; goto err;
...@@ -1901,6 +1887,40 @@ static int cfqg_print_rwstat_recursive(struct seq_file *sf, void *v) ...@@ -1901,6 +1887,40 @@ static int cfqg_print_rwstat_recursive(struct seq_file *sf, void *v)
return 0; return 0;
} }
static u64 cfqg_prfill_sectors(struct seq_file *sf, struct blkg_policy_data *pd,
int off)
{
u64 sum = blkg_rwstat_total(&pd->blkg->stat_bytes);
return __blkg_prfill_u64(sf, pd, sum >> 9);
}
static int cfqg_print_stat_sectors(struct seq_file *sf, void *v)
{
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)),
cfqg_prfill_sectors, &blkcg_policy_cfq, 0, false);
return 0;
}
static u64 cfqg_prfill_sectors_recursive(struct seq_file *sf,
struct blkg_policy_data *pd, int off)
{
struct blkg_rwstat tmp = blkg_rwstat_recursive_sum(pd->blkg, NULL,
offsetof(struct blkcg_gq, stat_bytes));
u64 sum = atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_READ]) +
atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_WRITE]);
return __blkg_prfill_u64(sf, pd, sum >> 9);
}
static int cfqg_print_stat_sectors_recursive(struct seq_file *sf, void *v)
{
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)),
cfqg_prfill_sectors_recursive, &blkcg_policy_cfq, 0,
false);
return 0;
}
#ifdef CONFIG_DEBUG_BLK_CGROUP #ifdef CONFIG_DEBUG_BLK_CGROUP
static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,
struct blkg_policy_data *pd, int off) struct blkg_policy_data *pd, int off)
...@@ -1975,8 +1995,7 @@ static struct cftype cfq_blkcg_files[] = { ...@@ -1975,8 +1995,7 @@ static struct cftype cfq_blkcg_files[] = {
}, },
{ {
.name = "sectors", .name = "sectors",
.private = offsetof(struct cfq_group, stats.sectors), .seq_show = cfqg_print_stat_sectors,
.seq_show = cfqg_print_stat,
}, },
{ {
.name = "io_service_bytes", .name = "io_service_bytes",
...@@ -2017,8 +2036,7 @@ static struct cftype cfq_blkcg_files[] = { ...@@ -2017,8 +2036,7 @@ static struct cftype cfq_blkcg_files[] = {
}, },
{ {
.name = "sectors_recursive", .name = "sectors_recursive",
.private = offsetof(struct cfq_group, stats.sectors), .seq_show = cfqg_print_stat_sectors_recursive,
.seq_show = cfqg_print_stat_recursive,
}, },
{ {
.name = "io_service_bytes_recursive", .name = "io_service_bytes_recursive",
...@@ -2888,7 +2906,6 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq) ...@@ -2888,7 +2906,6 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]++; cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]++;
cfqq->nr_sectors += blk_rq_sectors(rq); cfqq->nr_sectors += blk_rq_sectors(rq);
cfqg_stats_update_dispatch(cfqq->cfqg, blk_rq_bytes(rq), rq->cmd_flags);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment