All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
@ 2014-04-03 12:45 roy.qing.li
  2014-04-03 20:36 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: roy.qing.li @ 2014-04-03 12:45 UTC (permalink / raw)
  To: netdev

From: Li RongQing <roy.qing.li@gmail.com>

if allocating memory for vlan_pcpu_stats failed, the device can not be operated

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 net/8021q/vlan_dev.c |   58 ++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4f3e907..dbab6f1 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -666,38 +666,36 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
 
 static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
+	struct vlan_pcpu_stats *p;
+	u32 rx_errors = 0, tx_dropped = 0;
+	int i;
 
-	if (vlan_dev_priv(dev)->vlan_pcpu_stats) {
-		struct vlan_pcpu_stats *p;
-		u32 rx_errors = 0, tx_dropped = 0;
-		int i;
-
-		for_each_possible_cpu(i) {
-			u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
-			unsigned int start;
-
-			p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
-			do {
-				start = u64_stats_fetch_begin_irq(&p->syncp);
-				rxpackets	= p->rx_packets;
-				rxbytes		= p->rx_bytes;
-				rxmulticast	= p->rx_multicast;
-				txpackets	= p->tx_packets;
-				txbytes		= p->tx_bytes;
-			} while (u64_stats_fetch_retry_irq(&p->syncp, start));
-
-			stats->rx_packets	+= rxpackets;
-			stats->rx_bytes		+= rxbytes;
-			stats->multicast	+= rxmulticast;
-			stats->tx_packets	+= txpackets;
-			stats->tx_bytes		+= txbytes;
-			/* rx_errors & tx_dropped are u32 */
-			rx_errors	+= p->rx_errors;
-			tx_dropped	+= p->tx_dropped;
-		}
-		stats->rx_errors  = rx_errors;
-		stats->tx_dropped = tx_dropped;
+	for_each_possible_cpu(i) {
+		u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
+		unsigned int start;
+
+		p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
+		do {
+			start = u64_stats_fetch_begin_irq(&p->syncp);
+			rxpackets	= p->rx_packets;
+			rxbytes		= p->rx_bytes;
+			rxmulticast	= p->rx_multicast;
+			txpackets	= p->tx_packets;
+			txbytes		= p->tx_bytes;
+		} while (u64_stats_fetch_retry_irq(&p->syncp, start));
+
+		stats->rx_packets	+= rxpackets;
+		stats->rx_bytes		+= rxbytes;
+		stats->multicast	+= rxmulticast;
+		stats->tx_packets	+= txpackets;
+		stats->tx_bytes		+= txbytes;
+		/* rx_errors & tx_dropped are u32 */
+		rx_errors	+= p->rx_errors;
+		tx_dropped	+= p->tx_dropped;
 	}
+	stats->rx_errors  = rx_errors;
+	stats->tx_dropped = tx_dropped;
+
 	return stats;
 }
 
-- 
1.7.10.4

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

