[PATCH 6/9] Include idle and iowait fields in cpuacct

From: Glauber Costa
Date: Wed Sep 14 2011 - 16:06:22 EST


These are slightly different from the others though:
(note to reviewers: might be better to put those in a separate
array?)

Since idle/iowait are a property of the system - by definition,
no process from any cgroup is running when the system is idle,
they are system wide. So what these fields really mean, are baselines
for when the cgroup was created. It allows the cgroup to start
counting idle/iowait from 0.

Signed-off-by: Glauber Costa <glommer@xxxxxxxxxxxxx>
---
kernel/sched.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index f0309a0..6c953f5 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1452,6 +1452,8 @@ enum cpuacct_stat_index {
CPUACCT_STAT_SOFTIRQ, /* ... softirq ticks */
CPUACCT_STAT_GUEST, /* ... guest mode */
CPUACCT_STAT_GUEST_NICE, /* ... guest nice */
+ CPUACCT_STAT_IDLE, /* ... idle base ticks when created */
+ CPUACCT_STAT_IOWAIT, /* ... iowait when created */

CPUACCT_STAT_NSTATS,
};
@@ -9151,6 +9153,8 @@ static struct cgroup_subsys_state *cpuacct_create(
struct cgroup_subsys *ss, struct cgroup *cgrp)
{
struct cpuacct *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
+ u64 *acct;
+ int i;

if (!ca)
goto out;
@@ -9163,6 +9167,11 @@ static struct cgroup_subsys_state *cpuacct_create(
if (!ca->cpustat)
goto out_free_usage;

+ for_each_possible_cpu(i) {
+ acct = per_cpu_ptr(ca->cpustat, i);
+ acct[CPUACCT_STAT_IDLE] = kstat_cpu(i).cpustat.idle;
+ acct[CPUACCT_STAT_IOWAIT] = kstat_cpu(i).cpustat.iowait;
+ }
return &ca->css;

out_free_usage:
--
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/