Netdev List
 help / color / mirror / Atom feed
* [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing
@ 2018-12-12  9:58 Xiaozhou Liu
  2018-12-12 13:08 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Xiaozhou Liu @ 2018-12-12  9:58 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Xiaozhou Liu

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 <liuxiaozhou@bytedance.com>
---
 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) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing
  2018-12-12  9:58 [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing Xiaozhou Liu
@ 2018-12-12 13:08 ` Eric Dumazet
  2018-12-13  3:35   ` Xiaozhou Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2018-12-12 13:08 UTC (permalink / raw)
  To: Xiaozhou Liu, netdev; +Cc: David S . Miller



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 <liuxiaozhou@bytedance.com>
> ---
>  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 <paulmck@linux.vnet.ibm.com>
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 <hch@infradead.org>
    Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing
  2018-12-12 13:08 ` Eric Dumazet
@ 2018-12-13  3:35   ` Xiaozhou Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Xiaozhou Liu @ 2018-12-13  3:35 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, David S. Miller

On Wed, Dec 12, 2018 at 05:08:45AM -0800, Eric Dumazet wrote:

> 
> 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 <paulmck@linux.vnet.ibm.com>
> 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 <hch@infradead.org>
>     Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Thanks for pointing this out. I guess the comments in include/linux/rcupdate.h
may need some updating.


Xiaozhou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-13  3:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12  9:58 [PATCH net] soreuseport: use RCU_INIT_POINTER() when NULLing Xiaozhou Liu
2018-12-12 13:08 ` Eric Dumazet
2018-12-13  3:35   ` Xiaozhou Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox