diff options
author | Li Zefan <lizefan@huawei.com> | 2013-03-29 02:36:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-04-10 07:54:16 -0400 |
commit | dbe4b41f9800223949ce72e4289814697e0ea91a (patch) | |
tree | 11f24c688852b29656724f0e7266f5b04d4291c6 /kernel/sched | |
parent | 60fed7891d4115be0ed7ff9ce6851eda80533c64 (diff) |
sched/cpuacct: Add cpuacct_init()
So we don't open-coded initialization of cpuacct in core.c.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/51553687.1060906@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/core.c | 8 | ||||
-rw-r--r-- | kernel/sched/cpuacct.c | 7 | ||||
-rw-r--r-- | kernel/sched/cpuacct.h | 5 |
3 files changed, 14 insertions, 6 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c28222f72c80..92930a89529d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -6936,12 +6936,8 @@ void __init sched_init(void) | |||
6936 | 6936 | ||
6937 | #endif /* CONFIG_CGROUP_SCHED */ | 6937 | #endif /* CONFIG_CGROUP_SCHED */ |
6938 | 6938 | ||
6939 | #ifdef CONFIG_CGROUP_CPUACCT | 6939 | cpuacct_init(); |
6940 | root_cpuacct.cpustat = &kernel_cpustat; | 6940 | |
6941 | root_cpuacct.cpuusage = alloc_percpu(u64); | ||
6942 | /* Too early, not expected to fail */ | ||
6943 | BUG_ON(!root_cpuacct.cpuusage); | ||
6944 | #endif | ||
6945 | for_each_possible_cpu(i) { | 6941 | for_each_possible_cpu(i) { |
6946 | struct rq *rq; | 6942 | struct rq *rq; |
6947 | 6943 | ||
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 50ec24b6193d..48b5e9184dcc 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c | |||
@@ -218,6 +218,13 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime) | |||
218 | rcu_read_unlock(); | 218 | rcu_read_unlock(); |
219 | } | 219 | } |
220 | 220 | ||
221 | void __init cpuacct_init(void) | ||
222 | { | ||
223 | root_cpuacct.cpustat = &kernel_cpustat; | ||
224 | root_cpuacct.cpuusage = alloc_percpu(u64); | ||
225 | BUG_ON(!root_cpuacct.cpuusage); /* Too early, not expected to fail */ | ||
226 | } | ||
227 | |||
221 | struct cgroup_subsys cpuacct_subsys = { | 228 | struct cgroup_subsys cpuacct_subsys = { |
222 | .name = "cpuacct", | 229 | .name = "cpuacct", |
223 | .css_alloc = cpuacct_css_alloc, | 230 | .css_alloc = cpuacct_css_alloc, |
diff --git a/kernel/sched/cpuacct.h b/kernel/sched/cpuacct.h index a7f3d4a8f535..551acd729562 100644 --- a/kernel/sched/cpuacct.h +++ b/kernel/sched/cpuacct.h | |||
@@ -41,10 +41,15 @@ static inline struct cpuacct *parent_ca(struct cpuacct *ca) | |||
41 | return cgroup_ca(ca->css.cgroup->parent); | 41 | return cgroup_ca(ca->css.cgroup->parent); |
42 | } | 42 | } |
43 | 43 | ||
44 | extern void cpuacct_init(void); | ||
44 | extern void cpuacct_charge(struct task_struct *tsk, u64 cputime); | 45 | extern void cpuacct_charge(struct task_struct *tsk, u64 cputime); |
45 | 46 | ||
46 | #else | 47 | #else |
47 | 48 | ||
49 | static inline void cpuacct_init(void) | ||
50 | { | ||
51 | } | ||
52 | |||
48 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) | 53 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) |
49 | { | 54 | { |
50 | } | 55 | } |