X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=include%2Flinux%2Fsmp.h;h=c438ec9880e94c87d504d21bc813c492c1db1c19;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=312ec58a4025afc0f84925c44d5dc57323c282d6;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/include/linux/smp.h b/include/linux/smp.h index 312ec58a4..c438ec988 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -8,6 +8,8 @@ #include +extern void cpu_idle(void); + #ifdef CONFIG_SMP #include @@ -95,8 +97,10 @@ void smp_prepare_boot_cpu(void); /* * These macros fold the SMP functionality into a single CPU system */ - -#define smp_processor_id() 0 + +#if !defined(__smp_processor_id) || !defined(CONFIG_PREEMPT) +# define smp_processor_id() 0 +#endif #define hard_smp_processor_id() 0 #define smp_threads_ready 1 #define smp_call_function(func,info,retry,wait) ({ 0; }) @@ -107,6 +111,33 @@ static inline void smp_send_reschedule(int cpu) { } #endif /* !SMP */ +/* + * DEBUG_PREEMPT support: check whether smp_processor_id() is being + * used in a preemption-safe way. + * + * An architecture has to enable this debugging code explicitly. + * It can do so by renaming the smp_processor_id() macro to + * __smp_processor_id(). This should only be done after some minimal + * testing, because usually there are a number of false positives + * that an architecture will trigger. + * + * To fix a false positive (i.e. smp_processor_id() use that the + * debugging code reports but which use for some reason is legal), + * change the smp_processor_id() reference to _smp_processor_id(), + * which is the nondebug variant. NOTE: don't use this to hack around + * real bugs. + */ +#ifdef __smp_processor_id +# if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT) + extern unsigned int smp_processor_id(void); +# else +# define smp_processor_id() __smp_processor_id() +# endif +# define _smp_processor_id() __smp_processor_id() +#else +# define _smp_processor_id() smp_processor_id() +#endif + #define get_cpu() ({ preempt_disable(); smp_processor_id(); }) #define put_cpu() preempt_enable() #define put_cpu_no_resched() preempt_enable_no_resched()