public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan@huawei.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 3/7] cpuacct: Add cpuacct_init()
Date: Fri, 29 Mar 2013 14:36:55 +0800	[thread overview]
Message-ID: <51553687.1060906@huawei.com> (raw)
In-Reply-To: <5155365F.1010203@huawei.com>

So we don't open-coded initialization of cpuacct in core.c.

Signed-off-by: Li Zefan <lizefan@huawei.com>
---
 kernel/sched/core.c    | 8 ++------
 kernel/sched/cpuacct.c | 7 +++++++
 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 c4e2b81..c7016c1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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;
 
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 50ec24b..48b5e91 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -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,
diff --git a/kernel/sched/cpuacct.h b/kernel/sched/cpuacct.h
index a7f3d4a..551acd7 100644
--- a/kernel/sched/cpuacct.h
+++ b/kernel/sched/cpuacct.h
@@ -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)
 {
 }
-- 
1.8.0.2

  parent reply	other threads:[~2013-03-29  6:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29  6:36 [PATCH v2 0/7] sched: Split cpuacct Li Zefan
2013-03-29  6:36 ` [PATCH v2 1/7] sched: Split cpuacct code out of core.c Li Zefan
2013-04-10 13:36   ` [tip:sched/core] " tip-bot for Li Zefan
2013-03-29  6:36 ` [PATCH v2 2/7] sched: Split cpuacct code out of sched.h Li Zefan
2013-04-10 13:37   ` [tip:sched/core] " tip-bot for Li Zefan
2013-03-29  6:36 ` Li Zefan [this message]
2013-04-10 13:38   ` [tip:sched/core] sched/cpuacct: Add cpuacct_init() tip-bot for Li Zefan
2013-03-29  6:37 ` [PATCH v2 4/7] cpuacct: Add cpuacct_acount_field() Li Zefan
2013-04-10 13:40   ` [tip:sched/core] sched/cpuacct: " tip-bot for Li Zefan
2013-03-29  6:37 ` [PATCH v2 5/7] cpuacct: Remove redundant NULL checks in cpuacct_charge() Li Zefan
2013-04-10 13:41   ` [tip:sched/core] sched/cpuacct: " tip-bot for Li Zefan
2013-03-29  6:37 ` [PATCH v2 6/7] cpuacct: Remove redundant NULL checks in cpuacct_acount_field() Li Zefan
2013-04-10 13:42   ` [tip:sched/core] sched/cpuacct: " tip-bot for Li Zefan
2013-03-29  6:38 ` [PATCH v2 7/7] cpuacct: Clean up cpuacct.h Li Zefan
2013-04-10 13:43   ` [tip:sched/core] sched/cpuacct: " tip-bot for Li Zefan
2013-03-29 10:34 ` [PATCH v2 0/7] sched: Split cpuacct Peter Zijlstra
2013-04-10 13:10   ` Ingo Molnar
2013-04-10 13:10     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51553687.1060906@huawei.com \
    --to=lizefan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox