Skip to content

Commit 4311401

Browse files
committed
cfq-iosched: add hierarchical cfq_group statistics
Unfortunately, at this point, there's no way to make the existing statistics hierarchical without creating nasty surprises for the existing users. Just create recursive counterpart of the existing stats. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Vivek Goyal <vgoyal@redhat.com>
1 parent 0b39920 commit 4311401

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

‎block/cfq-iosched.c‎

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,32 @@ static void cfq_pd_offline(struct blkcg_gq *blkg)
15281528
cfqg_stats_xfer_dead(blkg_to_cfqg(blkg));
15291529
}
15301530

1531+
/* offset delta from cfqg->stats to cfqg->dead_stats */
1532+
static const int dead_stats_off_delta = offsetof(struct cfq_group, dead_stats) -
1533+
offsetof(struct cfq_group, stats);
1534+
1535+
/* to be used by recursive prfill, sums live and dead stats recursively */
1536+
static u64 cfqg_stat_pd_recursive_sum(struct blkg_policy_data *pd, int off)
1537+
{
1538+
u64 sum = 0;
1539+
1540+
sum += blkg_stat_recursive_sum(pd, off);
1541+
sum += blkg_stat_recursive_sum(pd, off + dead_stats_off_delta);
1542+
return sum;
1543+
}
1544+
1545+
/* to be used by recursive prfill, sums live and dead rwstats recursively */
1546+
static struct blkg_rwstat cfqg_rwstat_pd_recursive_sum(struct blkg_policy_data *pd,
1547+
int off)
1548+
{
1549+
struct blkg_rwstat a, b;
1550+
1551+
a = blkg_rwstat_recursive_sum(pd, off);
1552+
b = blkg_rwstat_recursive_sum(pd, off + dead_stats_off_delta);
1553+
blkg_rwstat_merge(&a, &b);
1554+
return a;
1555+
}
1556+
15311557
static void cfq_pd_reset_stats(struct blkcg_gq *blkg)
15321558
{
15331559
struct cfq_group *cfqg = blkg_to_cfqg(blkg);
@@ -1732,6 +1758,42 @@ static int cfqg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
17321758
return 0;
17331759
}
17341760

1761+
static u64 cfqg_prfill_stat_recursive(struct seq_file *sf,
1762+
struct blkg_policy_data *pd, int off)
1763+
{
1764+
u64 sum = cfqg_stat_pd_recursive_sum(pd, off);
1765+
1766+
return __blkg_prfill_u64(sf, pd, sum);
1767+
}
1768+
1769+
static u64 cfqg_prfill_rwstat_recursive(struct seq_file *sf,
1770+
struct blkg_policy_data *pd, int off)
1771+
{
1772+
struct blkg_rwstat sum = cfqg_rwstat_pd_recursive_sum(pd, off);
1773+
1774+
return __blkg_prfill_rwstat(sf, pd, &sum);
1775+
}
1776+
1777+
static int cfqg_print_stat_recursive(struct cgroup *cgrp, struct cftype *cft,
1778+
struct seq_file *sf)
1779+
{
1780+
struct blkcg *blkcg = cgroup_to_blkcg(cgrp);
1781+
1782+
blkcg_print_blkgs(sf, blkcg, cfqg_prfill_stat_recursive,
1783+
&blkcg_policy_cfq, cft->private, false);
1784+
return 0;
1785+
}
1786+
1787+
static int cfqg_print_rwstat_recursive(struct cgroup *cgrp, struct cftype *cft,
1788+
struct seq_file *sf)
1789+
{
1790+
struct blkcg *blkcg = cgroup_to_blkcg(cgrp);
1791+
1792+
blkcg_print_blkgs(sf, blkcg, cfqg_prfill_rwstat_recursive,
1793+
&blkcg_policy_cfq, cft->private, true);
1794+
return 0;
1795+
}
1796+
17351797
#ifdef CONFIG_DEBUG_BLK_CGROUP
17361798
static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,
17371799
struct blkg_policy_data *pd, int off)
@@ -1803,6 +1865,7 @@ static struct cftype cfq_blkcg_files[] = {
18031865
.write_u64 = cfq_set_leaf_weight,
18041866
},
18051867

1868+
/* statistics, covers only the tasks in the cfqg */
18061869
{
18071870
.name = "time",
18081871
.private = offsetof(struct cfq_group, stats.time),
@@ -1843,6 +1906,48 @@ static struct cftype cfq_blkcg_files[] = {
18431906
.private = offsetof(struct cfq_group, stats.queued),
18441907
.read_seq_string = cfqg_print_rwstat,
18451908
},
1909+
1910+
/* the same statictics which cover the cfqg and its descendants */
1911+
{
1912+
.name = "time_recursive",
1913+
.private = offsetof(struct cfq_group, stats.time),
1914+
.read_seq_string = cfqg_print_stat_recursive,
1915+
},
1916+
{
1917+
.name = "sectors_recursive",
1918+
.private = offsetof(struct cfq_group, stats.sectors),
1919+
.read_seq_string = cfqg_print_stat_recursive,
1920+
},
1921+
{
1922+
.name = "io_service_bytes_recursive",
1923+
.private = offsetof(struct cfq_group, stats.service_bytes),
1924+
.read_seq_string = cfqg_print_rwstat_recursive,
1925+
},
1926+
{
1927+
.name = "io_serviced_recursive",
1928+
.private = offsetof(struct cfq_group, stats.serviced),
1929+
.read_seq_string = cfqg_print_rwstat_recursive,
1930+
},
1931+
{
1932+
.name = "io_service_time_recursive",
1933+
.private = offsetof(struct cfq_group, stats.service_time),
1934+
.read_seq_string = cfqg_print_rwstat_recursive,
1935+
},
1936+
{
1937+
.name = "io_wait_time_recursive",
1938+
.private = offsetof(struct cfq_group, stats.wait_time),
1939+
.read_seq_string = cfqg_print_rwstat_recursive,
1940+
},
1941+
{
1942+
.name = "io_merged_recursive",
1943+
.private = offsetof(struct cfq_group, stats.merged),
1944+
.read_seq_string = cfqg_print_rwstat_recursive,
1945+
},
1946+
{
1947+
.name = "io_queued_recursive",
1948+
.private = offsetof(struct cfq_group, stats.queued),
1949+
.read_seq_string = cfqg_print_rwstat_recursive,
1950+
},
18461951
#ifdef CONFIG_DEBUG_BLK_CGROUP
18471952
{
18481953
.name = "avg_queue_size",

0 commit comments

Comments
 (0)