From: Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
Paul Turner <pjt-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Peter Zijlstra
<a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org>,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
handai.szj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
Andrew.Phillips-xheW4WVAX9Y@public.gmane.org,
Serge Hallyn
<serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Subject: [PATCH v3 3/6] expose fine-grained per-cpu data for cpuacct stats
Date: Wed, 30 May 2012 13:48:34 +0400 [thread overview]
Message-ID: <1338371317-5980-4-git-send-email-glommer@parallels.com> (raw)
In-Reply-To: <1338371317-5980-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
The cpuacct cgroup already exposes user and system numbers in a per-cgroup
fashion. But they are a summation along the whole group, not a per-cpu figure.
Also, they are coarse-grained version of the stats usually shown at places
like /proc/stat.
I want to have enough cgroup data to emulate the /proc/stat interface. To
achieve that, I am creating a new file "stat_percpu" that displays the
fine-grained per-cpu data. The original data is left alone.
The format of this file resembles the one found in the usual cgroup's stat
files. But of course, the fields will be repeated, one per cpu, and prefixed
with the cpu number.
Therefore, we'll have something like:
cpu0.user X
cpu0.system Y
...
cpu1.user X1
cpu1.system Y1
...
Signed-off-by: Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
CC: Peter Zijlstra <a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org>
CC: Paul Turner <pjt-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
kernel/sched/core.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 220d416..4c1d7e9 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8178,6 +8178,35 @@ static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft,
return 0;
}
+static inline void do_fill_cb(struct cgroup_map_cb *cb, struct cpuacct *ca,
+ char *str, int cpu, int index)
+{
+ char name[24];
+ struct kernel_cpustat *kcpustat = per_cpu_ptr(ca->cpustat, cpu);
+
+ snprintf(name, sizeof(name), "cpu%d.%s", cpu, str);
+ cb->fill(cb, name, cputime64_to_clock_t(kcpustat->cpustat[index]));
+}
+
+static int cpuacct_stats_percpu_show(struct cgroup *cgrp, struct cftype *cft,
+ struct cgroup_map_cb *cb)
+{
+ struct cpuacct *ca = cgroup_ca(cgrp);
+ int cpu;
+
+ for_each_online_cpu(cpu) {
+ do_fill_cb(cb, ca, "user", cpu, CPUTIME_USER);
+ do_fill_cb(cb, ca, "nice", cpu, CPUTIME_NICE);
+ do_fill_cb(cb, ca, "system", cpu, CPUTIME_SYSTEM);
+ do_fill_cb(cb, ca, "irq", cpu, CPUTIME_IRQ);
+ do_fill_cb(cb, ca, "softirq", cpu, CPUTIME_SOFTIRQ);
+ do_fill_cb(cb, ca, "guest", cpu, CPUTIME_GUEST);
+ do_fill_cb(cb, ca, "guest_nice", cpu, CPUTIME_GUEST_NICE);
+ }
+
+ return 0;
+}
+
static struct cftype files[] = {
{
.name = "usage",
@@ -8192,6 +8221,10 @@ static struct cftype files[] = {
.name = "stat",
.read_map = cpuacct_stats_show,
},
+ {
+ .name = "stat_percpu",
+ .read_map = cpuacct_stats_percpu_show,
+ },
{ } /* terminate */
};
--
1.7.10.2
next prev parent reply other threads:[~2012-05-30 9:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-30 9:48 [PATCH v3 0/6] per cgroup /proc/stat statistics Glauber Costa
2012-05-30 9:48 ` [PATCH v3 2/6] account guest time per-cgroup as well Glauber Costa
[not found] ` <1338371317-5980-3-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 10:32 ` Peter Zijlstra
2012-05-30 10:36 ` Glauber Costa
2012-05-30 10:46 ` Paul Turner
2012-05-30 9:48 ` [PATCH v3 4/6] add a new scheduler hook for context switch Glauber Costa
[not found] ` <1338371317-5980-5-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 11:20 ` Peter Zijlstra
2012-05-30 11:40 ` Peter Zijlstra
2012-05-30 12:08 ` Glauber Costa
2012-05-30 12:07 ` Glauber Costa
2012-05-30 9:48 ` [PATCH v3 5/6] Also record sleep start for a task group Glauber Costa
[not found] ` <1338371317-5980-6-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 11:35 ` Paul Turner
[not found] ` <CAPM31R+VXsffUOSOtMPG=g+G9OdzWMKQvx9usTFa3KBbrqPe6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-30 12:24 ` Glauber Costa
[not found] ` <4FC61188.8000908-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 12:44 ` Peter Zijlstra
2012-05-30 12:44 ` Glauber Costa
[not found] ` <1338371317-5980-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 9:48 ` [PATCH v3 1/6] measure exec_clock for rt sched entities Glauber Costa
[not found] ` <1338371317-5980-2-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 10:29 ` Peter Zijlstra
2012-05-30 10:32 ` Glauber Costa
[not found] ` <4FC5F727.2040804-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 10:42 ` Peter Zijlstra
2012-05-30 10:42 ` Glauber Costa
[not found] ` <4FC5F99B.2060109-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 11:00 ` Paul Turner
[not found] ` <CAPM31RL-X2GYju-opjUumPq_cfGiRzGowXEOx9Tq4kVEG-z3SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-30 12:09 ` Glauber Costa
2012-05-30 9:48 ` Glauber Costa [this message]
[not found] ` <1338371317-5980-4-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 10:34 ` [PATCH v3 3/6] expose fine-grained per-cpu data for cpuacct stats Peter Zijlstra
2012-05-30 10:34 ` Glauber Costa
[not found] ` <4FC5F7A0.2000201-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 10:43 ` Peter Zijlstra
2012-05-30 10:44 ` Glauber Costa
[not found] ` <4FC5FA20.50301-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 11:24 ` Peter Zijlstra
2012-05-30 11:24 ` Paul Turner
[not found] ` <CAPM31RJanAvDB+pZ+h5J3W6KXvAwPgbbeXgw6C_56tx_Mc+cgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-30 12:20 ` Glauber Costa
[not found] ` <4FC6107F.9020802-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 12:48 ` Paul Turner
2012-05-30 12:52 ` Glauber Costa
[not found] ` <CAPM31RJ7s+pNciOEnsfXRU9xCwnUano1k8CTEUuCjsSN5n0-1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-30 13:26 ` Glauber Costa
2012-05-30 13:26 ` Glauber Costa
2012-05-30 9:48 ` [PATCH v3 6/6] expose per-taskgroup schedstats in cgroup Glauber Costa
[not found] ` <1338371317-5980-7-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-30 11:22 ` Peter Zijlstra
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=1338371317-5980-4-git-send-email-glommer@parallels.com \
--to=glommer-bzqdu9zft3wakbo8gow8eq@public.gmane.org \
--cc=Andrew.Phillips-xheW4WVAX9Y@public.gmane.org \
--cc=a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=handai.szj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pjt-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).