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,
cgroups@vger.kernel.org, Glauber Costa <glommer@parallels.com>,
Balbir Singh <bsingharora@gmail.com>
Subject: [PATCH 4/4] provide a version of cpuacct statistics inside cpu cgroup
Date: Tue, 15 Nov 2011 13:59:17 -0200 [thread overview]
Message-ID: <1321372757-1581-5-git-send-email-glommer@parallels.com> (raw)
In-Reply-To: <1321372757-1581-1-git-send-email-glommer@parallels.com>
For users interested in using the information currently displayed
at cpuacct.stat, we provide it inside the cpu cgroup.
This have the advantage of accounting this information only once,
instead of twice, when there is no need to have an independent group
of tasks for controlling and accounting, leading to a lot less overhead.
Signed-off-by: Glauber Costa <glommer@parallels.com>
CC: Balbir Singh <bsingharora@gmail.com>
---
kernel/sched.c | 43 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 934f631..99e806b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9151,6 +9151,11 @@ int sched_rt_handler(struct ctl_table *table, int write,
return ret;
}
+static const char *cpuacct_stat_desc[] = {
+ [CPUACCT_STAT_USER] = "user",
+ [CPUACCT_STAT_SYSTEM] = "system",
+};
+
#ifdef CONFIG_CGROUP_SCHED
/* return corresponding task_group object of a cgroup */
@@ -9509,6 +9514,35 @@ static int cpu_set_sched_stats(struct cgroup *cgrp, struct cftype *cft, u64 val)
return 0;
}
+static int cpu_cgroup_stats_show(struct cgroup *cgrp, struct cftype *cft,
+ struct cgroup_map_cb *cb)
+{
+ struct task_group *tg = cgroup_tg(cgrp);
+ int cpu;
+ s64 val = 0;
+
+ for_each_present_cpu(cpu) {
+ struct kernel_cpustat *kcpustat = per_cpu_ptr(tg->cpustat, cpu);
+ val += kcpustat->cpustat[USER];
+ val += kcpustat->cpustat[NICE];
+ }
+ val = cputime64_to_clock_t(val);
+ cb->fill(cb, cpuacct_stat_desc[CPUACCT_STAT_USER], val);
+
+ val = 0;
+ for_each_online_cpu(cpu) {
+ struct kernel_cpustat *kcpustat = per_cpu_ptr(tg->cpustat, cpu);
+ val += kcpustat->cpustat[SYSTEM];
+ val += kcpustat->cpustat[IRQ];
+ val += kcpustat->cpustat[SOFTIRQ];
+ }
+
+ val = cputime64_to_clock_t(val);
+ cb->fill(cb, cpuacct_stat_desc[CPUACCT_STAT_SYSTEM], val);
+
+ return 0;
+}
+
static struct cftype cpu_files[] = {
#ifdef CONFIG_FAIR_GROUP_SCHED
{
@@ -9545,6 +9579,10 @@ static struct cftype cpu_files[] = {
.write_u64 = cpu_rt_period_write_uint,
},
#endif
+ {
+ .name = "acct_stat",
+ .read_map = cpu_cgroup_stats_show,
+ },
};
/*
@@ -9746,11 +9784,6 @@ static int cpuacct_percpu_seq_read(struct cgroup *cgroup, struct cftype *cft,
return 0;
}
-static const char *cpuacct_stat_desc[] = {
- [CPUACCT_STAT_USER] = "user",
- [CPUACCT_STAT_SYSTEM] = "system",
-};
-
static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft,
struct cgroup_map_cb *cb)
{
--
1.7.6.4
next prev parent reply other threads:[~2011-11-15 16:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 15:59 [PATCH 0/4] Provide cpuacct functionality in " Glauber Costa
2011-11-15 15:59 ` [PATCH 1/4] Change cpustat fields to an array Glauber Costa
2011-11-16 5:58 ` Paul Turner
2011-11-16 11:25 ` Glauber Costa
2011-11-16 11:31 ` Glauber Costa
2011-11-15 15:59 ` [PATCH 2/4] split kernel stat in two Glauber Costa
2011-11-16 6:12 ` Paul Turner
2011-11-16 11:34 ` Glauber Costa
2011-11-15 15:59 ` [PATCH 3/4] Keep scheduler statistics per cgroup Glauber Costa
2011-11-16 7:02 ` Paul Turner
2011-11-16 11:56 ` Glauber Costa
2011-11-15 15:59 ` Glauber Costa [this message]
2011-11-17 7:12 ` [PATCH 4/4] provide a version of cpuacct statistics inside cpu cgroup Balbir Singh
2011-11-16 0:57 ` [PATCH 0/4] Provide cpuacct functionality in " KAMEZAWA Hiroyuki
2011-11-23 10:29 ` Glauber Costa
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=1321372757-1581-5-git-send-email-glommer@parallels.com \
--to=glommer@parallels.com \
--cc=a.p.zijlstra@chello.nl \
--cc=bsingharora@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=daniel.lezcano@free.fr \
--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®