Commit 8083e4ad970e4eb567e31037060cdd4ba346f0c0
Committed by
Dave Jones
1 parent
e9d95bf7eb
[CPUFREQ][5/6] cpufreq: Changes to get_cpu_idle_time_us(), used by ondemand governor
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>
Showing 2 changed files with 11 additions and 2 deletions Side-by-side Diff
include/linux/tick.h
... | ... | @@ -126,7 +126,7 @@ |
126 | 126 | return len; |
127 | 127 | } |
128 | 128 | static inline void tick_nohz_stop_idle(int cpu) { } |
129 | -static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return 0; } | |
129 | +static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } | |
130 | 130 | # endif /* !NO_HZ */ |
131 | 131 | |
132 | 132 | #endif |
kernel/time/tick-sched.c
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | #include <linux/profile.h> |
21 | 21 | #include <linux/sched.h> |
22 | 22 | #include <linux/tick.h> |
23 | +#include <linux/module.h> | |
23 | 24 | |
24 | 25 | #include <asm/irq_regs.h> |
25 | 26 | |
26 | 27 | |
... | ... | @@ -190,9 +191,17 @@ |
190 | 191 | { |
191 | 192 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); |
192 | 193 | |
193 | - *last_update_time = ktime_to_us(ts->idle_lastupdate); | |
194 | + if (!tick_nohz_enabled) | |
195 | + return -1; | |
196 | + | |
197 | + if (ts->idle_active) | |
198 | + *last_update_time = ktime_to_us(ts->idle_lastupdate); | |
199 | + else | |
200 | + *last_update_time = ktime_to_us(ktime_get()); | |
201 | + | |
194 | 202 | return ktime_to_us(ts->idle_sleeptime); |
195 | 203 | } |
204 | +EXPORT_SYMBOL_GPL(get_cpu_idle_time_us); | |
196 | 205 | |
197 | 206 | /** |
198 | 207 | * tick_nohz_stop_sched_tick - stop the idle tick from the idle task |