From: Tejun Heo <tj@kernel.org>
To: mingo@redhat.com, peterz@infradead.org
Cc: hannes@cmpxchg.org, lizefan@huawei.com, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-team@fb.com,
Tejun Heo <tj@kernel.org>
Subject: [PATCH 2/3] sched: Misc preps for cgroup unified hierarchy interface
Date: Mon, 3 Aug 2015 18:41:28 -0400 [thread overview]
Message-ID: <1438641689-14655-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1438641689-14655-1-git-send-email-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, remove pointless cpuacct_stat_desc[] array.
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 | 33 +++++++++++++++------------------
2 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 78b4bad10..6137037 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8359,7 +8359,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;
@@ -8399,7 +8399,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",
@@ -8420,7 +8420,7 @@ static struct cftype cpu_files[] = {
},
{
.name = "stat",
- .seq_show = cpu_stats_show,
+ .seq_show = cpu_cfs_stats_show,
},
#endif
#ifdef CONFIG_RT_GROUP_SCHED
@@ -8447,7 +8447,7 @@ struct cgroup_subsys cpu_cgrp_subsys = {
.can_attach = cpu_cgroup_can_attach,
.attach = cpu_cgroup_attach,
.exit = cpu_cgroup_exit,
- .legacy_cftypes = cpu_files,
+ .legacy_cftypes = cpu_legacy_files,
.early_init = 1,
};
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index dd7cbb5..42b2dd5 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -177,36 +177,33 @@ static int cpuacct_percpu_seq_show(struct seq_file *m, void *V)
return 0;
}
-static const char * const cpuacct_stat_desc[] = {
- [CPUACCT_STAT_USER] = "user",
- [CPUACCT_STAT_SYSTEM] = "system",
-};
-
-static int cpuacct_stats_show(struct seq_file *sf, void *v)
+static void cpuacct_stats_read(struct cpuacct *ca, u64 *userp, u64 *sysp)
{
- struct cpuacct *ca = css_ca(seq_css(sf));
int cpu;
- s64 val = 0;
+ *userp = 0;
for_each_online_cpu(cpu) {
struct kernel_cpustat *kcpustat = per_cpu_ptr(ca->cpustat, cpu);
- val += kcpustat->cpustat[CPUTIME_USER];
- val += kcpustat->cpustat[CPUTIME_NICE];
+ *userp += kcpustat->cpustat[CPUTIME_USER];
+ *userp += kcpustat->cpustat[CPUTIME_NICE];
}
- val = cputime64_to_clock_t(val);
- seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_USER], val);
- val = 0;
+ *sysp = 0;
for_each_online_cpu(cpu) {
struct kernel_cpustat *kcpustat = per_cpu_ptr(ca->cpustat, cpu);
- val += kcpustat->cpustat[CPUTIME_SYSTEM];
- val += kcpustat->cpustat[CPUTIME_IRQ];
- val += kcpustat->cpustat[CPUTIME_SOFTIRQ];
+ *sysp += kcpustat->cpustat[CPUTIME_SYSTEM];
+ *sysp += kcpustat->cpustat[CPUTIME_IRQ];
+ *sysp += kcpustat->cpustat[CPUTIME_SOFTIRQ];
}
+}
- val = cputime64_to_clock_t(val);
- seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_SYSTEM], val);
+static int cpuacct_stats_show(struct seq_file *sf, void *v)
+{
+ cputime64_t user, sys;
+ cpuacct_stats_read(css_ca(seq_css(sf)), &user, &sys);
+ seq_printf(sf, "user %lld\n", cputime64_to_clock_t(user));
+ seq_printf(sf, "system %lld\n", cputime64_to_clock_t(sys));
return 0;
}
--
2.4.3
next prev parent reply other threads:[~2015-08-03 22:41 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 22:41 [PATCHSET sched,cgroup] sched: Implement interface for cgroup unified hierarchy Tejun Heo
2015-08-03 22:41 ` [PATCH 1/3] cgroup: define controller file conventions Tejun Heo
2015-08-04 8:42 ` Peter Zijlstra
2015-08-04 14:51 ` Tejun Heo
2015-08-04 8:48 ` Peter Zijlstra
2015-08-04 14:53 ` Tejun Heo
2015-08-04 19:31 ` [PATCH v2 " Tejun Heo
2015-08-05 0:39 ` Kamezawa Hiroyuki
2015-08-05 7:47 ` Michal Hocko
2015-08-06 2:30 ` Kamezawa Hiroyuki
2015-08-07 18:17 ` Michal Hocko
2015-08-17 22:04 ` Johannes Weiner
2015-08-17 21:34 ` Johannes Weiner
2015-08-03 22:41 ` Tejun Heo [this message]
2015-08-03 22:41 ` [PATCH 3/3] sched: Implement interface for cgroup unified hierarchy Tejun Heo
2015-08-04 9:07 ` Peter Zijlstra
2015-08-04 15:10 ` Tejun Heo
2015-08-05 9:10 ` Peter Zijlstra
2015-08-05 14:31 ` Tejun Heo
2015-08-17 20:35 ` Tejun Heo
[not found] ` <CAPM31RJTf0v=2v90kN6-HM9xUGab_k++upO0Ym=irmfO9+BbFw@mail.gmail.com>
2015-08-18 4:03 ` Paul Turner
2015-08-18 20:31 ` Tejun Heo
2015-08-18 23:39 ` Kamezawa Hiroyuki
2015-08-19 16:23 ` Tejun Heo
2015-08-19 3:23 ` Mike Galbraith
2015-08-19 16:41 ` Tejun Heo
2015-08-20 4:00 ` Mike Galbraith
2015-08-20 7:52 ` Tejun Heo
2015-08-20 8:47 ` Mike Galbraith
2015-08-21 19:26 ` Paul Turner
2015-08-22 18:29 ` Tejun Heo
2015-08-24 15:47 ` Austin S Hemmelgarn
2015-08-24 17:04 ` Tejun Heo
2015-08-24 19:18 ` Mike Galbraith
2015-08-24 20:00 ` Austin S Hemmelgarn
2015-08-24 20:25 ` Tejun Heo
2015-08-24 21:00 ` Paul Turner
2015-08-24 21:12 ` Tejun Heo
2015-08-24 21:15 ` Paul Turner
2015-08-24 20:54 ` Paul Turner
2015-08-24 21:02 ` Tejun Heo
2015-08-24 21:10 ` Paul Turner
2015-08-24 21:17 ` Tejun Heo
2015-08-24 21:19 ` Paul Turner
2015-08-24 21:40 ` Tejun Heo
2015-08-24 22:03 ` Paul Turner
2015-08-24 22:49 ` Tejun Heo
2015-08-24 23:15 ` Paul Turner
2015-08-25 2:36 ` Kamezawa Hiroyuki
2015-08-25 21:13 ` Tejun Heo
2015-08-25 9:24 ` Ingo Molnar
2015-08-25 10:00 ` Peter Zijlstra
2015-08-25 19:18 ` Tejun Heo
2015-08-24 20:52 ` Paul Turner
2015-08-24 21:36 ` Tejun Heo
2015-08-24 21:58 ` Paul Turner
2015-08-24 22:19 ` Tejun Heo
2015-08-24 23:06 ` Paul Turner
2015-08-25 21:02 ` Tejun Heo
2015-09-02 17:03 ` Tejun Heo
2015-09-09 12:49 ` Paul Turner
2015-09-12 14:40 ` Tejun Heo
2015-09-17 14:35 ` Peter Zijlstra
2015-09-17 14:53 ` Tejun Heo
2015-09-17 15:42 ` Peter Zijlstra
2015-09-17 15:10 ` Peter Zijlstra
2015-09-17 15:52 ` Tejun Heo
2015-09-17 15:53 ` Peter Zijlstra
2015-09-17 23:29 ` Tejun Heo
2015-09-18 11:27 ` Paul Turner
2015-10-01 18:46 ` Tejun Heo
2015-10-15 11:42 ` Paul Turner
2015-10-23 22:21 ` Tejun Heo
2015-10-24 4:36 ` Mike Galbraith
2015-10-25 2:18 ` Tejun Heo
2015-10-25 3:43 ` Mike Galbraith
2015-10-27 3:16 ` Tejun Heo
2015-10-27 5:42 ` Mike Galbraith
2015-10-27 5:46 ` Tejun Heo
2015-10-27 5:56 ` Mike Galbraith
2015-10-27 6:00 ` Tejun Heo
2015-10-27 6:08 ` Mike Galbraith
2015-10-25 3:54 ` Linus Torvalds
2015-10-25 9:33 ` Ingo Molnar
2015-10-25 10:41 ` Theodore Ts'o
2015-10-25 10:47 ` Florian Weimer
2015-10-25 11:58 ` Theodore Ts'o
2015-10-25 13:17 ` Florian Weimer
2015-10-25 13:40 ` Getrandom wrapper Theodore Ts'o
2015-10-26 13:32 ` Florian Weimer
2015-10-26 14:10 ` [PATCH 3/3] sched: Implement interface for cgroup unified hierarchy Peter Zijlstra
2015-08-04 19:32 ` [PATCH v2 " Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438641689-14655-3-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).