blob: eead92e30b2938ddc09d9aa134b4fb34a3260aaf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
Andi Kleen3c021752006-01-11 22:45:12 +01004extern cpumask_t cpu_initialized;
Glauber Costaa3553522008-03-03 14:12:58 -03005extern cpumask_t cpu_callin_map;
Andi Kleena8ab26f2005-04-16 15:25:19 -07006
Laurent Vivier66d16ed2007-10-19 20:35:03 +02007extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
8 void *info, int wait);
Eric W. Biederman3d483f42005-07-29 14:03:29 -07009
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010010#ifdef CONFIG_SMP
11
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010012#define raw_smp_processor_id() read_pda(cpunumber)
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010013
14#define stack_smp_processor_id() \
Joe Perchesceb7ce12008-03-23 01:03:30 -070015({ \
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010016 struct thread_info *ti; \
Joe Perchesceb7ce12008-03-23 01:03:30 -070017 asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010018 ti->cpu; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070019})
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010020
21/*
22 * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
23 * scheduling and IPI sending and compresses data structures.
24 */
25static inline int num_booting_cpus(void)
26{
27 return cpus_weight(cpu_callout_map);
28}
29
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010030#else /* CONFIG_SMP */
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010031#define stack_smp_processor_id() 0
32
33#endif /* !CONFIG_SMP */
34
35#define safe_smp_processor_id() smp_processor_id()
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#endif
38