Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277391
b: refs/heads/master
c: 44252e4
h: refs/heads/master
i:
  277389: ed5ee9f
  277387: d8c3892
  277383: 8b680d3
  277375: b37a1d9
v: v3
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Dec 6, 2011
1 parent 6f28c23 commit f0cd61c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3292beb340c76884427faa1f5d6085719477d889
refs/heads/master: 44252e421ad81e711c5a9db158fad7f433f70665
15 changes: 9 additions & 6 deletions trunk/kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7849,7 +7849,6 @@ struct cpuacct {
/* cpuusage holds pointer to a u64-type object on every cpu */
u64 __percpu *cpuusage;
struct percpu_counter cpustat[CPUACCT_STAT_NSTATS];
struct cpuacct *parent;
};

struct cgroup_subsys cpuacct_subsys;
Expand All @@ -7868,6 +7867,13 @@ static inline struct cpuacct *task_ca(struct task_struct *tsk)
struct cpuacct, css);
}

static inline struct cpuacct *parent_ca(struct cpuacct *ca)
{
if (!ca || !ca->css.cgroup->parent)
return NULL;
return cgroup_ca(ca->css.cgroup->parent);
}

/* create a new cpu accounting group */
static struct cgroup_subsys_state *cpuacct_create(
struct cgroup_subsys *ss, struct cgroup *cgrp)
Expand All @@ -7886,9 +7892,6 @@ static struct cgroup_subsys_state *cpuacct_create(
if (percpu_counter_init(&ca->cpustat[i], 0))
goto out_free_counters;

if (cgrp->parent)
ca->parent = cgroup_ca(cgrp->parent);

return &ca->css;

out_free_counters:
Expand Down Expand Up @@ -8055,7 +8058,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)

ca = task_ca(tsk);

for (; ca; ca = ca->parent) {
for (; ca; ca = parent_ca(ca)) {
u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
*cpuusage += cputime;
}
Expand Down Expand Up @@ -8097,7 +8100,7 @@ void cpuacct_update_stats(struct task_struct *tsk,

do {
__percpu_counter_add(&ca->cpustat[idx], val, batch);
ca = ca->parent;
ca = parent_ca(ca);
} while (ca);
rcu_read_unlock();
}
Expand Down

0 comments on commit f0cd61c

Please sign in to comment.