]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - block/bfq-cgroup.c
bfq-iosched: stop using blkg->stat_bytes and ->stat_ios
[mirror_ubuntu-hirsute-kernel.git] / block / bfq-cgroup.c
index d4755d4ad009c073a0725e329a567c54f89d78d5..cea0ae12f93783df801a2b85fc2d73cbea994f3c 100644 (file)
@@ -347,6 +347,14 @@ void bfqg_and_blkg_put(struct bfq_group *bfqg)
        bfqg_put(bfqg);
 }
 
+void bfqg_stats_update_legacy_io(struct request_queue *q, struct request *rq)
+{
+       struct bfq_group *bfqg = blkg_to_bfqg(rq->bio->bi_blkg);
+
+       blkg_rwstat_add(&bfqg->stats.bytes, rq->cmd_flags, blk_rq_bytes(rq));
+       blkg_rwstat_add(&bfqg->stats.ios, rq->cmd_flags, 1);
+}
+
 /* @stats = 0 */
 static void bfqg_stats_reset(struct bfqg_stats *stats)
 {
@@ -431,6 +439,8 @@ void bfq_init_entity(struct bfq_entity *entity, struct bfq_group *bfqg)
 
 static void bfqg_stats_exit(struct bfqg_stats *stats)
 {
+       blkg_rwstat_exit(&stats->bytes);
+       blkg_rwstat_exit(&stats->ios);
 #ifdef CONFIG_BFQ_CGROUP_DEBUG
        blkg_rwstat_exit(&stats->merged);
        blkg_rwstat_exit(&stats->service_time);
@@ -448,6 +458,10 @@ static void bfqg_stats_exit(struct bfqg_stats *stats)
 
 static int bfqg_stats_init(struct bfqg_stats *stats, gfp_t gfp)
 {
+       if (blkg_rwstat_init(&stats->bytes, gfp) ||
+           blkg_rwstat_init(&stats->ios, gfp))
+               return -ENOMEM;
+
 #ifdef CONFIG_BFQ_CGROUP_DEBUG
        if (blkg_rwstat_init(&stats->merged, gfp) ||
            blkg_rwstat_init(&stats->service_time, gfp) ||
@@ -1057,7 +1071,6 @@ static ssize_t bfq_io_set_weight(struct kernfs_open_file *of,
        return bfq_io_set_device_weight(of, buf, nbytes, off);
 }
 
-#ifdef CONFIG_BFQ_CGROUP_DEBUG
 static int bfqg_print_rwstat(struct seq_file *sf, void *v)
 {
        blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat,
@@ -1082,6 +1095,7 @@ static int bfqg_print_rwstat_recursive(struct seq_file *sf, void *v)
        return 0;
 }
 
+#ifdef CONFIG_BFQ_CGROUP_DEBUG
 static int bfqg_print_stat(struct seq_file *sf, void *v)
 {
        blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_stat,
@@ -1125,7 +1139,8 @@ static int bfqg_print_stat_recursive(struct seq_file *sf, void *v)
 static u64 bfqg_prfill_sectors(struct seq_file *sf, struct blkg_policy_data *pd,
                               int off)
 {
-       u64 sum = blkg_rwstat_total(&pd->blkg->stat_bytes);
+       struct bfq_group *bfqg = blkg_to_bfqg(pd->blkg);
+       u64 sum = blkg_rwstat_total(&bfqg->stats.bytes);
 
        return __blkg_prfill_u64(sf, pd, sum >> 9);
 }
@@ -1142,8 +1157,8 @@ static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf,
 {
        struct blkg_rwstat_sample tmp;
 
-       blkg_rwstat_recursive_sum(pd->blkg, NULL,
-                       offsetof(struct blkcg_gq, stat_bytes), &tmp);
+       blkg_rwstat_recursive_sum(pd->blkg, &blkcg_policy_bfq,
+                       offsetof(struct bfq_group, stats.bytes), &tmp);
 
        return __blkg_prfill_u64(sf, pd,
                (tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE]) >> 9);
@@ -1226,13 +1241,13 @@ struct cftype bfq_blkcg_legacy_files[] = {
        /* statistics, covers only the tasks in the bfqg */
        {
                .name = "bfq.io_service_bytes",
-               .private = (unsigned long)&blkcg_policy_bfq,
-               .seq_show = blkg_print_stat_bytes,
+               .private = offsetof(struct bfq_group, stats.bytes),
+               .seq_show = bfqg_print_rwstat,
        },
        {
                .name = "bfq.io_serviced",
-               .private = (unsigned long)&blkcg_policy_bfq,
-               .seq_show = blkg_print_stat_ios,
+               .private = offsetof(struct bfq_group, stats.ios),
+               .seq_show = bfqg_print_rwstat,
        },
 #ifdef CONFIG_BFQ_CGROUP_DEBUG
        {
@@ -1269,13 +1284,13 @@ struct cftype bfq_blkcg_legacy_files[] = {
        /* the same statistics which cover the bfqg and its descendants */
        {
                .name = "bfq.io_service_bytes_recursive",
-               .private = (unsigned long)&blkcg_policy_bfq,
-               .seq_show = blkg_print_stat_bytes_recursive,
+               .private = offsetof(struct bfq_group, stats.bytes),
+               .seq_show = bfqg_print_rwstat_recursive,
        },
        {
                .name = "bfq.io_serviced_recursive",
-               .private = (unsigned long)&blkcg_policy_bfq,
-               .seq_show = blkg_print_stat_ios_recursive,
+               .private = offsetof(struct bfq_group, stats.ios),
+               .seq_show = bfqg_print_rwstat_recursive,
        },
 #ifdef CONFIG_BFQ_CGROUP_DEBUG
        {