]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> |
2 | Subject: export get_cpu_idle_time_us() | |
3 | ||
4 | export get_cpu_idle_time_us() for it to be used in ondemand governor. | |
5 | Last update time can be current time when the CPU is currently non-idle, | |
6 | accounting for the busy time since last idle. | |
7 | ||
8 | Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | |
9 | Signed-off-by: Thomas Renninger <trenn@suse.de> | |
10 | ||
11 | --- | |
12 | include/linux/tick.h | 2 +- | |
13 | kernel/time/tick-sched.c | 11 ++++++++++- | |
14 | 2 files changed, 11 insertions(+), 2 deletions(-) | |
15 | ||
16 | Index: cpufreq.git/kernel/time/tick-sched.c | |
17 | =================================================================== | |
18 | --- cpufreq.git.orig/kernel/time/tick-sched.c 2008-07-31 10:04:55.000000000 -0700 | |
19 | +++ cpufreq.git/kernel/time/tick-sched.c 2008-07-31 14:52:18.000000000 -0700 | |
20 | @@ -20,6 +20,7 @@ | |
21 | #include <linux/profile.h> | |
22 | #include <linux/sched.h> | |
23 | #include <linux/tick.h> | |
24 | +#include <linux/module.h> | |
25 | ||
26 | #include <asm/irq_regs.h> | |
27 | ||
28 | @@ -184,9 +185,17 @@ u64 get_cpu_idle_time_us(int cpu, u64 *l | |
29 | { | |
30 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); | |
31 | ||
32 | - *last_update_time = ktime_to_us(ts->idle_lastupdate); | |
33 | + if (!tick_nohz_enabled) | |
34 | + return -1; | |
35 | + | |
36 | + if (ts->idle_active) | |
37 | + *last_update_time = ktime_to_us(ts->idle_lastupdate); | |
38 | + else | |
39 | + *last_update_time = ktime_to_us(ktime_get()); | |
40 | + | |
41 | return ktime_to_us(ts->idle_sleeptime); | |
42 | } | |
43 | +EXPORT_SYMBOL_GPL(get_cpu_idle_time_us); | |
44 | ||
45 | /** | |
46 | * tick_nohz_stop_sched_tick - stop the idle tick from the idle task | |
47 | Index: cpufreq.git/include/linux/tick.h | |
48 | =================================================================== | |
49 | --- cpufreq.git.orig/include/linux/tick.h 2008-07-31 10:04:54.000000000 -0700 | |
50 | +++ cpufreq.git/include/linux/tick.h 2008-07-31 14:52:18.000000000 -0700 | |
51 | @@ -123,7 +123,7 @@ static inline ktime_t tick_nohz_get_slee | |
52 | return len; | |
53 | } | |
54 | static inline void tick_nohz_stop_idle(int cpu) { } | |
55 | -static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return 0; } | |
56 | +static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } | |
57 | # endif /* !NO_HZ */ | |
58 | ||
59 | #endif | |
60 | ||
61 | -- |