diff options
Diffstat (limited to 'arch/x86_64/kernel/process.c')
-rw-r--r-- | arch/x86_64/kernel/process.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c index 7451a4c43c16..a418ee4c8c62 100644 --- a/arch/x86_64/kernel/process.c +++ b/arch/x86_64/kernel/process.c | |||
@@ -108,17 +108,15 @@ void exit_idle(void) | |||
108 | */ | 108 | */ |
109 | static void default_idle(void) | 109 | static void default_idle(void) |
110 | { | 110 | { |
111 | local_irq_enable(); | ||
112 | |||
113 | current_thread_info()->status &= ~TS_POLLING; | 111 | current_thread_info()->status &= ~TS_POLLING; |
114 | smp_mb__after_clear_bit(); | 112 | smp_mb__after_clear_bit(); |
115 | while (!need_resched()) { | 113 | local_irq_disable(); |
116 | local_irq_disable(); | 114 | if (!need_resched()) { |
117 | if (!need_resched()) | 115 | /* Enables interrupts one instruction before HLT. |
118 | safe_halt(); | 116 | x86 special cases this so there is no race. */ |
119 | else | 117 | safe_halt(); |
120 | local_irq_enable(); | 118 | } else |
121 | } | 119 | local_irq_enable(); |
122 | current_thread_info()->status |= TS_POLLING; | 120 | current_thread_info()->status |= TS_POLLING; |
123 | } | 121 | } |
124 | 122 | ||
@@ -130,15 +128,7 @@ static void default_idle(void) | |||
130 | static void poll_idle (void) | 128 | static void poll_idle (void) |
131 | { | 129 | { |
132 | local_irq_enable(); | 130 | local_irq_enable(); |
133 | 131 | cpu_relax(); | |
134 | asm volatile( | ||
135 | "2:" | ||
136 | "testl %0,%1;" | ||
137 | "rep; nop;" | ||
138 | "je 2b;" | ||
139 | : : | ||
140 | "i" (_TIF_NEED_RESCHED), | ||
141 | "m" (current_thread_info()->flags)); | ||
142 | } | 132 | } |
143 | 133 | ||
144 | void cpu_idle_wait(void) | 134 | void cpu_idle_wait(void) |
@@ -219,6 +209,12 @@ void cpu_idle (void) | |||
219 | idle = default_idle; | 209 | idle = default_idle; |
220 | if (cpu_is_offline(smp_processor_id())) | 210 | if (cpu_is_offline(smp_processor_id())) |
221 | play_dead(); | 211 | play_dead(); |
212 | /* | ||
213 | * Idle routines should keep interrupts disabled | ||
214 | * from here on, until they go to idle. | ||
215 | * Otherwise, idle callbacks can misfire. | ||
216 | */ | ||
217 | local_irq_disable(); | ||
222 | enter_idle(); | 218 | enter_idle(); |
223 | idle(); | 219 | idle(); |
224 | /* In many cases the interrupt that ended idle | 220 | /* In many cases the interrupt that ended idle |
@@ -256,9 +252,16 @@ void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) | |||
256 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ | 252 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ |
257 | static void mwait_idle(void) | 253 | static void mwait_idle(void) |
258 | { | 254 | { |
259 | local_irq_enable(); | 255 | if (!need_resched()) { |
260 | while (!need_resched()) | 256 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
261 | mwait_idle_with_hints(0,0); | 257 | smp_mb(); |
258 | if (!need_resched()) | ||
259 | __sti_mwait(0, 0); | ||
260 | else | ||
261 | local_irq_enable(); | ||
262 | } else { | ||
263 | local_irq_enable(); | ||
264 | } | ||
262 | } | 265 | } |
263 | 266 | ||
264 | void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) | 267 | void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) |