]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
update_ts_time_stat currently updates idle time even if we are in iowait
authorMichal Hocko <mhocko@suse.cz>
Wed, 24 Aug 2011 23:46:23 +0000 (09:46 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 1 Sep 2011 03:28:40 +0000 (13:28 +1000)
loop at the moment.  The only real users of the idle counter (via
get_cpu_idle_time_us) are CPU governors and they expect to get cumulative
time for both idle and iowait times.  The value (idle_sleeptime) is also
printed to userspace by print_cpu but it prints both idle and iowait times
so the idle part is misleading.

Let's clean this up and fix update_ts_time_stat to account both counters
properly and update consumers of idle to consider iowait time as well.  If
we do this we might use get_cpu_{idle,iowait}_time_us from other contexts
as well and we will get expected values.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Dave Jones <davej@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/cpufreq/cpufreq_conservative.c
drivers/cpufreq/cpufreq_ondemand.c
kernel/time/tick-sched.c

index 33b56e5c5c14a36fbfc99dd700a8b98164aca707..c97b468ee9f7020ef3bd2e3e976f8b0036662450 100644 (file)
@@ -120,10 +120,12 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
 
 static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
 {
-       u64 idle_time = get_cpu_idle_time_us(cpu, wall);
+       u64 idle_time = get_cpu_idle_time_us(cpu, NULL);
 
        if (idle_time == -1ULL)
                return get_cpu_idle_time_jiffy(cpu, wall);
+       else
+               idle_time += get_cpu_iowait_time_us(cpu, wall);
 
        return idle_time;
 }
index 629b3ec698e2d4ac0f88f88e26f9e95e91e96150..fa8af4ebb1d6b74d1ff73f64e665e22c87b839ee 100644 (file)
@@ -144,10 +144,12 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
 
 static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
 {
-       u64 idle_time = get_cpu_idle_time_us(cpu, wall);
+       u64 idle_time = get_cpu_idle_time_us(cpu, NULL);
 
        if (idle_time == -1ULL)
                return get_cpu_idle_time_jiffy(cpu, wall);
+       else
+               idle_time += get_cpu_iowait_time_us(cpu, wall);
 
        return idle_time;
 }
index eb98e55196b96275f6ee73af0b5d6e351d9162dc..f3409be12bed9622a4c26b52d67fe2851f7eb40b 100644 (file)
@@ -158,9 +158,10 @@ update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_upda
 
        if (ts->idle_active) {
                delta = ktime_sub(now, ts->idle_entrytime);
-               ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
                if (nr_iowait_cpu(cpu) > 0)
                        ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta);
+               else
+                       ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
                ts->idle_entrytime = now;
        }
 
@@ -199,8 +200,7 @@ static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts)
  * @last_update_time: variable to store update time in
  *
  * Return the cummulative idle time (since boot) for a given
- * CPU, in microseconds. The idle time returned includes
- * the iowait time (unlike what "top" and co report).
+ * CPU, in microseconds.
  *
  * This time is measured via accounting rather than sampling,
  * and is as accurate as ktime_get() is.
@@ -220,7 +220,7 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
 }
 EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
 
-/*
+/**
  * get_cpu_iowait_time_us - get the total iowait time of a cpu
  * @cpu: CPU number to query
  * @last_update_time: variable to store update time in