Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SMP_H |
| 2 | #define __ASM_SMP_H |
| 3 | |
Andi Kleen | 3c02175 | 2006-01-11 22:45:12 +0100 | [diff] [blame] | 4 | extern cpumask_t cpu_initialized; |
Glauber Costa | a355352 | 2008-03-03 14:12:58 -0300 | [diff] [blame] | 5 | extern cpumask_t cpu_callin_map; |
Andi Kleen | a8ab26f | 2005-04-16 15:25:19 -0700 | [diff] [blame] | 6 | |
Laurent Vivier | 66d16ed | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 7 | extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *), |
| 8 | void *info, int wait); |
Eric W. Biederman | 3d483f4 | 2005-07-29 14:03:29 -0700 | [diff] [blame] | 9 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 10 | #ifdef CONFIG_SMP |
| 11 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 12 | #define raw_smp_processor_id() read_pda(cpunumber) |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 13 | |
| 14 | #define stack_smp_processor_id() \ |
Joe Perches | ceb7ce1 | 2008-03-23 01:03:30 -0700 | [diff] [blame] | 15 | ({ \ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 16 | struct thread_info *ti; \ |
Joe Perches | ceb7ce1 | 2008-03-23 01:03:30 -0700 | [diff] [blame] | 17 | asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 18 | ti->cpu; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | }) |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 20 | |
| 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 | */ |
| 25 | static inline int num_booting_cpus(void) |
| 26 | { |
| 27 | return cpus_weight(cpu_callout_map); |
| 28 | } |
| 29 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 30 | #else /* CONFIG_SMP */ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 31 | #define stack_smp_processor_id() 0 |
| 32 | |
| 33 | #endif /* !CONFIG_SMP */ |
| 34 | |
| 35 | #define safe_smp_processor_id() smp_processor_id() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #endif |
| 38 | |