From: "Paul E. McKenney" This patch adds the rcu_assign_pointer() API that helps reduce the need for explicit memory barriers in code that uses RCU. This API buries the required memory barriers in a macro that also does the assignment. This has been tested successfully on i386 and ppc64. Signed-off-by: Signed-off-by: Andrew Morton --- 25-akpm/include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+) diff -puN include/linux/rcupdate.h~rcu-rcu_assign_pointer-removal-of-memory-barriers include/linux/rcupdate.h --- 25/include/linux/rcupdate.h~rcu-rcu_assign_pointer-removal-of-memory-barriers 2004-10-24 03:23:17.357773280 -0700 +++ 25-akpm/include/linux/rcupdate.h 2004-10-24 03:23:17.361772672 -0700 @@ -239,6 +239,24 @@ static inline int rcu_pending(int cpu) (_________p1); \ }) +/** + * rcu_assign_pointer - assign (publicize) a pointer to a newly + * initialized structure that will be dereferenced by RCU read-side + * critical sections. Returns the value assigned. + * + * Inserts memory barriers on architectures that require them + * (pretty much all of them other than x86), and also prevents + * the compiler from reordering the code that initializes the + * structure after the pointer assignment. More importantly, this + * call documents which pointers will be dereferenced by RCU read-side + * code. + */ + +#define rcu_assign_pointer(p, v) ({ \ + smp_wmb(); \ + (p) = (v); \ + }) + extern void rcu_init(void); extern void rcu_check_callbacks(int cpu, int user); extern void rcu_restart_cpu(int cpu); _