From: "Paul Menage" <menage@google.com>
To: "Dhaval Giani" <dhaval@linux.vnet.ibm.com>
Cc: vatsa@linux.vnet.ibm.com, balbir@linux.vnet.ibm.com,
mingo@elte.hu, linux-kernel@vger.kernel.org,
a.p.zijlstra@chello.nl, akpm@linux-foundation.org,
skumar@linux.vnet.ibm.com
Subject: Re: [patch 2/2] sched: allow cpuacct stats to be reset
Date: Thu, 28 Feb 2008 21:48:51 -0800 [thread overview]
Message-ID: <6599ad830802282148g7f309995l450fc15074234cd7@mail.gmail.com> (raw)
In-Reply-To: <20080229043751.555866685@linux.vnet.ibm.com>
On Thu, Feb 28, 2008 at 8:32 PM, Dhaval Giani <dhaval@linux.vnet.ibm.com> wrote:
> 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>
>
> ---
> kernel/sched.c | 24 ++++++++++++++++++++++++
> 1 files changed, 24 insertions(+)
>
> Index: linux-2.6/kernel/sched.c
> ===================================================================
> --- linux-2.6.orig/kernel/sched.c 2008-02-28 20:05:27.000000000 +0530
> +++ linux-2.6/kernel/sched.c 2008-02-28 20:05:30.000000000 +0530
> @@ -8243,10 +8243,34 @@ static u64 cpuusage_read(struct cgroup *
> return totalcpuusage;
> }
>
> +static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype,
> + u64 reset)
> +{
> + struct cpuacct *ca = cgroup_ca(cgrp);
> + int err = 0;
> + int i;
> +
> + if (reset) {
> + err = -EINVAL;
> + goto out;
> + }
> +
> + for_each_possible_cpu(i) {
> + u64 *cpuusage = percpu_ptr(ca->cpuusage, i);
> +
> + spin_lock_irq(&cpu_rq(i)->lock);
> + *cpuusage = 0;
> + spin_unlock_irq(&cpu_rq(i)->lock);
> + }
> +out:
> + return err;
> +}
> +
> static struct cftype files[] = {
> {
> .name = "usage",
> .read_uint = cpuusage_read,
> + .write_uint = cpuusage_write,
> },
> };
>
Can I suggest, in order to be more generic, that this patch instead
set each CPU's counter to the written value divided by the number of
CPUs? (Either forgetting the remainder, or spreading it among the
first few CPUs).
Paul
next prev parent reply other threads:[~2008-02-29 5:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-29 4:32 [patch 0/2] sched: cpuacct: minor cleanups and reset for cpuusage Dhaval Giani
2008-02-29 4:32 ` [patch 1/2] sched: cleanup cpuacct variable names Dhaval Giani
2008-03-07 4:58 ` Balbir Singh
2008-03-07 8:58 ` Ingo Molnar
2008-02-29 4:32 ` [patch 2/2] sched: allow cpuacct stats to be reset Dhaval Giani
2008-02-29 5:48 ` Paul Menage [this message]
2008-02-29 6:02 ` Srivatsa Vaddagiri
2008-02-29 6:04 ` Dhaval Giani
2008-02-29 10:08 ` Paul Menage
2008-02-29 10:38 ` Peter Zijlstra
2008-03-07 5:00 ` Balbir Singh
2008-03-07 8:59 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6599ad830802282148g7f309995l450fc15074234cd7@mail.gmail.com \
--to=menage@google.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=skumar@linux.vnet.ibm.com \
--cc=vatsa@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®