From 79eb6a126211dc1cbb20f16f67bad69afa2f9703 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 21 May 2002 03:21:43 -0700 Subject: [PATCH] get/put_cpu methods This implements a get_cpu() and matching put_cpu() to safely hand out the current CPU to avoid preempt races. Andrew and I have been bitching about the need for such a method. I also went ahead and replaced an example of current explicit preempt-off with the new methods, as a case in point. --- include/linux/smp.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/smp.h b/include/linux/smp.h index 85c6273694c9..b61435d369c8 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -96,5 +96,9 @@ static inline void smp_send_reschedule_all(void) { } #define per_cpu(var, cpu) var #define this_cpu(var) var -#endif -#endif +#endif /* !SMP */ + +#define get_cpu() ({ preempt_disable(); smp_processor_id(); }) +#define put_cpu() preempt_enable() + +#endif /* __LINUX_SMP_H */ -- cgit v1.2.3