[CPUFREQ][5/6] cpufreq: Changes to get_cpu_idle_time_us(), used by ondemand governor
authorvenkatesh.pallipadi@intel.com <venkatesh.pallipadi@intel.com>
Mon, 4 Aug 2008 18:59:11 +0000 (11:59 -0700)
committerDave Jones <davej@redhat.com>
Thu, 9 Oct 2008 17:52:44 +0000 (13:52 -0400)
export get_cpu_idle_time_us() for it to be used in ondemand governor.
Last update time can be current time when the CPU is currently non-idle,
accounting for the busy time since last idle.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Dave Jones <davej@redhat.com>
include/linux/tick.h
kernel/time/tick-sched.c

index 8cf8cfe2cc9712a176d7d4904107f4d30e74293f..98921a3e1aa8db33b7e743e6711abb671485ea12 100644 (file)
@@ -126,7 +126,7 @@ static inline ktime_t tick_nohz_get_sleep_length(void)
        return len;
 }
 static inline void tick_nohz_stop_idle(int cpu) { }
-static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return 0; }
+static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }
 # endif /* !NO_HZ */
 
 #endif
index cb02324bdb88b1c477f055af028bd4eace476d4d..a4d2193981675aa7b5e2048bf229d5dbdbeccdcd 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/profile.h>
 #include <linux/sched.h>
 #include <linux/tick.h>
+#include <linux/module.h>
 
 #include <asm/irq_regs.h>
 
@@ -190,9 +191,17 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
 {
        struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
 
-       *last_update_time = ktime_to_us(ts->idle_lastupdate);
+       if (!tick_nohz_enabled)
+               return -1;
+
+       if (ts->idle_active)
+               *last_update_time = ktime_to_us(ts->idle_lastupdate);
+       else
+               *last_update_time = ktime_to_us(ktime_get());
+
        return ktime_to_us(ts->idle_sleeptime);
 }
+EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
 
 /**
  * tick_nohz_stop_sched_tick - stop the idle tick from the idle task