Skip to contentSkip to conversation

net: rtnetlink: convert rcu_assign_pointer to RCU_INIT_POINTER

PATCH Applied Yajun Deng 3 participants 3 messages Sep 18, 2021 – Sep 23, 2021

Subsystems (2)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 net: rtnetlink: convert rcu_assign_pointer to RCU_INIT_POINTER

It no need barrier when assigning a NULL value to an RCU protected pointer. So use RCU_INIT_POINTER() instead for more fast.

---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +2 -2
index 972c8cb303a5..327ca6bc6e6d 100644
@@ -301,7 +301,7 @@ int rtnl_unregister(int protocol, int msgtype)
 	}
 
 	link = rtnl_dereference(tab[msgindex]);
-	rcu_assign_pointer(tab[msgindex], NULL);
+	RCU_INIT_POINTER(tab[msgindex], NULL);
 	rtnl_unlock();
 
 	kfree_rcu(link, rcu);
@@ -337,7 +337,7 @@ void rtnl_unregister_all(int protocol)
 		if (!link)
 			continue;
 
-		rcu_assign_pointer(tab[msgindex], NULL);
+		RCU_INIT_POINTER(tab[msgindex], NULL);
 		kfree_rcu(link, rcu);
 	}
 	rtnl_unlock();
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 7 lines · On Sat, 18 Sep 2021 14:36:07 +0800 you wrote:

It no need barrier when assigning a NULL value to an RCU protected pointer. So use RCU_INIT_POINTER() instead for more fast.

---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
- [net-next] net: rtnetlink: convert rcu_assign_pointer to RCU_INIT_POINTER

    https://git.kernel.org/netdev/net-next/c/4fc29989835a

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

#2 lore raw
In reply to Yajun Deng
Quoted 23 lines · Yajun Deng

It no need barrier when assigning a NULL value to an RCU protected pointer. So use RCU_INIT_POINTER() instead for more fast.

---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +1 -1
index 972c8cb303a5..327ca6bc6e6d 100644
@@ -301,7 +301,7 @@ int rtnl_unregister(int protocol, int msgtype)
 	}
 
 	link = rtnl_dereference(tab[msgindex]);
-	rcu_assign_pointer(tab[msgindex], NULL);
+	RCU_INIT_POINTER(tab[msgindex], NULL);
 	rtnl_unlock();
 
 	kfree_rcu(link, rcu);

net/core/rtnetlink.c void rtnl_unregister_all(int protocol) · line 343

Quoted 8 lines
net/core/rtnetlink.c +1 -1
@@ -337,7 +337,7 @@ void rtnl_unregister_all(int protocol)
 		if (!link)
 			continue;
 
-		rcu_assign_pointer(tab[msgindex], NULL);
+		RCU_INIT_POINTER(tab[msgindex], NULL);
 		kfree_rcu(link, rcu);
 	}
 	rtnl_unlock();

FYI, there is no memory barrier involved in

rcu_assign_pointer(tab[msgindex], NULL);

This has been the case for the last 5 years.

Your patch was not needed really.