diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:06 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:06 -0500 |
commit | 5ee613b6751cd91db4b6bd7c1dc9d2f9cf65cde2 (patch) | |
tree | 2fa68d5c3d0e18723bed666fe087b4bbc3ed78ba | |
parent | 53d517cdbaac704352b3d0c10fecb99e0b54572e (diff) |
x86: idle wakeup event in the HLT loop
do a proper idle-wakeup event on HLT as well - some CPUs stop the TSC
in HLT too, not just when going through the ACPI methods.
(the ACPI idle code already does this.)
[ update the 64-bit side too, as noticed by Jiri Slaby. ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/process_32.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 13 |
2 files changed, 22 insertions, 6 deletions
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 46d391d49de8..a63d2d2556ee 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
@@ -113,10 +113,19 @@ void default_idle(void) | |||
113 | smp_mb(); | 113 | smp_mb(); |
114 | 114 | ||
115 | local_irq_disable(); | 115 | local_irq_disable(); |
116 | if (!need_resched()) | 116 | if (!need_resched()) { |
117 | ktime_t t0, t1; | ||
118 | u64 t0n, t1n; | ||
119 | |||
120 | t0 = ktime_get(); | ||
121 | t0n = ktime_to_ns(t0); | ||
117 | safe_halt(); /* enables interrupts racelessly */ | 122 | safe_halt(); /* enables interrupts racelessly */ |
118 | else | 123 | local_irq_disable(); |
119 | local_irq_enable(); | 124 | t1 = ktime_get(); |
125 | t1n = ktime_to_ns(t1); | ||
126 | sched_clock_idle_wakeup_event(t1n - t0n); | ||
127 | } | ||
128 | local_irq_enable(); | ||
120 | current_thread_info()->status |= TS_POLLING; | 129 | current_thread_info()->status |= TS_POLLING; |
121 | } else { | 130 | } else { |
122 | /* loop is done by the caller */ | 131 | /* loop is done by the caller */ |
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index c2db7ef93565..40fed477f3e5 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
@@ -116,9 +116,16 @@ static void default_idle(void) | |||
116 | smp_mb(); | 116 | smp_mb(); |
117 | local_irq_disable(); | 117 | local_irq_disable(); |
118 | if (!need_resched()) { | 118 | if (!need_resched()) { |
119 | /* Enables interrupts one instruction before HLT. | 119 | ktime_t t0, t1; |
120 | x86 special cases this so there is no race. */ | 120 | u64 t0n, t1n; |
121 | safe_halt(); | 121 | |
122 | t0 = ktime_get(); | ||
123 | t0n = ktime_to_ns(t0); | ||
124 | safe_halt(); /* enables interrupts racelessly */ | ||
125 | local_irq_disable(); | ||
126 | t1 = ktime_get(); | ||
127 | t1n = ktime_to_ns(t1); | ||
128 | sched_clock_idle_wakeup_event(t1n - t0n); | ||
122 | } else | 129 | } else |
123 | local_irq_enable(); | 130 | local_irq_enable(); |
124 | current_thread_info()->status |= TS_POLLING; | 131 | current_thread_info()->status |= TS_POLLING; |