[IA64] Simplify cpu_idle_wait

This is just Venki's patch[*] for x86 ported to ia64.

* http://marc.info/?l=linux-kernel&m=120249201318159&w=2

Acked-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

Tony Luck 42763935 aa91a2e9

+15 -29
+15 -29
arch/ia64/kernel/process.c
··· 52 #include "sigframe.h" 53 54 void (*ia64_mark_idle)(int); 55 - static DEFINE_PER_CPU(unsigned int, cpu_idle_state); 56 57 unsigned long boot_option_idle_override = 0; 58 EXPORT_SYMBOL(boot_option_idle_override); ··· 253 } 254 #endif /* CONFIG_HOTPLUG_CPU */ 255 256 void cpu_idle_wait(void) 257 { 258 - unsigned int cpu, this_cpu = get_cpu(); 259 - cpumask_t map; 260 - cpumask_t tmp = current->cpus_allowed; 261 - 262 - set_cpus_allowed(current, cpumask_of_cpu(this_cpu)); 263 - put_cpu(); 264 - 265 - cpus_clear(map); 266 - for_each_online_cpu(cpu) { 267 - per_cpu(cpu_idle_state, cpu) = 1; 268 - cpu_set(cpu, map); 269 - } 270 - 271 - __get_cpu_var(cpu_idle_state) = 0; 272 - 273 - wmb(); 274 - do { 275 - ssleep(1); 276 - for_each_online_cpu(cpu) { 277 - if (cpu_isset(cpu, map) && !per_cpu(cpu_idle_state, cpu)) 278 - cpu_clear(cpu, map); 279 - } 280 - cpus_and(map, map, cpu_online_map); 281 - } while (!cpus_empty(map)); 282 - set_cpus_allowed(current, tmp); 283 } 284 EXPORT_SYMBOL_GPL(cpu_idle_wait); 285 ··· 297 #ifdef CONFIG_SMP 298 min_xtp(); 299 #endif 300 - if (__get_cpu_var(cpu_idle_state)) 301 - __get_cpu_var(cpu_idle_state) = 0; 302 - 303 rmb(); 304 if (mark_idle) 305 (*mark_idle)(1);
··· 52 #include "sigframe.h" 53 54 void (*ia64_mark_idle)(int); 55 56 unsigned long boot_option_idle_override = 0; 57 EXPORT_SYMBOL(boot_option_idle_override); ··· 254 } 255 #endif /* CONFIG_HOTPLUG_CPU */ 256 257 + static void do_nothing(void *unused) 258 + { 259 + } 260 + 261 + /* 262 + * cpu_idle_wait - Used to ensure that all the CPUs discard old value of 263 + * pm_idle and update to new pm_idle value. Required while changing pm_idle 264 + * handler on SMP systems. 265 + * 266 + * Caller must have changed pm_idle to the new value before the call. Old 267 + * pm_idle value will not be used by any CPU after the return of this function. 268 + */ 269 void cpu_idle_wait(void) 270 { 271 + smp_mb(); 272 + /* kick all the CPUs so that they exit out of pm_idle */ 273 + smp_call_function(do_nothing, NULL, 0, 1); 274 } 275 EXPORT_SYMBOL_GPL(cpu_idle_wait); 276 ··· 308 #ifdef CONFIG_SMP 309 min_xtp(); 310 #endif 311 rmb(); 312 if (mark_idle) 313 (*mark_idle)(1);