aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/cpuacct.c
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2013-03-29 02:37:06 -0400
committerIngo Molnar <mingo@kernel.org>2013-04-10 07:54:17 -0400
commit1966aaf7d54608e8ddb7ac454b461840e763409a (patch)
tree01010d8ff23842f4200e69d2955fd805f50d6e28 /kernel/sched/cpuacct.c
parentdbe4b41f9800223949ce72e4289814697e0ea91a (diff)
sched/cpuacct: Add cpuacct_acount_field()
So we can remove open-coded cpuacct code in cputime.c. Signed-off-by: Li Zefan <lizefan@huawei.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/51553692.9060008@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/cpuacct.c')
-rw-r--r--kernel/sched/cpuacct.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 48b5e9184dcc..72bd971ea377 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -218,6 +218,29 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
218 rcu_read_unlock(); 218 rcu_read_unlock();
219} 219}
220 220
221/*
222 * Add user/system time to cpuacct.
223 *
224 * Note: it's the caller that updates the account of the root cgroup.
225 */
226void cpuacct_account_field(struct task_struct *p, int index, u64 val)
227{
228 struct kernel_cpustat *kcpustat;
229 struct cpuacct *ca;
230
231 if (unlikely(!cpuacct_subsys.active))
232 return;
233
234 rcu_read_lock();
235 ca = task_ca(p);
236 while (ca && (ca != &root_cpuacct)) {
237 kcpustat = this_cpu_ptr(ca->cpustat);
238 kcpustat->cpustat[index] += val;
239 ca = parent_ca(ca);
240 }
241 rcu_read_unlock();
242}
243
221void __init cpuacct_init(void) 244void __init cpuacct_init(void)
222{ 245{
223 root_cpuacct.cpustat = &kernel_cpustat; 246 root_cpuacct.cpustat = &kernel_cpustat;