From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing Date: Wed, 12 Dec 2018 05:08:45 -0800 Message-ID: <116312bb-3891-b387-1fab-99ae7c61c0cb@gmail.com> References: <20181212095812.27541-1-liuxiaozhou@bytedance.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "David S . Miller" To: Xiaozhou Liu , netdev@vger.kernel.org Return-path: Received: from mail-wr1-f67.google.com ([209.85.221.67]:35938 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbeLLNIy (ORCPT ); Wed, 12 Dec 2018 08:08:54 -0500 Received: by mail-wr1-f67.google.com with SMTP id u3so17661463wrs.3 for ; Wed, 12 Dec 2018 05:08:53 -0800 (PST) In-Reply-To: <20181212095812.27541-1-liuxiaozhou@bytedance.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 12/12/2018 01:58 AM, Xiaozhou Liu wrote: > Use RCU_INIT_POINTER() instead of rcu_assign_pointer() to > NULL out the pointer because it is a bit faster. > > Signed-off-by: Xiaozhou Liu > --- > net/core/sock_reuseport.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c > index d8fe3e549373..25e71355f0a6 100644 > --- a/net/core/sock_reuseport.c > +++ b/net/core/sock_reuseport.c > @@ -205,7 +205,7 @@ void reuseport_detach_sock(struct sock *sk) > if (reuse->reuseport_id) > bpf_sk_reuseport_detach(sk); > > - rcu_assign_pointer(sk->sk_reuseport_cb, NULL); > + RCU_INIT_POINTER(sk->sk_reuseport_cb, NULL); > > for (i = 0; i < reuse->num_socks; i++) { > if (reuse->socks[i] == sk) { > It is _not_ faster. Just different ways to do the exact same thing. For some reason you missed this two years old commit : commit 3a37f7275cda5ad25c1fe9be8f20c76c60d175fa Author: Paul E. McKenney Date: Sun May 1 18:46:54 2016 -0700 rcu: No ordering for rcu_assign_pointer() of NULL This commit does a compile-time check for rcu_assign_pointer() of NULL, and uses WRITE_ONCE() rather than smp_store_release() in that case. Reported-by: Christoph Hellwig Signed-off-by: Paul E. McKenney