Skip to content

Commit

Permalink
sched/cpuacct: Add cpuacct_init()
Browse files Browse the repository at this point in the history
So we don't open-coded initialization of cpuacct in core.c.

Signed-off-by: Li Zefan <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
lizf-os authored and Ingo Molnar committed Apr 10, 2013
1 parent 60fed78 commit dbe4b41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 2 additions & 6 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions kernel/sched/cpuacct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions kernel/sched/cpuacct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down

0 comments on commit dbe4b41

Please sign in to comment.