* [PATCH net-next v2 0/3] lockless version of netdev_notify_peers
@ 2020-12-14 21:19 Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Lijun Pan @ 2020-12-14 21:19 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.
In v2, patch 3 calls the new helper where notify variable used
to be set true.
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 | 11 ++++-------
include/linux/netdevice.h | 1 +
net/core/dev.c | 22 ++++++++++++++++++++--
4 files changed, 28 insertions(+), 15 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/3] net: core: introduce __netdev_notify_peers
2020-12-14 21:19 [PATCH net-next v2 0/3] lockless version of netdev_notify_peers Lijun Pan
@ 2020-12-14 21:19 ` Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Lijun Pan @ 2020-12-14 21:19 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 bde98cfd166f..43e3b176a30a 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] 6+ messages in thread
* [PATCH net-next v2 2/3] use __netdev_notify_peers in ibmvnic
2020-12-14 21:19 [PATCH net-next v2 0/3] lockless version of netdev_notify_peers Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
@ 2020-12-14 21:19 ` Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv Lijun Pan
2020-12-16 20:50 ` [PATCH net-next v2 0/3] lockless version of netdev_notify_peers patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Lijun Pan @ 2020-12-14 21:19 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 a2191392ca4f..f302504faa8a 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2171,10 +2171,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;
@@ -2249,8 +2247,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] 6+ messages in thread
* [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv
2020-12-14 21:19 [PATCH net-next v2 0/3] lockless version of netdev_notify_peers Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
@ 2020-12-14 21:19 ` Lijun Pan
2020-12-14 23:22 ` Jakub Kicinski
2020-12-16 20:50 ` [PATCH net-next v2 0/3] lockless version of netdev_notify_peers patchwork-bot+netdevbpf
3 siblings, 1 reply; 6+ messages in thread
From: Lijun Pan @ 2020-12-14 21:19 UTC (permalink / raw)
To: netdev; +Cc: Lijun Pan, Haiyang Zhang
Start to use the lockless version of netdev_notify_peers.
Call the helper where notify variable used to be set true.
Remove the notify bool variable and sort the variables
in reverse Christmas tree order.
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
v2: call the helper where notify variable used to be set true
according to Jakub's review suggestion.
drivers/net/hyperv/netvsc_drv.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index d17bbc75f5e7..f32f28311d57 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2050,11 +2050,11 @@ static void netvsc_link_change(struct work_struct *w)
container_of(w, struct net_device_context, dwork.work);
struct hv_device *device_obj = ndev_ctx->device_ctx;
struct net_device *net = hv_get_drvdata(device_obj);
+ unsigned long flags, next_reconfig, delay;
+ struct netvsc_reconfig *event = NULL;
struct netvsc_device *net_device;
struct rndis_device *rdev;
- struct netvsc_reconfig *event = NULL;
- bool notify = false, reschedule = false;
- unsigned long flags, next_reconfig, delay;
+ bool reschedule = false;
/* if changes are happening, comeback later */
if (!rtnl_trylock()) {
@@ -2103,7 +2103,7 @@ static void netvsc_link_change(struct work_struct *w)
netif_carrier_on(net);
netvsc_tx_enable(net_device, net);
} else {
- notify = true;
+ __netdev_notify_peers(net);
}
kfree(event);
break;
@@ -2132,9 +2132,6 @@ static void netvsc_link_change(struct work_struct *w)
rtnl_unlock();
- if (notify)
- netdev_notify_peers(net);
-
/* 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] 6+ messages in thread
* Re: [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv
2020-12-14 21:19 ` [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv Lijun Pan
@ 2020-12-14 23:22 ` Jakub Kicinski
0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2020-12-14 23:22 UTC (permalink / raw)
To: Haiyang Zhang, Stephen Hemminger; +Cc: Lijun Pan, netdev
On Mon, 14 Dec 2020 15:19:30 -0600 Lijun Pan wrote:
> Start to use the lockless version of netdev_notify_peers.
> Call the helper where notify variable used to be set true.
> Remove the notify bool variable and sort the variables
> in reverse Christmas tree order.
>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
> ---
> v2: call the helper where notify variable used to be set true
> according to Jakub's review suggestion.
Can we get an ack for merging via net-next?
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index d17bbc75f5e7..f32f28311d57 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -2050,11 +2050,11 @@ static void netvsc_link_change(struct work_struct *w)
> container_of(w, struct net_device_context, dwork.work);
> struct hv_device *device_obj = ndev_ctx->device_ctx;
> struct net_device *net = hv_get_drvdata(device_obj);
> + unsigned long flags, next_reconfig, delay;
> + struct netvsc_reconfig *event = NULL;
> struct netvsc_device *net_device;
> struct rndis_device *rdev;
> - struct netvsc_reconfig *event = NULL;
> - bool notify = false, reschedule = false;
> - unsigned long flags, next_reconfig, delay;
> + bool reschedule = false;
>
> /* if changes are happening, comeback later */
> if (!rtnl_trylock()) {
> @@ -2103,7 +2103,7 @@ static void netvsc_link_change(struct work_struct *w)
> netif_carrier_on(net);
> netvsc_tx_enable(net_device, net);
> } else {
> - notify = true;
> + __netdev_notify_peers(net);
> }
> kfree(event);
> break;
> @@ -2132,9 +2132,6 @@ static void netvsc_link_change(struct work_struct *w)
>
> rtnl_unlock();
>
> - if (notify)
> - netdev_notify_peers(net);
> -
> /* link_watch only sends one notification with current state per
> * second, handle next reconfig event in 2 seconds.
> */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/3] lockless version of netdev_notify_peers
2020-12-14 21:19 [PATCH net-next v2 0/3] lockless version of netdev_notify_peers Lijun Pan
` (2 preceding siblings ...)
2020-12-14 21:19 ` [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv Lijun Pan
@ 2020-12-16 20:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-16 20:50 UTC (permalink / raw)
To: Lijun Pan; +Cc: netdev
Hello:
This series was applied to netdev/net.git (refs/heads/master):
On Mon, 14 Dec 2020 15:19:27 -0600 you wrote:
> 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.
> In v2, patch 3 calls the new helper where notify variable used
> to be set true.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/3] net: core: introduce __netdev_notify_peers
https://git.kernel.org/netdev/net/c/7061eb8cfa90
- [net-next,v2,2/3] use __netdev_notify_peers in ibmvnic
https://git.kernel.org/netdev/net/c/6be4666221ca
- [net-next,v2,3/3] use __netdev_notify_peers in hyperv
https://git.kernel.org/netdev/net/c/935d8a0a43e3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-16 20:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 21:19 [PATCH net-next v2 0/3] lockless version of netdev_notify_peers Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 1/3] net: core: introduce __netdev_notify_peers Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 2/3] use __netdev_notify_peers in ibmvnic Lijun Pan
2020-12-14 21:19 ` [PATCH net-next v2 3/3] use __netdev_notify_peers in hyperv Lijun Pan
2020-12-14 23:22 ` Jakub Kicinski
2020-12-16 20:50 ` [PATCH net-next v2 0/3] lockless version of netdev_notify_peers patchwork-bot+netdevbpf
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.