Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121346
b: refs/heads/master
c: 720f549
h: refs/heads/master
v: v3
  • Loading branch information
Ken Chen authored and Ingo Molnar committed Dec 16, 2008
1 parent 475c3ba commit d1b56f9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 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: 34f28ecd0f4bdc733c681294d02d9fab5880591b
refs/heads/master: 720f54988e17b33f3f477010b3a68ee872d20d5a
56 changes: 39 additions & 17 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -9275,24 +9275,50 @@ cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
kfree(ca);
}

static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu)
{
u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
u64 data;

#ifndef CONFIG_64BIT
/*
* Take rq->lock to make 64-bit read safe on 32-bit platforms.
*/
spin_lock_irq(&cpu_rq(cpu)->lock);
data = *cpuusage;
spin_unlock_irq(&cpu_rq(cpu)->lock);
#else
data = *cpuusage;
#endif

return data;
}

static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
{
u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);

#ifndef CONFIG_64BIT
/*
* Take rq->lock to make 64-bit write safe on 32-bit platforms.
*/
spin_lock_irq(&cpu_rq(cpu)->lock);
*cpuusage = val;
spin_unlock_irq(&cpu_rq(cpu)->lock);
#else
*cpuusage = val;
#endif
}

/* return total cpu usage (in nanoseconds) of a group */
static u64 cpuusage_read(struct cgroup *cgrp, struct cftype *cft)
{
struct cpuacct *ca = cgroup_ca(cgrp);
u64 totalcpuusage = 0;
int i;

for_each_possible_cpu(i) {
u64 *cpuusage = percpu_ptr(ca->cpuusage, i);

/*
* Take rq->lock to make 64-bit addition safe on 32-bit
* platforms.
*/
spin_lock_irq(&cpu_rq(i)->lock);
totalcpuusage += *cpuusage;
spin_unlock_irq(&cpu_rq(i)->lock);
}
for_each_present_cpu(i)
totalcpuusage += cpuacct_cpuusage_read(ca, i);

return totalcpuusage;
}
Expand All @@ -9309,13 +9335,9 @@ static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype,
goto out;
}

for_each_possible_cpu(i) {
u64 *cpuusage = percpu_ptr(ca->cpuusage, i);
for_each_present_cpu(i)
cpuacct_cpuusage_write(ca, i, 0);

spin_lock_irq(&cpu_rq(i)->lock);
*cpuusage = 0;
spin_unlock_irq(&cpu_rq(i)->lock);
}
out:
return err;
}
Expand Down

0 comments on commit d1b56f9

Please sign in to comment.