1
0
Fork 0

rcu: Don't return a value from rcu_assign_pointer()

Quoting Paul [1]:

  "Given that a quick (and perhaps error-prone) search of the uses
   of rcu_assign_pointer() in v5.1 didn't find a single use of the
   return value, let's please instead change the documentation and
   implementation to eliminate the return value."

[1] https://lkml.kernel.org/r/20190523135013.GL28207@linux.ibm.com

Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: rcu@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
alistair/sunxi64-5.4-dsi
Andrea Parri 2019-05-27 10:49:57 +02:00 committed by Paul E. McKenney
parent 6da9f77517
commit 9129b017b5
4 changed files with 9 additions and 10 deletions

View File

@ -212,7 +212,7 @@ synchronize_rcu()
rcu_assign_pointer() rcu_assign_pointer()
typeof(p) rcu_assign_pointer(p, typeof(p) v); void rcu_assign_pointer(p, typeof(p) v);
Yes, rcu_assign_pointer() -is- implemented as a macro, though it Yes, rcu_assign_pointer() -is- implemented as a macro, though it
would be cool to be able to declare a function in this manner. would be cool to be able to declare a function in this manner.
@ -220,9 +220,9 @@ rcu_assign_pointer()
The updater uses this function to assign a new value to an The updater uses this function to assign a new value to an
RCU-protected pointer, in order to safely communicate the change RCU-protected pointer, in order to safely communicate the change
in value from the updater to the reader. This function returns in value from the updater to the reader. This macro does not
the new value, and also executes any memory-barrier instructions evaluate to an rvalue, but it does execute any memory-barrier
required for a given CPU architecture. instructions required for a given CPU architecture.
Perhaps just as important, it serves to document (1) which Perhaps just as important, it serves to document (1) which
pointers are protected by RCU and (2) the point at which a pointers are protected by RCU and (2) the point at which a

View File

@ -367,7 +367,7 @@ static inline void rcu_preempt_sleep_check(void) { }
* other macros that it invokes. * other macros that it invokes.
*/ */
#define rcu_assign_pointer(p, v) \ #define rcu_assign_pointer(p, v) \
({ \ do { \
uintptr_t _r_a_p__v = (uintptr_t)(v); \ uintptr_t _r_a_p__v = (uintptr_t)(v); \
rcu_check_sparse(p, __rcu); \ rcu_check_sparse(p, __rcu); \
\ \
@ -375,8 +375,7 @@ static inline void rcu_preempt_sleep_check(void) { }
WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \ WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
else \ else \
smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \ smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
_r_a_p__v; \ } while (0)
})
/** /**
* rcu_swap_protected() - swap an RCU and a regular pointer * rcu_swap_protected() - swap an RCU and a regular pointer

View File

@ -19,7 +19,7 @@ static inline bool rcu_is_watching(void)
return false; return false;
} }
#define rcu_assign_pointer(p, v) ((p) = (v)) #define rcu_assign_pointer(p, v) do { (p) = (v); } while (0)
#define RCU_INIT_POINTER(p, v) p=(v) #define RCU_INIT_POINTER(p, v) do { (p) = (v); } while (0)
#endif #endif

View File

@ -7,6 +7,6 @@
#define rcu_dereference_raw(p) rcu_dereference(p) #define rcu_dereference_raw(p) rcu_dereference(p)
#define rcu_dereference_protected(p, cond) rcu_dereference(p) #define rcu_dereference_protected(p, cond) rcu_dereference(p)
#define rcu_dereference_check(p, cond) rcu_dereference(p) #define rcu_dereference_check(p, cond) rcu_dereference(p)
#define RCU_INIT_POINTER(p, v) (p) = (v) #define RCU_INIT_POINTER(p, v) do { (p) = (v); } while (0)
#endif #endif