From: Tejun Heo <tj@xxxxxxxxxx> Make the following changes in preparation for the cpu controller interface implementation for the unified hierarchy. This patch doesn't cause any functional differences. * s/cpu_stats_show()/cpu_cfs_stats_show()/ * s/cpu_files/cpu_legacy_files/ * Separate out cpuacct_stats_read() from cpuacct_stats_show(). While at it, make the @val array u64 for consistency. Signed-off-by: Tejun Heo <tj@xxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Li Zefan <lizefan@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> --- kernel/sched/core.c | 8 ++++---- kernel/sched/cpuacct.c | 29 ++++++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 27b4dd5..5e3a217 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7209,7 +7209,7 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota) return ret; } -static int cpu_stats_show(struct seq_file *sf, void *v) +static int cpu_cfs_stats_show(struct seq_file *sf, void *v) { struct task_group *tg = css_tg(seq_css(sf)); struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; @@ -7249,7 +7249,7 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css, } #endif /* CONFIG_RT_GROUP_SCHED */ -static struct cftype cpu_files[] = { +static struct cftype cpu_legacy_files[] = { #ifdef CONFIG_FAIR_GROUP_SCHED { .name = "shares", @@ -7270,7 +7270,7 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css, }, { .name = "stat", - .seq_show = cpu_stats_show, + .seq_show = cpu_cfs_stats_show, }, #endif #ifdef CONFIG_RT_GROUP_SCHED @@ -7296,7 +7296,7 @@ struct cgroup_subsys cpu_cgrp_subsys = { .fork = cpu_cgroup_fork, .can_attach = cpu_cgroup_can_attach, .attach = cpu_cgroup_attach, - .legacy_cftypes = cpu_files, + .legacy_cftypes = cpu_legacy_files, .early_init = true, }; diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index f95ab29..6151c23 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -276,26 +276,33 @@ static int cpuacct_all_seq_show(struct seq_file *m, void *V) return 0; } -static int cpuacct_stats_show(struct seq_file *sf, void *v) +static void cpuacct_stats_read(struct cpuacct *ca, + u64 (*val)[CPUACCT_STAT_NSTATS]) { - struct cpuacct *ca = css_ca(seq_css(sf)); - s64 val[CPUACCT_STAT_NSTATS]; int cpu; - int stat; - memset(val, 0, sizeof(val)); + memset(val, 0, sizeof(*val)); + for_each_possible_cpu(cpu) { u64 *cpustat = per_cpu_ptr(ca->cpustat, cpu)->cpustat; - val[CPUACCT_STAT_USER] += cpustat[CPUTIME_USER]; - val[CPUACCT_STAT_USER] += cpustat[CPUTIME_NICE]; - val[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_SYSTEM]; - val[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_IRQ]; - val[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_SOFTIRQ]; + (*val)[CPUACCT_STAT_USER] += cpustat[CPUTIME_USER]; + (*val)[CPUACCT_STAT_USER] += cpustat[CPUTIME_NICE]; + (*val)[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_SYSTEM]; + (*val)[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_IRQ]; + (*val)[CPUACCT_STAT_SYSTEM] += cpustat[CPUTIME_SOFTIRQ]; } +} + +static int cpuacct_stats_show(struct seq_file *sf, void *v) +{ + u64 val[CPUACCT_STAT_NSTATS]; + int stat; + + cpuacct_stats_read(css_ca(seq_css(sf)), &val); for (stat = 0; stat < CPUACCT_STAT_NSTATS; stat++) { - seq_printf(sf, "%s %lld\n", + seq_printf(sf, "%s %llu\n", cpuacct_stat_desc[stat], (long long)nsec_to_clock_t(val[stat])); } -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html