All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] lockless version of netdev_notify_peers
@ 2020-12-09  6:18 Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Lijun Pan @ 2020-12-09  6:18 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan

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(-)

-- 
2.23.0


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

* [PATCH net-next 1/3] net: core: introduce __netdev_notify_peers
  2020-12-09  6:18 [PATCH net-next 0/3] lockless version of netdev_notify_peers Lijun Pan
@ 2020-12-09  6:18 ` Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 3/3] use __netdev_notify_peers in hyperv Lijun Pan
  2 siblings, 0 replies; 5+ messages in thread
From: Lijun Pan @ 2020-12-09  6:18 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan, Nathan Lynch

There 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.

Suggested-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 include/linux/netdevice.h |  1 +
 net/core/dev.c            | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7bf167993c05..259be67644e3 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -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 */
diff --git a/net/core/dev.c b/net/core/dev.c
index ce8fea2e2788..6aa1de86a2e0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);
-- 
2.23.0


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

* [PATCH net-next 2/3] use __netdev_notify_peers in ibmvnic
  2020-12-09  6:18 [PATCH net-next 0/3] lockless version of netdev_notify_peers Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
@ 2020-12-09  6:18 ` Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 3/3] use __netdev_notify_peers in hyperv Lijun Pan
  2 siblings, 0 replies; 5+ messages in thread
From: Lijun Pan @ 2020-12-09  6:18 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan

Start to use the lockless version of netdev_notify_peers.

Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index cb701a6c0712..626e0f0399aa 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -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)
-- 
2.23.0


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

* [PATCH net-next 3/3] use __netdev_notify_peers in hyperv
  2020-12-09  6:18 [PATCH net-next 0/3] lockless version of netdev_notify_peers Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
  2020-12-09  6:18 ` [PATCH net-next 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
@ 2020-12-09  6:18 ` Lijun Pan
  2020-12-13  1:20   ` Jakub Kicinski
  2 siblings, 1 reply; 5+ messages in thread
From: Lijun Pan @ 2020-12-09  6:18 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan, Haiyang Zhang

Start to use the lockless version of netdev_notify_peers.

Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 drivers/net/hyperv/netvsc_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index d17bbc75f5e7..4e3dac7bb944 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -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.
-- 
2.23.0


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

* Re: [PATCH net-next 3/3] use __netdev_notify_peers in hyperv
  2020-12-09  6:18 ` [PATCH net-next 3/3] use __netdev_notify_peers in hyperv Lijun Pan
@ 2020-12-13  1:20   ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-12-13  1:20 UTC (permalink / raw)
  To: Lijun Pan; +Cc: netdev, Haiyang Zhang

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 <haiyangz@microsoft.com>
> Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
> ---
>  drivers/net/hyperv/netvsc_drv.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index d17bbc75f5e7..4e3dac7bb944 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -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.

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

end of thread, other threads:[~2020-12-13  1:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  6:18 [PATCH net-next 0/3] lockless version of netdev_notify_peers Lijun Pan
2020-12-09  6:18 ` [PATCH net-next 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
2020-12-09  6:18 ` [PATCH net-next 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
2020-12-09  6:18 ` [PATCH net-next 3/3] use __netdev_notify_peers in hyperv Lijun Pan
2020-12-13  1:20   ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.