diff options
| author | Robert Love <rml@tech9.net> | 2002-05-21 03:21:43 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-05-21 03:21:43 -0700 |
| commit | 79eb6a126211dc1cbb20f16f67bad69afa2f9703 (patch) | |
| tree | bd59645d6b1a5e0a069a52f2d12fb77411da27f2 /include/linux | |
| parent | 8e93dcc872459a0601273631848ccc3f319af02f (diff) | |
[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.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/smp.h | 8 |
1 files changed, 6 insertions, 2 deletions
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 */ |
