linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
@ 2019-08-06  5:17 Dexuan Cui
  2019-08-06 19:12 ` Jakub Kicinski
  2019-08-09  1:13 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Dexuan Cui @ 2019-08-06  5:17 UTC (permalink / raw)
  To: netdev, David S. Miller, Haiyang Zhang, Stephen Hemminger
  Cc: sashal, KY Srinivasan, Michael Kelley, linux-hyperv,
	linux-kernel, olaf, apw, jasowang, vkuznets, marcelo.cerri


This fixes a warning of "suspicious rcu_dereference_check() usage"
when nload runs.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 44 +++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f9209594624b5..25502d335b94f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1236,25 +1236,10 @@ static void netvsc_get_pcpu_stats(struct net_device *net,
 	}
 }
 
-static void netvsc_get_stats64(struct net_device *net,
-			       struct rtnl_link_stats64 *t)
+static void netvsc_get_per_chan_stats(struct netvsc_device *nvdev,
+				      struct rtnl_link_stats64 *t)
 {
-	struct net_device_context *ndev_ctx = netdev_priv(net);
-	struct netvsc_device *nvdev = rcu_dereference_rtnl(ndev_ctx->nvdev);
-	struct netvsc_vf_pcpu_stats vf_tot;
-	int i;
-
-	if (!nvdev)
-		return;
-
-	netdev_stats_to_stats64(t, &net->stats);
-
-	netvsc_get_vf_stats(net, &vf_tot);
-	t->rx_packets += vf_tot.rx_packets;
-	t->tx_packets += vf_tot.tx_packets;
-	t->rx_bytes   += vf_tot.rx_bytes;
-	t->tx_bytes   += vf_tot.tx_bytes;
-	t->tx_dropped += vf_tot.tx_dropped;
+	u32 i;
 
 	for (i = 0; i < nvdev->num_chn; i++) {
 		const struct netvsc_channel *nvchan = &nvdev->chan_table[i];
@@ -1286,6 +1271,29 @@ static void netvsc_get_stats64(struct net_device *net,
 	}
 }
 
+static void netvsc_get_stats64(struct net_device *net,
+			       struct rtnl_link_stats64 *t)
+{
+	struct net_device_context *ndev_ctx = netdev_priv(net);
+	struct netvsc_device *nvdev;
+	struct netvsc_vf_pcpu_stats vf_tot;
+
+	netdev_stats_to_stats64(t, &net->stats);
+
+	netvsc_get_vf_stats(net, &vf_tot);
+	t->rx_packets += vf_tot.rx_packets;
+	t->tx_packets += vf_tot.tx_packets;
+	t->rx_bytes   += vf_tot.rx_bytes;
+	t->tx_bytes   += vf_tot.tx_bytes;
+	t->tx_dropped += vf_tot.tx_dropped;
+
+	rcu_read_lock();
+	nvdev = rcu_dereference(ndev_ctx->nvdev);
+	if (nvdev)
+		netvsc_get_per_chan_stats(nvdev, t);
+	rcu_read_unlock();
+}
+
 static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
 {
 	struct net_device_context *ndc = netdev_priv(ndev);

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

* Re: [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
  2019-08-06  5:17 [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage Dexuan Cui
@ 2019-08-06 19:12 ` Jakub Kicinski
  2019-08-07  6:56   ` Dexuan Cui
  2019-08-09  1:13 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2019-08-06 19:12 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: netdev, David S. Miller, Haiyang Zhang, Stephen Hemminger,
	sashal, KY Srinivasan, Michael Kelley, linux-hyperv,
	linux-kernel, olaf, apw, jasowang, vkuznets, marcelo.cerri

On Tue, 6 Aug 2019 05:17:44 +0000, Dexuan Cui wrote:
> This fixes a warning of "suspicious rcu_dereference_check() usage"
> when nload runs.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>

Minor change in behaviour would perhaps be worth acknowledging in the
commit message (since you check ndev for NULL later now), and a Fixes
tag would be good.

But the looks pretty straightforward and correct!

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

* RE: [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
  2019-08-06 19:12 ` Jakub Kicinski
