From: Glauber Costa <glommer@parallels.com>
To: linux-kernel@vger.kernel.org
Cc: paul@paulmenage.org, lizf@cn.fujitsu.com, daniel.lezcano@free.fr,
a.p.zijlstra@chello.nl, jbottomley@parallels.com, pjt@google.com,
fweisbec@gmail.com, Glauber Costa <glommer@parallels.com>
Subject: [PATCH v2 08/14] Report steal time for cgroup
Date: Tue, 1 Nov 2011 19:19:14 -0200 [thread overview]
Message-ID: <1320182360-20043-9-git-send-email-glommer@parallels.com> (raw)
In-Reply-To: <1320182360-20043-1-git-send-email-glommer@parallels.com>
This patch introduces a functionality commonly found in
hypervisors: steal time.
For those not particularly familiar with it, steal time
is defined as any time in which a virtual machine (or container)
wanted to perform cpu work, but could not due to another
VM/container being scheduled in its place. Note that idle
time is never defined as steal time.
Assuming each container will live in its cgroup, we can
very easily and nicely calculate steal time as all user/system
time recorded in our sibling cgroups.
Signed-off-by: Glauber Costa <glommer@parallels.com>
---
kernel/sched.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 7dd4dea..c7ac150 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9662,6 +9662,7 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
struct timespec boottime;
#ifdef CONFIG_CGROUP_SCHED
struct task_group *tg;
+ struct task_group *sib;
if (cgrp)
tg = cgroup_tg(cgrp);
@@ -9700,6 +9701,21 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
guest += kcpustat->cpustat[GUEST];
guest_nice += kcpustat->cpustat[GUEST_NICE];
total_forks += kcpustat->cpustat[TOTAL_FORKS];
+#ifdef CONFIG_CGROUP_SCHED
+ if (static_branch(&sched_cgroup_enabled)) {
+ list_for_each_entry(sib, &tg->siblings, siblings) {
+ struct kernel_cpustat *ksib;
+ if (!sib)
+ continue;
+
+ ksib = per_cpu_ptr(sib->cpustat, i);
+ steal += ksib->cpustat[USER] +
+ ksib->cpustat[SYSTEM] +
+ ksib->cpustat[IRQ] +
+ ksib->cpustat[SOFTIRQ];
+ }
+ }
+#endif
kstat_unlock();
for (j = 0; j < NR_SOFTIRQS; j++) {
@@ -9744,6 +9760,21 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
steal -= kcpustat->cpustat[STEAL_BASE];
guest = kcpustat->cpustat[GUEST];
guest_nice = kcpustat->cpustat[GUEST_NICE];
+#ifdef CONFIG_CGROUP_SCHED
+ if (static_branch(&sched_cgroup_enabled)) {
+ list_for_each_entry(sib, &tg->siblings, siblings) {
+ struct kernel_cpustat *ksib;
+ if (!sib)
+ continue;
+
+ ksib = per_cpu_ptr(sib->cpustat, i);
+ steal += ksib->cpustat[USER] +
+ ksib->cpustat[SYSTEM] +
+ ksib->cpustat[IRQ] +
+ ksib->cpustat[SOFTIRQ];
+ }
+ }
+#endif
kstat_unlock();
seq_printf(p,
"cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu "
--
1.7.6.4
next prev parent reply other threads:[~2011-11-01 21:20 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-01 21:19 [PATCH v2 00/14] per-cgroup /proc/stat Glauber Costa
2011-11-01 21:19 ` [PATCH v2 01/14] trivial: initialize root cgroup's sibling list Glauber Costa
2011-11-11 21:34 ` Paul Turner
2011-11-14 19:44 ` Glauber Costa
2011-11-14 21:44 ` Peter Zijlstra
2011-11-18 23:42 ` [tip:sched/core] sched, trivial: Initialize " tip-bot for Glauber Costa
2011-11-01 21:19 ` [PATCH v2 02/14] Change cpustat fields to an array Glauber Costa
2011-11-01 21:19 ` [PATCH v2 03/14] Move /proc/stat logic inside sched.c Glauber Costa
2011-11-12 1:35 ` Paul Turner
2011-11-12 10:27 ` Glauber Costa
2011-11-01 21:19 ` [PATCH v2 04/14] split kernel stat in two Glauber Costa
2011-11-01 21:19 ` [PATCH v2 05/14] Display /proc/stat information per cgroup Glauber Costa
2011-11-01 21:19 ` [PATCH v2 06/14] Make total_forks per-cgroup Glauber Costa
2011-11-01 21:19 ` [PATCH v2 07/14] per-cgroup boot time Glauber Costa
2011-11-01 21:19 ` Glauber Costa [this message]
2011-11-01 21:19 ` [PATCH v2 09/14] Keep nr_iowait per cgroup Glauber Costa
2011-11-10 10:27 ` Andrew Wagin
2011-11-01 21:19 ` [PATCH v2 10/14] Keep number of context switches per-cgroup Glauber Costa
2011-11-01 21:19 ` [PATCH v2 11/14] provide a version of cpuacct statistics inside cpu cgroup Glauber Costa
2011-11-01 21:19 ` [PATCH v2 12/14] Keep number of running processes per-cgroup Glauber Costa
2011-11-14 14:42 ` Andrew Wagin
2011-11-01 21:19 ` [PATCH v2 13/14] provide a version of cpuusage statistics inside cpu cgroup Glauber Costa
2011-11-09 11:51 ` Andrew Wagin
2011-11-09 11:58 ` Glauber Costa
2011-11-09 14:18 ` Andrew Wagin
2011-11-09 15:30 ` Peter Zijlstra
2011-11-09 16:51 ` Glauber Costa
2011-11-10 8:59 ` Andrew Wagin
2011-11-01 21:19 ` [PATCH v2 14/14] Change CPUACCT to default n Glauber Costa
2011-11-11 21:33 ` Paul Turner
2011-11-12 10:29 ` Glauber Costa
2011-11-15 11:02 ` Paul Turner
2011-11-16 10:21 ` Balbir Singh
2011-11-16 23:52 ` KAMEZAWA Hiroyuki
2011-11-17 2:49 ` Glauber Costa
2011-11-17 2:58 ` Balbir Singh
2011-11-17 15:58 ` Glauber Costa
2011-11-21 1:59 ` KAMEZAWA Hiroyuki
2011-11-24 13:24 ` Peter Zijlstra
2011-11-24 16:07 ` Glauber Costa
2011-11-24 16:29 ` Peter Zijlstra
2011-11-24 16:38 ` Glauber Costa
2011-11-24 16:58 ` Peter Zijlstra
2011-11-25 5:38 ` Balbir Singh
2011-11-25 10:19 ` Peter Zijlstra
2011-11-26 13:18 ` Paul Turner
2011-11-28 8:29 ` Balbir Singh
2011-11-25 2:05 ` Li Zefan
2011-11-25 10:09 ` Peter Zijlstra
2011-11-26 13:07 ` Paul Turner
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=1320182360-20043-9-git-send-email-glommer@parallels.com \
--to=glommer@parallels.com \
--cc=a.p.zijlstra@chello.nl \
--cc=daniel.lezcano@free.fr \
--cc=fweisbec@gmail.com \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=paul@paulmenage.org \
--cc=pjt@google.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®