Re: [PATCH net-next] neigh: Add missing rcu_assign_pointer
From: Eric Dumazet <hidden>
Date: 2015-05-28 10:13:51
On Thu, 2015-05-28 at 16:28 +0800, Ying Xue wrote:
quoted hunk ↗ jump to hunk
Commit e4c4e448cf55 ("neigh: Convert garbage collection from softirq to workqueue") misses to use rcu_assign_pointer() macro to assign a RCU-protected pointer. Signed-off-by: Ying Xue <redacted> --- net/core/neighbour.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 3a74df7..aaad3a5 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c@@ -783,7 +783,8 @@ static void neigh_periodic_work(struct work_struct *work) if (atomic_read(&n->refcnt) == 1 && (state == NUD_FAILED || time_after(jiffies, n->used + NEIGH_VAR(n->parms, GC_STALETIME)))) { - *np = n->next; + rcu_assign_pointer(*np, rcu_dereference_protected(n->next, + lockdep_is_held(&tbl->lock))); n->dead = 1; write_unlock(&n->lock); neigh_cleanup_and_release(n);
This patch is not needed. You really should read Documentation/RCU , because it looks like you are quite confused. When we remove an element from a RCU protected list, all the objects in the chain are already ready to be caught by rcu readers. Therefore, no additional memory barrier is needed before doing *np = n->next; Please do not add spurious memory barriers. Like atomic operations, we want all of them being required and possibly documented.