cgroup: rstat: punt root-level optimization to individual controllers
[sfrench/cifs-2.6.git] / block / blk-cgroup.c
index a317c03d40f6e1ff6a1f4aa5b7f0f214665e63b7..582d2f18717ee3c1cd767332471a3612b19f35bc 100644 (file)
@@ -764,6 +764,10 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)
        struct blkcg *blkcg = css_to_blkcg(css);
        struct blkcg_gq *blkg;
 
+       /* Root-level stats are sourced from system-wide IO stats */
+       if (!cgroup_parent(css->cgroup))
+               return;
+
        rcu_read_lock();
 
        hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
@@ -786,8 +790,8 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)
                blkg_iostat_add(&bisc->last, &delta);
                u64_stats_update_end(&blkg->iostat.sync);
 
-               /* propagate global delta to parent */
-               if (parent) {
+               /* propagate global delta to parent (unless that's root) */
+               if (parent && parent->parent) {
                        u64_stats_update_begin(&parent->iostat.sync);
                        blkg_iostat_set(&delta, &blkg->iostat.cur);
                        blkg_iostat_sub(&delta, &blkg->iostat.last);
@@ -801,10 +805,11 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)
 }
 
 /*
- * The rstat algorithms intentionally don't handle the root cgroup to avoid
- * incurring overhead when no cgroups are defined. For that reason,
- * cgroup_rstat_flush in blkcg_print_stat does not actually fill out the
- * iostat in the root cgroup's blkcg_gq.
+ * We source root cgroup stats from the system-wide stats to avoid
+ * tracking the same information twice and incurring overhead when no
+ * cgroups are defined. For that reason, cgroup_rstat_flush in
+ * blkcg_print_stat does not actually fill out the iostat in the root
+ * cgroup's blkcg_gq.
  *
  * However, we would like to re-use the printing code between the root and
  * non-root cgroups to the extent possible. For that reason, we simulate