Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1628300
| From | Waiman Long <longman@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH 11/14] sched: Misc preps for cgroup unified hierarchy interface |
| Date | 2017-04-21 16:10 +0200 |
| Message-ID | <tyHq3-6LU-39@gated-at.bofh.it> (permalink) |
| References | <tyHq1-6LU-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Tejun Heo <tj@kernel.org>
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@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
---
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH 00/14] cgroup: Implement cgroup v2 thread mode & CPU controller Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 08/14] cgroup: Keep accurate count of tasks in each css_set Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 12/14] sched: Implement interface for cgroup unified hierarchy Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 13/14] sched: Make cpu/cpuacct threaded controllers Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 03/14] cgroup: introduce cgroup->proc_cgrp and threaded css_set handling Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 09/14] cgroup: Make debug cgroup support v2 and thread mode Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 06/14] cgroup: Fix reference counting bug in cgroup_procs_write() Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 07/14] cgroup: Move debug cgroup to its own file Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 05/14] cgroup: implement cgroup v2 thread support Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 10/14] cgroup: Implement new thread mode semantics Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 04/14] cgroup: implement CSS_TASK_ITER_THREADED Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 14/14] cgroup: Enable separate control knobs for thread root internal processes Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 02/14] cgroup: add @flags to css_task_iter_start() and implement CSS_TASK_ITER_PROCS Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 11/14] sched: Misc preps for cgroup unified hierarchy interface Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200 [RFC PATCH 01/14] cgroup: reorganize cgroup.procs / task write path Waiman Long <longman@redhat.com> - 2017-04-21 16:10 +0200
csiph-web