sched/cpuacct: Add cpuacct_init()
authorLi Zefan <lizefan@huawei.com>
Fri, 29 Mar 2013 06:36:55 +0000 (14:36 +0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 10 Apr 2013 11:54:16 +0000 (13:54 +0200)
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>
kernel/sched/core.c
kernel/sched/cpuacct.c
kernel/sched/cpuacct.h

index c28222f72c80d16ddc57d1783ccc257d64890e83..92930a89529d9d81b21439edb79962f83af68c19 100644 (file)
@@ -6936,12 +6936,8 @@ void __init sched_init(void)
 
 #endif /* CONFIG_CGROUP_SCHED */
 
-#ifdef CONFIG_CGROUP_CPUACCT
-       root_cpuacct.cpustat = &kernel_cpustat;
-       root_cpuacct.cpuusage = alloc_percpu(u64);
-       /* Too early, not expected to fail */
-       BUG_ON(!root_cpuacct.cpuusage);
-#endif
+       cpuacct_init();
+
        for_each_possible_cpu(i) {
                struct rq *rq;
 
index 50ec24b6193d4a9f4d7c44edae937237ab5d7474..48b5e9184dcc279312ce4f7dd1bc90997e2976d0 100644 (file)
@@ -218,6 +218,13 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
        rcu_read_unlock();
 }
 
+void __init cpuacct_init(void)
+{
+       root_cpuacct.cpustat = &kernel_cpustat;
+       root_cpuacct.cpuusage = alloc_percpu(u64);
+       BUG_ON(!root_cpuacct.cpuusage); /* Too early, not expected to fail */
+}
+
 struct cgroup_subsys cpuacct_subsys = {
        .name = "cpuacct",
        .css_alloc = cpuacct_css_alloc,
index a7f3d4a8f535d5995e7c07fca474ebf6ec8d3509..551acd729562ee1c88836fae3b744f85377c7d57 100644 (file)
@@ -41,10 +41,15 @@ static inline struct cpuacct *parent_ca(struct cpuacct *ca)
        return cgroup_ca(ca->css.cgroup->parent);
 }
 
+extern void cpuacct_init(void);
 extern void cpuacct_charge(struct task_struct *tsk, u64 cputime);
 
 #else
 
+static inline void cpuacct_init(void)
+{
+}
+
 static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime)
 {
 }