lkml.org 
[lkml]   [2011]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/9] Include idle and iowait fields in cpuacct
Date
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@parallels.com>
---
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


\
 
 \ /
  Last update: 2011-09-14 22:09    [W:0.154 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site