aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorBharata B Rao <bharata@linux.vnet.ibm.com>2008-11-10 10:11:13 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-11 06:13:28 -0500
commit934352f214b3251eb0793c1209d346595a661d80 (patch)
tree375ac56485c20f7b7cf783c3ca2980a76dc94fce /kernel/sched.c
parentff9b48c3598732926fa09afd7f526981c32a48cc (diff)
sched: add hierarchical accounting to cpu accounting controller
Impact: improve CPU time accounting of tasks under the cpu accounting controller Add hierarchical accounting to cpu accounting controller and include cpuacct documentation. Currently, while charging the task's cputime to its accounting group, the accounting group hierarchy isn't updated. This patch charges the cputime of a task to its accounting group and all its parent accounting groups. Reported-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Reviewed-by: Paul Menage <menage@google.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 59db86c915f9..ebaf432365f6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9196,11 +9196,12 @@ struct cgroup_subsys cpu_cgroup_subsys = {
9196 * (balbir@in.ibm.com). 9196 * (balbir@in.ibm.com).
9197 */ 9197 */
9198 9198
9199/* track cpu usage of a group of tasks */ 9199/* track cpu usage of a group of tasks and its child groups */
9200struct cpuacct { 9200struct cpuacct {
9201 struct cgroup_subsys_state css; 9201 struct cgroup_subsys_state css;
9202 /* cpuusage holds pointer to a u64-type object on every cpu */ 9202 /* cpuusage holds pointer to a u64-type object on every cpu */
9203 u64 *cpuusage; 9203 u64 *cpuusage;
9204 struct cpuacct *parent;
9204}; 9205};
9205 9206
9206struct cgroup_subsys cpuacct_subsys; 9207struct cgroup_subsys cpuacct_subsys;
@@ -9234,6 +9235,9 @@ static struct cgroup_subsys_state *cpuacct_create(
9234 return ERR_PTR(-ENOMEM); 9235 return ERR_PTR(-ENOMEM);
9235 } 9236 }
9236 9237
9238 if (cgrp->parent)
9239 ca->parent = cgroup_ca(cgrp->parent);
9240
9237 return &ca->css; 9241 return &ca->css;
9238} 9242}
9239 9243
@@ -9313,14 +9317,16 @@ static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
9313static void cpuacct_charge(struct task_struct *tsk, u64 cputime) 9317static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
9314{ 9318{
9315 struct cpuacct *ca; 9319 struct cpuacct *ca;
9320 int cpu;
9316 9321
9317 if (!cpuacct_subsys.active) 9322 if (!cpuacct_subsys.active)
9318 return; 9323 return;
9319 9324
9325 cpu = task_cpu(tsk);
9320 ca = task_ca(tsk); 9326 ca = task_ca(tsk);
9321 if (ca) {
9322 u64 *cpuusage = percpu_ptr(ca->cpuusage, task_cpu(tsk));
9323 9327
9328 for (; ca; ca = ca->parent) {
9329 u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
9324 *cpuusage += cputime; 9330 *cpuusage += cputime;
9325 } 9331 }
9326} 9332}