aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-02-28 23:32:44 -0500
committerIngo Molnar <mingo@elte.hu>2008-04-19 13:44:58 -0400
commit0297b80339d545045490716fa8591b215fdd9458 (patch)
tree3a00c5bd83fc3f0493a2a26b95db0c4a7e4bb691 /kernel
parent32cd756a80aaef657ac09c76e6eff3ba65567790 (diff)
sched: allow cpuacct stats to be reset
Currently the schedstats implementation does not allow the statistics to be reset. This patch aims to allow that. echo 0 > cpuacct.usage resets the usage. Any other value is not allowed and returns -EINVAL. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index e2f85c7a7476..e4bf4477aee5 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8381,10 +8381,34 @@ static u64 cpuusage_read(struct cgroup *cgrp, struct cftype *cft)
8381 return totalcpuusage; 8381 return totalcpuusage;
8382} 8382}
8383 8383
8384static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype,
8385 u64 reset)
8386{
8387 struct cpuacct *ca = cgroup_ca(cgrp);
8388 int err = 0;
8389 int i;
8390
8391 if (reset) {
8392 err = -EINVAL;
8393 goto out;
8394 }
8395
8396 for_each_possible_cpu(i) {
8397 u64 *cpuusage = percpu_ptr(ca->cpuusage, i);
8398
8399 spin_lock_irq(&cpu_rq(i)->lock);
8400 *cpuusage = 0;
8401 spin_unlock_irq(&cpu_rq(i)->lock);
8402 }
8403out:
8404 return err;
8405}
8406
8384static struct cftype files[] = { 8407static struct cftype files[] = {
8385 { 8408 {
8386 .name = "usage", 8409 .name = "usage",
8387 .read_uint = cpuusage_read, 8410 .read_uint = cpuusage_read,
8411 .write_uint = cpuusage_write,
8388 }, 8412 },
8389}; 8413};
8390 8414