lockless version of netdev_notify_peers
Subsystems (5)
cover lockless version of netdev_notify_peers
This series introduce the lockless version of netdev_notify_peers and then apply it to the relevant drivers.
In v1, a more appropriate name __netdev_notify_peers is used; netdev_notify_peers is converted to call the new helper.
Lijun Pan (3):
net: core: introduce __netdev_notify_peers
use __netdev_notify_peers in ibmvnic
use __netdev_notify_peers in hyperv
drivers/net/ethernet/ibm/ibmvnic.c | 9 +++------ drivers/net/hyperv/netvsc_drv.c | 6 +++--- include/linux/netdevice.h | 1 + net/core/dev.c | 22 ++++++++++++++++++++-- 4 files changed, 27 insertions(+), 11 deletions(-)
Signature · 1 line
2.23.0
PATCH 3/3 use __netdev_notify_peers in hyperv
Start to use the lockless version of netdev_notify_peers.
--- drivers/net/hyperv/netvsc_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/hyperv/netvsc_drv.c +3 -3
@@ -2130,10 +2130,10 @@ static void netvsc_link_change(struct work_struct *w)break ; } -rtnl_unlock (); -if (notify) -netdev_notify_peers (net); +__netdev_notify_peers (net); + +rtnl_unlock ();/* link_watch only sends one notification with current state per * second, handle next reconfig event in 2 seconds.
Signature · 1 line
2.23.0
PATCH 2/3 use __netdev_notify_peers in ibmvnic
In reply to Lijun PanStart to use the lockless version of netdev_notify_peers.
--- drivers/net/ethernet/ibm/ibmvnic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +3 -6
@@ -2169,10 +2169,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,napi_schedule (&adapter->napi[i]);if (adapter->reset_reason ==VNIC_RESET_FAILOVER || - adapter->reset_reason ==VNIC_RESET_MOBILITY ) { -call_netdevice_notifiers (NETDEV_NOTIFY_PEERS , netdev); -call_netdevice_notifiers (NETDEV_RESEND_IGMP , netdev); - } + adapter->reset_reason ==VNIC_RESET_MOBILITY ) +__netdev_notify_peers (netdev); rc =0 ;
@@ -2247,8 +2245,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, goto out; } -call_netdevice_notifiers (NETDEV_NOTIFY_PEERS , netdev); -call_netdevice_notifiers (NETDEV_RESEND_IGMP , netdev); +__netdev_notify_peers (netdev); out:/* restore adapter state if reset failed */ if (rc)
Signature · 1 line
2.23.0
PATCH 1/3 net: core: introduce __netdev_notify_peers
In reply to Lijun PanThere are some use cases for netdev_notify_peers in the context when rtnl lock is already held. Introduce lockless version of netdev_notify_peers call to save the extra code to call
call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, dev); call_netdevice_notifiers(NETDEV_RESEND_IGMP, dev);
After that, convert netdev_notify_peers to call the new helper.
--- include/linux/netdevice.h | 1 + net/core/dev.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
include/linux/netdevice.h +1 -0
@@ -4547,6 +4547,7 @@ void __dev_set_rx_mode(struct net_device *dev);int dev_set_promiscuity (struct net_device *dev,int inc);int dev_set_allmulti (struct net_device *dev,int inc);void netdev_state_change (struct net_device *dev); +void __netdev_notify_peers (struct net_device *dev);void netdev_notify_peers (struct net_device *dev);void netdev_features_change (struct net_device *dev);/* Load a device via the kmod */
net/core/dev.c +20 -2
@@ -1456,6 +1456,25 @@ void netdev_state_change(struct net_device *dev) }EXPORT_SYMBOL (netdev_state_change); +/** +* __netdev_notify_peers - notify network peers about existence of @dev, +* to be called when rtnl lock is already held. +* @dev: network device +* +* Generate traffic such that interested network peers are aware of +* @dev, such as by generating a gratuitous ARP. This may be used when +* a device wants to inform the rest of the network about some sort of +* reconfiguration such as a failover event or virtual machine +* migration. +*/ +void __netdev_notify_peers (struct net_device *dev) +{ +ASSERT_RTNL (); +call_netdevice_notifiers (NETDEV_NOTIFY_PEERS , dev); +call_netdevice_notifiers (NETDEV_RESEND_IGMP , dev); +} +EXPORT_SYMBOL (__netdev_notify_peers); +/** * netdev_notify_peers - notify network peers about existence of @dev * @dev: network device
@@ -1469,8 +1488,7 @@ EXPORT_SYMBOL(netdev_state_change);void netdev_notify_peers (struct net_device *dev) {rtnl_lock (); -call_netdevice_notifiers (NETDEV_NOTIFY_PEERS , dev); -call_netdevice_notifiers (NETDEV_RESEND_IGMP , dev); +__netdev_notify_peers (dev);rtnl_unlock (); }EXPORT_SYMBOL (netdev_notify_peers);
Signature · 1 line
2.23.0
Jakub Kicinski
maintainerRe: [PATCH net-next 3/3] use __netdev_notify_peers in hyperv
In reply to Lijun PanQuoted 13 lines · On Wed, 9 Dec 2020 00:18:11 -0600 Lijun Pan wrote:
Start to use the lockless version of
netdev_notify_peers.Cc Haiyang Zhang <[email protected]>Signed-off-by Lijun Pan <[email protected]>--- drivers/net/hyperv/netvsc_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/hyperv/netvsc_drv.c +0
-0
drivers/net/hyperv/netvsc_drv.c static void netvsc_link_change(struct work_struct *w) · line 2136
Quoted 10 lines
drivers/net/hyperv/netvsc_drv.c +3
-3@@ -2130,10 +2130,10 @@ static void netvsc_link_change(struct work_struct *w)break ; } -rtnl_unlock (); -if (notify) -netdev_notify_peers (net); +__netdev_notify_peers (net); + +rtnl_unlock ();
Looks like this code is only using this "notify" variable because it wanted to wait until unlock to call the function. I think you can now just call the helper where notify used to be set to true.