* Re: [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
  2014-04-03 12:45 [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL roy.qing.li
@ 2014-04-03 20:36 ` David Miller
  2014-04-03 21:01   ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2014-04-03 20:36 UTC (permalink / raw)
  To: roy.qing.li; +Cc: netdev, edumazet

From: roy.qing.li@gmail.com
Date: Thu,  3 Apr 2014 20:45:25 +0800

> From: Li RongQing <roy.qing.li@gmail.com>
> 
> if allocating memory for vlan_pcpu_stats failed, the device can not be operated
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>

This check seems to have been there since Eric Dumazet added precise
RX statistic accounting.

It looks unnecessary to me, Eric?

 ...
>  static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
>  {
> +	struct vlan_pcpu_stats *p;
> +	u32 rx_errors = 0, tx_dropped = 0;
> +	int i;
>  
> -	if (vlan_dev_priv(dev)->vlan_pcpu_stats) {

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

* Re: [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
  2014-04-03 20:36 ` David Miller
@ 2014-04-03 21:01   ` Eric Dumazet
  2014-04-04  1:10     ` Li RongQing
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2014-04-03 21:01 UTC (permalink / raw)
  To: David Miller; +Cc: roy.qing.li, netdev, edumazet

On Thu, 2014-04-03 at 16:36 -0400, David Miller wrote:
> From: roy.qing.li@gmail.com
> Date: Thu,  3 Apr 2014 20:45:25 +0800
> 
> > From: Li RongQing <roy.qing.li@gmail.com>
> > 
> > if allocating memory for vlan_pcpu_stats failed, the device can not be operated
> > 
> > Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> 
> This check seems to have been there since Eric Dumazet added precise
> RX statistic accounting.
> 
> It looks unnecessary to me, Eric?

Right, this patch seems fine, thanks !

Acked-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
  2014-04-03 21:01   ` Eric Dumazet
@ 2014-04-04  1:10     ` Li RongQing
  2014-04-04 13:59       ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Li RongQing @ 2014-04-04  1:10 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Eric Dumazet

> Right, this patch seems fine, thanks !
>
> Acked-by: Eric Dumazet <edumazet@google.com>
>
>

Thanks;
This should be for net-next, not net; Thanks.

-Roy

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

* Re: [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
  2014-04-04  1:10     ` Li RongQing
@ 2014-04-04 13:59       ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2014-04-04 13:59 UTC (permalink / raw)
  To: roy.qing.li; +Cc: eric.dumazet, netdev, edumazet

From: Li RongQing <roy.qing.li@gmail.com>
Date: Fri, 4 Apr 2014 09:10:31 +0800

>> Right, this patch seems fine, thanks !
>>
>> Acked-by: Eric Dumazet <edumazet@google.com>
>>
>>
> 
> Thanks;
> This should be for net-next, not net; Thanks.

The net-next tree is closed, please resubmit when it opens back up.

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

* Re: [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
  2014-04-21 11:49 roy.qing.li
@ 2014-04-23  1:29 ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2014-04-23  1:29 UTC (permalink / raw)
  To: roy.qing.li; +Cc: netdev, edumazet

From: roy.qing.li@gmail.com
Date: Mon, 21 Apr 2014 19:49:08 +0800

> From: Li RongQing <roy.qing.li@gmail.com>
> 
> if allocating memory for vlan_pcpu_stats failed, the device can not be operated
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>

Applied.

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

* [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL
@ 2014-04-21 11:49 roy.qing.li
  2014-04-23  1:29 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: roy.qing.li @ 2014-04-21 11:49 UTC (permalink / raw)
  To: netdev; +Cc: edumazet

From: Li RongQing <roy.qing.li@gmail.com>

if allocating memory for vlan_pcpu_stats failed, the device can not be operated

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
---
 net/8021q/vlan_dev.c |   58 ++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 6f142f0..0cc60ad 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -670,38 +670,36 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
 
 static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
+	struct vlan_pcpu_stats *p;
+	u32 rx_errors = 0, tx_dropped = 0;
+	int i;
 
-	if (vlan_dev_priv(dev)->vlan_pcpu_stats) {
-		struct vlan_pcpu_stats *p;
-		u32 rx_errors = 0, tx_dropped = 0;
-		int i;
-
-		for_each_possible_cpu(i) {
-			u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
-			unsigned int start;
-
-			p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
-			do {
-				start = u64_stats_fetch_begin_irq(&p->syncp);
-				rxpackets	= p->rx_packets;
-				rxbytes		= p->rx_bytes;
-				rxmulticast	= p->rx_multicast;
-				txpackets	= p->tx_packets;
-				txbytes		= p->tx_bytes;
-			} while (u64_stats_fetch_retry_irq(&p->syncp, start));
-
-			stats->rx_packets	+= rxpackets;
-			stats->rx_bytes		+= rxbytes;
-			stats->multicast	+= rxmulticast;
-			stats->tx_packets	+= txpackets;
-			stats->tx_bytes		+= txbytes;
-			/* rx_errors & tx_dropped are u32 */
-			rx_errors	+= p->rx_errors;
-			tx_dropped	+= p->tx_dropped;
-		}
-		stats->rx_errors  = rx_errors;
-		stats->tx_dropped = tx_dropped;
+	for_each_possible_cpu(i) {
+		u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
+		unsigned int start;
+
+		p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
+		do {
+			start = u64_stats_fetch_begin_irq(&p->syncp);
+			rxpackets	= p->rx_packets;
+			rxbytes		= p->rx_bytes;
+			rxmulticast	= p->rx_multicast;
+			txpackets	= p->tx_packets;
+			txbytes		= p->tx_bytes;
+		} while (u64_stats_fetch_retry_irq(&p->syncp, start));
+
+		stats->rx_packets	+= rxpackets;
+		stats->rx_bytes		+= rxbytes;
+		stats->multicast	+= rxmulticast;
+		stats->tx_packets	+= txpackets;
+		stats->tx_bytes		+= txbytes;
+		/* rx_errors & tx_dropped are u32 */
+		rx_errors	+= p->rx_errors;
+		tx_dropped	+= p->tx_dropped;
 	}
+	stats->rx_errors  = rx_errors;
+	stats->tx_dropped = tx_dropped;
+
 	return stats;
 }
 
-- 
1.7.10.4

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

end of thread, other threads:[~2014-04-23  1:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-03 12:45 [PATCH] vlan: unnecessary to check if vlan_pcpu_stats is NULL roy.qing.li
2014-04-03 20:36 ` David Miller
2014-04-03 21:01   ` Eric Dumazet
2014-04-04  1:10     ` Li RongQing
2014-04-04 13:59       ` David Miller
2014-04-21 11:49 roy.qing.li
2014-04-23  1:29 ` David Miller

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.