Skip to content

Commit 14c6d3c

Browse files
lizf-osingomolnar
authored andcommitted
sched/cpuacct: Initialize root cpuacct earlier
Now we don't need cpuacct_init(), and instead we just initialize root_cpuacct when it's defined. 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/51553834.9090701@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 7943e15 commit 14c6d3c

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

‎kernel/sched/core.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6936,8 +6936,6 @@ void __init sched_init(void)
69366936

69376937
#endif /* CONFIG_CGROUP_SCHED */
69386938

6939-
cpuacct_init();
6940-
69416939
for_each_possible_cpu(i) {
69426940
struct rq *rq;
69436941

‎kernel/sched/cpuacct.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ static inline struct cpuacct *parent_ca(struct cpuacct *ca)
5959
}
6060

6161
static DEFINE_PER_CPU(u64, root_cpuacct_cpuusage);
62-
static struct cpuacct root_cpuacct;
62+
static struct cpuacct root_cpuacct = {
63+
.cpustat = &kernel_cpustat,
64+
.cpuusage = &root_cpuacct_cpuusage,
65+
};
6366

6467
/* create a new cpu accounting group */
6568
static struct cgroup_subsys_state *cpuacct_css_alloc(struct cgroup *cgrp)
@@ -288,12 +291,6 @@ void cpuacct_account_field(struct task_struct *p, int index, u64 val)
288291
rcu_read_unlock();
289292
}
290293

291-
void __init cpuacct_init(void)
292-
{
293-
root_cpuacct.cpustat = &kernel_cpustat;
294-
root_cpuacct.cpuusage = &root_cpuacct_cpuusage;
295-
}
296-
297294
struct cgroup_subsys cpuacct_subsys = {
298295
.name = "cpuacct",
299296
.css_alloc = cpuacct_css_alloc,

‎kernel/sched/cpuacct.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#ifdef CONFIG_CGROUP_CPUACCT
22

3-
extern void cpuacct_init(void);
43
extern void cpuacct_charge(struct task_struct *tsk, u64 cputime);
54
extern void cpuacct_account_field(struct task_struct *p, int index, u64 val);
65

76
#else
87

9-
static inline void cpuacct_init(void)
10-
{
11-
}
12-
138
static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime)
149
{
1510
}

0 commit comments

Comments
 (0)