blob: b83151d7388cdd52813590b03d99961a24442159 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
Thomas Gleixnerae9d9832008-01-30 13:30:36 +01004#include <linux/cpumask.h>
5#include <linux/init.h>
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/*
8 * We need the APIC definitions automatically as part of 'smp.h'
9 */
Glauber Costac1fa6c92008-03-27 14:05:59 -030010#ifdef CONFIG_X86_LOCAL_APIC
11# include <asm/mpspec.h>
12# include <asm/apic.h>
13# ifdef CONFIG_X86_IO_APIC
14# include <asm/io_apic.h>
15# endif
16#endif
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010017#include <asm/pda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Andi Kleen3c021752006-01-11 22:45:12 +010020extern cpumask_t cpu_initialized;
Glauber Costaa3553522008-03-03 14:12:58 -030021extern cpumask_t cpu_callin_map;
Andi Kleena8ab26f2005-04-16 15:25:19 -070022
Laurent Vivier66d16ed2007-10-19 20:35:03 +020023extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
24 void *info, int wait);
Eric W. Biederman3d483f42005-07-29 14:03:29 -070025
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010026#ifdef CONFIG_SMP
27
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010028#define raw_smp_processor_id() read_pda(cpunumber)
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010029
30#define stack_smp_processor_id() \
Joe Perchesceb7ce12008-03-23 01:03:30 -070031({ \
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010032 struct thread_info *ti; \
Joe Perchesceb7ce12008-03-23 01:03:30 -070033 asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010034 ti->cpu; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070035})
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010036
37/*
38 * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
39 * scheduling and IPI sending and compresses data structures.
40 */
41static inline int num_booting_cpus(void)
42{
43 return cpus_weight(cpu_callout_map);
44}
45
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010046#else /* CONFIG_SMP */
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010047#define stack_smp_processor_id() 0
48
49#endif /* !CONFIG_SMP */
50
51#define safe_smp_processor_id() smp_processor_id()
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#endif
54