@ 2019-08-07  6:56   ` Dexuan Cui
  0 siblings, 0 replies; 5+ messages in thread
From: Dexuan Cui @ 2019-08-07  6:56 UTC (permalink / raw)
  To: Jakub Kicinski, Stephen Hemminger
  Cc: netdev, David S. Miller, Haiyang Zhang, sashal, KY Srinivasan,
	Michael Kelley, linux-hyperv, linux-kernel, olaf, apw, jasowang,
	vkuznets, marcelo.cerri

> From: Jakub Kicinski <jakub.kicinski@netronome.com>
> Sent: Tuesday, August 6, 2019 12:13 PM
> To: Dexuan Cui <decui@microsoft.com>
> 
> On Tue, 6 Aug 2019 05:17:44 +0000, Dexuan Cui wrote:
> > This fixes a warning of "suspicious rcu_dereference_check() usage"
> > when nload runs.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > Signed-off-by: Dexuan Cui <decui@microsoft.com>
> 
> Minor change in behaviour would perhaps be worth acknowledging in the
> commit message (since you check ndev for NULL later now), and a Fixes
> tag would be good.
> 
> But the looks pretty straightforward and correct!

Hi,
Yeah, it looks the minor behavior change doesn't matter, because IMO the 
'nvdev' can only be NULL when the NIC is being removed, or the MTU is
being changed, etc.

The Fixes tag is:
Fixes: 776e726bfb34 ("netvsc: fix RCU warning in get_stats")

If I should send a v2, please let me know.

Thanks,
-- Dexuan


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

* Re: [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
  2019-08-06  5:17 [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage Dexuan Cui
  2019-08-06 19:12 ` Jakub Kicinski
@ 2019-08-09  1:13 ` David Miller
  2019-08-09  1:16   ` Dexuan Cui
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2019-08-09  1:13 UTC (permalink / raw)
  To: decui
  Cc: netdev, haiyangz, sthemmin, sashal, kys, mikelley, linux-hyperv,
	linux-kernel, olaf, apw, jasowang, vkuznets, marcelo.cerri

From: Dexuan Cui <decui@microsoft.com>
Date: Tue, 6 Aug 2019 05:17:44 +0000

> 
> This fixes a warning of "suspicious rcu_dereference_check() usage"
> when nload runs.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>

Please resend with appropriate fixes tag.

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

* RE: [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
  2019-08-09  1:13 ` David Miller
@ 2019-08-09  1:16   ` Dexuan Cui
  0 siblings, 0 replies; 5+ messages in thread
From: Dexuan Cui @ 2019-08-09  1:16 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Haiyang Zhang, Stephen Hemminger, sashal, KY Srinivasan,
	Michael Kelley, linux-hyperv, linux-kernel, olaf, apw, jasowang,
	vkuznets, marcelo.cerri

> From: David Miller <davem@davemloft.net>
> Sent: Thursday, August 8, 2019 6:14 PM
> To: Dexuan Cui <decui@microsoft.com>
> Cc: netdev@vger.kernel.org; Haiyang Zhang <haiyangz@microsoft.com>;
> Stephen Hemminger <sthemmin@microsoft.com>; sashal@kernel.org; KY
> Srinivasan <kys@microsoft.com>; Michael Kelley <mikelley@microsoft.com>;
> linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com; vkuznets
> <vkuznets@redhat.com>; marcelo.cerri@canonical.com
> Subject: Re: [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage
> 
> From: Dexuan Cui <decui@microsoft.com>
> Date: Tue, 6 Aug 2019 05:17:44 +0000
> 
> >
> > This fixes a warning of "suspicious rcu_dereference_check() usage"
> > when nload runs.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > Signed-off-by: Dexuan Cui <decui@microsoft.com>
> 
> Please resend with appropriate fixes tag.

Will do shortly.

Thanks,
-- Dexuan

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

end of thread, other threads:[~2019-08-09  1:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06  5:17 [PATCH net] hv_netvsc: Fix a warning of suspicious RCU usage Dexuan Cui
2019-08-06 19:12 ` Jakub Kicinski
2019-08-07  6:56   ` Dexuan Cui
2019-08-09  1:13 ` David Miller
2019-08-09  1:16   ` Dexuan Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).