sched/cpuacct: Allocate per_cpu cpuusage for root cpuacct statically
authorLi Zefan <lizefan@huawei.com>
Fri, 29 Mar 2013 06:43:46 +0000 (14:43 +0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 10 Apr 2013 11:54:20 +0000 (13:54 +0200)
This is a preparation, so later we can initialize cpuacct
earlier.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Cc: Tejun Heo <tj@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/51553822.5000403@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/cpuacct.c

index 9305fd2f8cf97a473c040a7fcb917ffd29b4af18..a691c4dd65bef8ae9e247486326878eb276487f7 100644 (file)
@@ -58,6 +58,7 @@ static inline struct cpuacct *parent_ca(struct cpuacct *ca)
        return cgroup_ca(ca->css.cgroup->parent);
 }
 
+static DEFINE_PER_CPU(u64, root_cpuacct_cpuusage);
 static struct cpuacct root_cpuacct;
 
 /* create a new cpu accounting group */
@@ -290,8 +291,7 @@ void cpuacct_account_field(struct task_struct *p, int index, u64 val)
 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 */
+       root_cpuacct.cpuusage = &root_cpuacct_cpuusage;
 }
 
 struct cgroup_subsys cpuacct_subsys = {