Skip to contentSkip to conversation

vlan: unnecessary to check if vlan_pcpu_stats is NULL

PATCH In review [email protected] 3 participants 5 messages Apr 3, 2014 – Apr 4, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vlan: unnecessary to check if vlan_pcpu_stats is NULL

From: Li RongQing <[email protected]>

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

---
 net/8021q/vlan_dev.c |   58 ++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 30 deletions(-)
net/8021q/vlan_dev.c +28 -30
index 4f3e907..dbab6f1 100644
@@ -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;
 }
 
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: [email protected]
Date: Thu, 3 Apr 2014 20:45:25 +0800

Quoted 5 lines

From: Li RongQing <[email protected]>

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

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

It looks unnecessary to me, Eric?

...

Quoted 7 lines

static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) {

net/8021q/vlan_dev.c +3 -1
+	struct vlan_pcpu_stats *p;
+	u32 rx_errors = 0, tx_dropped = 0;
+	int i;
 
-	if (vlan_dev_priv(dev)->vlan_pcpu_stats) {
Acked-by
#2 lore raw
Quoted 5 lines · David Miller

From: [email protected]
Date: Thu, 3 Apr 2014 20:45:25 +0800

Quoted 2 lines

From: Li RongQing <[email protected]>

Quoted 8 lines
Quoted 3 lines

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

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 !

maintainer
#4 lore raw

From: Li RongQing <[email protected]>
Date: Fri, 4 Apr 2014 09:10:31 +0800

Quoted 8 lines
Quoted 5 lines

Right, this patch seems fine, thanks !

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

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