netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
@ 2020-10-11 19:34 Heiner Kallweit
  2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
                   ` (12 more replies)
  0 siblings, 13 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:34 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

In several places the same code is used to populate rtnl_link_stats64
fields with data from pcpu_sw_netstats. Therefore factor out this code
to a new function dev_fetch_sw_netstats().

Heiner Kallweit (12):
  net: core: add function dev_fetch_sw_netstats for fetching
    pcpu_sw_netstats
  IB/hfi1: use new function dev_fetch_sw_netstats
  net: macsec: use new function dev_fetch_sw_netstats
  net: usb: qmi_wwan: use new function dev_fetch_sw_netstats
  net: usbnet: use new function dev_fetch_sw_netstats
  qtnfmac: use new function dev_fetch_sw_netstats
  net: bridge: use new function dev_fetch_sw_netstats
  net: dsa: use new function dev_fetch_sw_netstats
  iptunnel: use new function dev_fetch_sw_netstats
  mac80211: use new function dev_fetch_sw_netstats
  net: openvswitch: use new function dev_fetch_sw_netstats
  xfrm: use new function dev_fetch_sw_netstats

 drivers/infiniband/hw/hfi1/ipoib_main.c       | 34 +-----------------
 drivers/net/macsec.c                          | 25 +------------
 drivers/net/usb/qmi_wwan.c                    | 24 +------------
 drivers/net/usb/usbnet.c                      | 24 +------------
 drivers/net/wireless/quantenna/qtnfmac/core.c | 27 +-------------
 include/linux/netdevice.h                     |  2 ++
 net/bridge/br_device.c                        | 21 +----------
 net/core/dev.c                                | 36 +++++++++++++++++++
 net/dsa/slave.c                               | 21 +----------
 net/ipv4/ip_tunnel_core.c                     | 23 +-----------
 net/mac80211/iface.c                          | 23 +-----------
 net/openvswitch/vport-internal_dev.c          | 20 +----------
 net/xfrm/xfrm_interface.c                     | 22 +-----------
 13 files changed, 49 insertions(+), 253 deletions(-)

-- 
2.28.0


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

* [PATCH net-next 01/12] net: core: add function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
@ 2020-10-11 19:36 ` Heiner Kallweit
  2020-10-11 19:54   ` Stephen Hemminger
  2020-10-11 22:07   ` Jakub Kicinski
  2020-10-11 19:37 ` [PATCH net-next 02/12] IB/hfi1: use new function dev_fetch_sw_netstats Heiner Kallweit
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:36 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

In several places the same code is used to populate rtnl_link_stats64
fields with data from pcpu_sw_netstats. Therefore factor out this code
to a new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 include/linux/netdevice.h |  2 ++
 net/core/dev.c            | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a0df43b13..ca4736349 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4495,6 +4495,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
 					struct rtnl_link_stats64 *storage);
 void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
 			     const struct net_device_stats *netdev_stats);
+void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
+			   struct pcpu_sw_netstats __percpu *netstats);
 
 extern int		netdev_max_backlog;
 extern int		netdev_tstamp_prequeue;
diff --git a/net/core/dev.c b/net/core/dev.c
index 7d18560b2..ba91bf16b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10323,6 +10323,42 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
 }
 EXPORT_SYMBOL(dev_get_stats);
 
+/**
+ *	dev_fetch_sw_netstats - get per-cpu network device statistics
+ *	@s: place to store stats
+ *	@netstats: per-cpu network stats to read from
+ *
+ *	Read per-cpu network statistics and populate the related fields in s.
+ */
+void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
+			   struct pcpu_sw_netstats __percpu *netstats)
+{
+	int cpu;
+
+	if (IS_ERR_OR_NULL(netstats))
+		return;
+
+	for_each_possible_cpu(cpu) {
+		struct pcpu_sw_netstats *stats, tmp;
+		unsigned int start;
+
+		stats = per_cpu_ptr(netstats, cpu);
+		do {
+			start = u64_stats_fetch_begin_irq(&stats->syncp);
+			tmp.rx_packets = stats->rx_packets;
+			tmp.rx_bytes   = stats->rx_bytes;
+			tmp.tx_packets = stats->tx_packets;
+			tmp.tx_bytes   = stats->tx_bytes;
+		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
+
+		s->rx_packets += tmp.rx_packets;
+		s->rx_bytes   += tmp.rx_bytes;
+		s->tx_packets += tmp.tx_packets;
+		s->tx_bytes   += tmp.tx_bytes;
+	}
+}
+EXPORT_SYMBOL(dev_fetch_sw_netstats);
+
 struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 {
 	struct netdev_queue *queue = dev_ingress_queue(dev);
-- 
2.28.0



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

* [PATCH net-next 02/12] IB/hfi1: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
  2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
@ 2020-10-11 19:37 ` Heiner Kallweit
  2020-10-11 19:38 ` [PATCH net-next 03/12] net: macsec: " Heiner Kallweit
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:37 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/infiniband/hw/hfi1/ipoib_main.c | 34 +------------------------
 1 file changed, 1 insertion(+), 33 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
index 014351ebb..9f71b9d70 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_main.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
@@ -97,41 +97,9 @@ static void hfi1_ipoib_dev_get_stats64(struct net_device *dev,
 				       struct rtnl_link_stats64 *storage)
 {
 	struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
-	u64 rx_packets = 0ull;
-	u64 rx_bytes = 0ull;
-	u64 tx_packets = 0ull;
-	u64 tx_bytes = 0ull;
-	int i;
 
 	netdev_stats_to_stats64(storage, &dev->stats);
-
-	for_each_possible_cpu(i) {
-		const struct pcpu_sw_netstats *stats;
-		unsigned int start;
-		u64 trx_packets;
-		u64 trx_bytes;
-		u64 ttx_packets;
-		u64 ttx_bytes;
-
-		stats = per_cpu_ptr(priv->netstats, i);
-		do {
-			start = u64_stats_fetch_begin_irq(&stats->syncp);
-			trx_packets = stats->rx_packets;
-			trx_bytes = stats->rx_bytes;
-			ttx_packets = stats->tx_packets;
-			ttx_bytes = stats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
-
-		rx_packets += trx_packets;
-		rx_bytes += trx_bytes;
-		tx_packets += ttx_packets;
-		tx_bytes += ttx_bytes;
-	}
-
-	storage->rx_packets += rx_packets;
-	storage->rx_bytes += rx_bytes;
-	storage->tx_packets += tx_packets;
-	storage->tx_bytes += tx_bytes;
+	dev_fetch_sw_netstats(storage, priv->netstats);
 }
 
 static const struct net_device_ops hfi1_ipoib_netdev_ops = {
-- 
2.28.0



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

* [PATCH net-next 03/12] net: macsec: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
  2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
  2020-10-11 19:37 ` [PATCH net-next 02/12] IB/hfi1: use new function dev_fetch_sw_netstats Heiner Kallweit
@ 2020-10-11 19:38 ` Heiner Kallweit
  2020-10-11 19:38 ` [PATCH net-next 04/12] net: usb: qmi_wwan: " Heiner Kallweit
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:38 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/macsec.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 2b0c8f01d..e74483279 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3647,30 +3647,7 @@ static int macsec_change_mtu(struct net_device *dev, int new_mtu)
 static void macsec_get_stats64(struct net_device *dev,
 			       struct rtnl_link_stats64 *s)
 {
-	int cpu;
-
-	if (!dev->tstats)
-		return;
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats;
-		struct pcpu_sw_netstats tmp;
-		int start;
-
-		stats = per_cpu_ptr(dev->tstats, cpu);
-		do {
-			start = u64_stats_fetch_begin_irq(&stats->syncp);
-			tmp.rx_packets = stats->rx_packets;
-			tmp.rx_bytes   = stats->rx_bytes;
-			tmp.tx_packets = stats->tx_packets;
-			tmp.tx_bytes   = stats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
-
-		s->rx_packets += tmp.rx_packets;
-		s->rx_bytes   += tmp.rx_bytes;
-		s->tx_packets += tmp.tx_packets;
-		s->tx_bytes   += tmp.tx_bytes;
-	}
+	dev_fetch_sw_netstats(s, dev->tstats);
 
 	s->rx_dropped = dev->stats.rx_dropped;
 	s->tx_dropped = dev->stats.tx_dropped;
-- 
2.28.0



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

* [PATCH net-next 04/12] net: usb: qmi_wwan: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (2 preceding siblings ...)
  2020-10-11 19:38 ` [PATCH net-next 03/12] net: macsec: " Heiner Kallweit
@ 2020-10-11 19:38 ` Heiner Kallweit
  2020-10-12  6:47   ` Bjørn Mork
  2020-10-11 19:39 ` [PATCH net-next 05/12] net: usbnet: " Heiner Kallweit
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:38 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/usb/qmi_wwan.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 5ca1356b8..a322f5187 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -126,31 +126,9 @@ static void qmimux_get_stats64(struct net_device *net,
 			       struct rtnl_link_stats64 *stats)
 {
 	struct qmimux_priv *priv = netdev_priv(net);
-	unsigned int start;
-	int cpu;
 
 	netdev_stats_to_stats64(stats, &net->stats);
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats64;
-		u64 rx_packets, rx_bytes;
-		u64 tx_packets, tx_bytes;
-
-		stats64 = per_cpu_ptr(priv->stats64, cpu);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&stats64->syncp);
-			rx_packets = stats64->rx_packets;
-			rx_bytes = stats64->rx_bytes;
-			tx_packets = stats64->tx_packets;
-			tx_bytes = stats64->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
-
-		stats->rx_packets += rx_packets;
-		stats->rx_bytes += rx_bytes;
-		stats->tx_packets += tx_packets;
-		stats->tx_bytes += tx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, priv->stats64);
 }
 
 static const struct net_device_ops qmimux_netdev_ops = {
-- 
2.28.0



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

* [PATCH net-next 05/12] net: usbnet: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (3 preceding siblings ...)
  2020-10-11 19:38 ` [PATCH net-next 04/12] net: usb: qmi_wwan: " Heiner Kallweit
@ 2020-10-11 19:39 ` Heiner Kallweit
  2020-10-11 19:40 ` [PATCH net-next 06/12] qtnfmac: " Heiner Kallweit
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:39 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/usb/usbnet.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 963d260d1..6062dc278 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -983,31 +983,9 @@ EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings);
 void usbnet_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats)
 {
 	struct usbnet *dev = netdev_priv(net);
-	unsigned int start;
-	int cpu;
 
 	netdev_stats_to_stats64(stats, &net->stats);
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats64;
-		u64 rx_packets, rx_bytes;
-		u64 tx_packets, tx_bytes;
-
-		stats64 = per_cpu_ptr(dev->stats64, cpu);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&stats64->syncp);
-			rx_packets = stats64->rx_packets;
-			rx_bytes = stats64->rx_bytes;
-			tx_packets = stats64->tx_packets;
-			tx_bytes = stats64->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
-
-		stats->rx_packets += rx_packets;
-		stats->rx_bytes += rx_bytes;
-		stats->tx_packets += tx_packets;
-		stats->tx_bytes += tx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, dev->stats64);
 }
 EXPORT_SYMBOL_GPL(usbnet_get_stats64);
 
-- 
2.28.0



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

* [PATCH net-next 06/12] qtnfmac: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (4 preceding siblings ...)
  2020-10-11 19:39 ` [PATCH net-next 05/12] net: usbnet: " Heiner Kallweit
@ 2020-10-11 19:40 ` Heiner Kallweit
  2020-10-12  7:10   ` Kalle Valo
  2020-10-11 19:40 ` [PATCH net-next 07/12] net: bridge: " Heiner Kallweit
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:40 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/wireless/quantenna/qtnfmac/core.c | 27 +------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 374074dc7..7f66cf608 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -139,34 +139,9 @@ static void qtnf_netdev_get_stats64(struct net_device *ndev,
 				    struct rtnl_link_stats64 *stats)
 {
 	struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
-	unsigned int start;
-	int cpu;
 
 	netdev_stats_to_stats64(stats, &ndev->stats);
-
-	if (!vif->stats64)
-		return;
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats64;
-		u64 rx_packets, rx_bytes;
-		u64 tx_packets, tx_bytes;
-
-		stats64 = per_cpu_ptr(vif->stats64, cpu);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&stats64->syncp);
-			rx_packets = stats64->rx_packets;
-			rx_bytes = stats64->rx_bytes;
-			tx_packets = stats64->tx_packets;
-			tx_bytes = stats64->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
-
-		stats->rx_packets += rx_packets;
-		stats->rx_bytes += rx_bytes;
-		stats->tx_packets += tx_packets;
-		stats->tx_bytes += tx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, vif->stats64);
 }
 
 /* Netdev handler for transmission timeout.
-- 
2.28.0



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

* [PATCH net-next 07/12] net: bridge: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (5 preceding siblings ...)
  2020-10-11 19:40 ` [PATCH net-next 06/12] qtnfmac: " Heiner Kallweit
@ 2020-10-11 19:40 ` Heiner Kallweit
  2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:40 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/bridge/br_device.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 9a2fb4aa1..6f742fee8 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -206,27 +206,8 @@ static void br_get_stats64(struct net_device *dev,
 			   struct rtnl_link_stats64 *stats)
 {
 	struct net_bridge *br = netdev_priv(dev);
-	struct pcpu_sw_netstats tmp, sum = { 0 };
-	unsigned int cpu;
-
-	for_each_possible_cpu(cpu) {
-		unsigned int start;
-		const struct pcpu_sw_netstats *bstats
-			= per_cpu_ptr(br->stats, cpu);
-		do {
-			start = u64_stats_fetch_begin_irq(&bstats->syncp);
-			memcpy(&tmp, bstats, sizeof(tmp));
-		} while (u64_stats_fetch_retry_irq(&bstats->syncp, start));
-		sum.tx_bytes   += tmp.tx_bytes;
-		sum.tx_packets += tmp.tx_packets;
-		sum.rx_bytes   += tmp.rx_bytes;
-		sum.rx_packets += tmp.rx_packets;
-	}
 
-	stats->tx_bytes   = sum.tx_bytes;
-	stats->tx_packets = sum.tx_packets;
-	stats->rx_bytes   = sum.rx_bytes;
-	stats->rx_packets = sum.rx_packets;
+	dev_fetch_sw_netstats(stats, br->stats);
 }
 
 static int br_change_mtu(struct net_device *dev, int new_mtu)
-- 
2.28.0



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

* [PATCH net-next 08/12] net: dsa: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (6 preceding siblings ...)
  2020-10-11 19:40 ` [PATCH net-next 07/12] net: bridge: " Heiner Kallweit
@ 2020-10-11 19:41 ` Heiner Kallweit
  2020-10-11 20:15   ` Vladimir Oltean
  2020-10-12  1:49   ` Florian Fainelli
  2020-10-11 19:42 ` [PATCH net-next 09/12] iptunnel: " Heiner Kallweit
                   ` (4 subsequent siblings)
  12 siblings, 2 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:41 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/dsa/slave.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e7c1d62fd..3bc5ca40c 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1221,28 +1221,9 @@ static void dsa_slave_get_stats64(struct net_device *dev,
 				  struct rtnl_link_stats64 *stats)
 {
 	struct dsa_slave_priv *p = netdev_priv(dev);
-	struct pcpu_sw_netstats *s;
-	unsigned int start;
-	int i;
 
 	netdev_stats_to_stats64(stats, &dev->stats);
-	for_each_possible_cpu(i) {
-		u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
-
-		s = per_cpu_ptr(p->stats64, i);
-		do {
-			start = u64_stats_fetch_begin_irq(&s->syncp);
-			tx_packets = s->tx_packets;
-			tx_bytes = s->tx_bytes;
-			rx_packets = s->rx_packets;
-			rx_bytes = s->rx_bytes;
-		} while (u64_stats_fetch_retry_irq(&s->syncp, start));
-
-		stats->tx_packets += tx_packets;
-		stats->tx_bytes += tx_bytes;
-		stats->rx_packets += rx_packets;
-		stats->rx_bytes += rx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, p->stats64);
 }
 
 static int dsa_slave_get_rxnfc(struct net_device *dev,
-- 
2.28.0



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

* [PATCH net-next 09/12] iptunnel: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (7 preceding siblings ...)
  2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
@ 2020-10-11 19:42 ` Heiner Kallweit
  2020-10-11 19:42 ` [PATCH net-next 10/12] mac80211: " Heiner Kallweit
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/ipv4/ip_tunnel_core.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index b2ea1a8c5..25f1caf5a 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -433,29 +433,8 @@ EXPORT_SYMBOL(skb_tunnel_check_pmtu);
 void ip_tunnel_get_stats64(struct net_device *dev,
 			   struct rtnl_link_stats64 *tot)
 {
-	int i;
-
 	netdev_stats_to_stats64(tot, &dev->stats);
-
-	for_each_possible_cpu(i) {
-		const struct pcpu_sw_netstats *tstats =
-						   per_cpu_ptr(dev->tstats, i);
-		u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
-		unsigned int start;
-
-		do {
-			start = u64_stats_fetch_begin_irq(&tstats->syncp);
-			rx_packets = tstats->rx_packets;
-			tx_packets = tstats->tx_packets;
-			rx_bytes = tstats->rx_bytes;
-			tx_bytes = tstats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&tstats->syncp, start));
-
-		tot->rx_packets += rx_packets;
-		tot->tx_packets += tx_packets;
-		tot->rx_bytes   += rx_bytes;
-		tot->tx_bytes   += tx_bytes;
-	}
+	dev_fetch_sw_netstats(tot, dev->tstats);
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64);
 
-- 
2.28.0



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

* [PATCH net-next 10/12] mac80211: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (8 preceding siblings ...)
  2020-10-11 19:42 ` [PATCH net-next 09/12] iptunnel: " Heiner Kallweit
@ 2020-10-11 19:42 ` Heiner Kallweit
  2020-10-11 19:43 ` [PATCH net-next 11/12] net: openvswitch: " Heiner Kallweit
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/mac80211/iface.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 240862a74..1be775979 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -709,28 +709,7 @@ static u16 ieee80211_netdev_select_queue(struct net_device *dev,
 static void
 ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
-	int i;
-
-	for_each_possible_cpu(i) {
-		const struct pcpu_sw_netstats *tstats;
-		u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
-		unsigned int start;
-
-		tstats = per_cpu_ptr(dev->tstats, i);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&tstats->syncp);
-			rx_packets = tstats->rx_packets;
-			tx_packets = tstats->tx_packets;
-			rx_bytes = tstats->rx_bytes;
-			tx_bytes = tstats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&tstats->syncp, start));
-
-		stats->rx_packets += rx_packets;
-		stats->tx_packets += tx_packets;
-		stats->rx_bytes   += rx_bytes;
-		stats->tx_bytes   += tx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, dev->tstats);
 }
 
 static const struct net_device_ops ieee80211_dataif_ops = {
-- 
2.28.0



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

* [PATCH net-next 11/12] net: openvswitch: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (9 preceding siblings ...)
  2020-10-11 19:42 ` [PATCH net-next 10/12] mac80211: " Heiner Kallweit
@ 2020-10-11 19:43 ` Heiner Kallweit
  2020-10-11 19:44 ` [PATCH net-next 12/12] xfrm: " Heiner Kallweit
  2020-10-11 22:10 ` [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:43 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/openvswitch/vport-internal_dev.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index d8fe66eea..1e30d8df3 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -86,31 +86,13 @@ static void internal_dev_destructor(struct net_device *dev)
 static void
 internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
-	int i;
-
 	memset(stats, 0, sizeof(*stats));
 	stats->rx_errors  = dev->stats.rx_errors;
 	stats->tx_errors  = dev->stats.tx_errors;
 	stats->tx_dropped = dev->stats.tx_dropped;
 	stats->rx_dropped = dev->stats.rx_dropped;
 
-	for_each_possible_cpu(i) {
-		const struct pcpu_sw_netstats *percpu_stats;
-		struct pcpu_sw_netstats local_stats;
-		unsigned int start;
-
-		percpu_stats = per_cpu_ptr(dev->tstats, i);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&percpu_stats->syncp);
-			local_stats = *percpu_stats;
-		} while (u64_stats_fetch_retry_irq(&percpu_stats->syncp, start));
-
-		stats->rx_bytes         += local_stats.rx_bytes;
-		stats->rx_packets       += local_stats.rx_packets;
-		stats->tx_bytes         += local_stats.tx_bytes;
-		stats->tx_packets       += local_stats.tx_packets;
-	}
+	dev_fetch_sw_netstats(stats, dev->tstats);
 }
 
 static const struct net_device_ops internal_dev_netdev_ops = {
-- 
2.28.0



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

* [PATCH net-next 12/12] xfrm: use new function dev_fetch_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (10 preceding siblings ...)
  2020-10-11 19:43 ` [PATCH net-next 11/12] net: openvswitch: " Heiner Kallweit
@ 2020-10-11 19:44 ` Heiner Kallweit
  2020-10-11 22:10 ` [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
  12 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 19:44 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/xfrm/xfrm_interface.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 5b120936d..aa4cdcf69 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -541,27 +541,7 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p)
 static void xfrmi_get_stats64(struct net_device *dev,
 			       struct rtnl_link_stats64 *s)
 {
-	int cpu;
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats;
-		struct pcpu_sw_netstats tmp;
-		int start;
-
-		stats = per_cpu_ptr(dev->tstats, cpu);
-		do {
-			start = u64_stats_fetch_begin_irq(&stats->syncp);
-			tmp.rx_packets = stats->rx_packets;
-			tmp.rx_bytes   = stats->rx_bytes;
-			tmp.tx_packets = stats->tx_packets;
-			tmp.tx_bytes   = stats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
-
-		s->rx_packets += tmp.rx_packets;
-		s->rx_bytes   += tmp.rx_bytes;
-		s->tx_packets += tmp.tx_packets;
-		s->tx_bytes   += tmp.tx_bytes;
-	}
+	dev_fetch_sw_netstats(s, dev->tstats);
 
 	s->rx_dropped = dev->stats.rx_dropped;
 	s->tx_dropped = dev->stats.tx_dropped;
-- 
2.28.0



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

* Re: [PATCH net-next 01/12] net: core: add function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
@ 2020-10-11 19:54   ` Stephen Hemminger
  2020-10-11 20:18     ` Heiner Kallweit
  2020-10-11 22:07   ` Jakub Kicinski
  1 sibling, 1 reply; 23+ messages in thread
From: Stephen Hemminger @ 2020-10-11 19:54 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On Sun, 11 Oct 2020 21:36:43 +0200
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> +void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
> +			   struct pcpu_sw_netstats __percpu *netstats)

netstats is unmodified, should it be const?

> +{
> +	int cpu;
> +
> +	if (IS_ERR_OR_NULL(netstats))
> +		return;

Any code calling this with a null pointer is broken/buggy, please don't
ignore that.

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

* Re: [PATCH net-next 08/12] net: dsa: use new function dev_fetch_sw_netstats
  2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
@ 2020-10-11 20:15   ` Vladimir Oltean
  2020-10-12  1:49   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Vladimir Oltean @ 2020-10-11 20:15 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Johannes Berg, Pravin B Shelar, Steffen Klassert, Herbert Xu,
	netdev, linux-rdma, Linux USB Mailing List, linux-wireless,
	bridge

On Sun, Oct 11, 2020 at 09:41:27PM +0200, Heiner Kallweit wrote:
> Simplify the code by using new function dev_fetch_sw_netstats().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---

Tested-by: Vladimir Oltean <olteanv@gmail.com>

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

* Re: [PATCH net-next 01/12] net: core: add function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 19:54   ` Stephen Hemminger
@ 2020-10-11 20:18     ` Heiner Kallweit
  0 siblings, 0 replies; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 20:18 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On 11.10.2020 21:54, Stephen Hemminger wrote:
> On Sun, 11 Oct 2020 21:36:43 +0200
> Heiner Kallweit <hkallweit1@gmail.com> wrote:
> 
>> +void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
>> +			   struct pcpu_sw_netstats __percpu *netstats)
> 
> netstats is unmodified, should it be const?
> 
>> +{
>> +	int cpu;
>> +
>> +	if (IS_ERR_OR_NULL(netstats))
>> +		return;
> 
> Any code calling this with a null pointer is broken/buggy, please don't
> ignore that.
> 
Thanks, I'll consider both points in a v2.

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

* Re: [PATCH net-next 01/12] net: core: add function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
  2020-10-11 19:54   ` Stephen Hemminger
@ 2020-10-11 22:07   ` Jakub Kicinski
  1 sibling, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2020-10-11 22:07 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Bjørn Mork, Oliver Neukum, Igor Mitsyanko,
	Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On Sun, 11 Oct 2020 21:36:43 +0200 Heiner Kallweit wrote:
> In several places the same code is used to populate rtnl_link_stats64
> fields with data from pcpu_sw_netstats. Therefore factor out this code
> to a new function dev_fetch_sw_netstats().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

> +/**
> + *	dev_fetch_sw_netstats - get per-cpu network device statistics
> + *	@s: place to store stats
> + *	@netstats: per-cpu network stats to read from
> + *
> + *	Read per-cpu network statistics and populate the related fields in s.

in @s?

> + */
> +void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
> +			   struct pcpu_sw_netstats __percpu *netstats)

> +}
> +EXPORT_SYMBOL(dev_fetch_sw_netstats);

Your pick, but _GPL would be fine too even if most exports here are
non-GPL-exclusive. 

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

* Re: [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
                   ` (11 preceding siblings ...)
  2020-10-11 19:44 ` [PATCH net-next 12/12] xfrm: " Heiner Kallweit
@ 2020-10-11 22:10 ` Jakub Kicinski
  2020-10-11 22:29   ` Heiner Kallweit
  12 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2020-10-11 22:10 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Bjørn Mork, Oliver Neukum, Igor Mitsyanko,
	Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On Sun, 11 Oct 2020 21:34:58 +0200 Heiner Kallweit wrote:
> In several places the same code is used to populate rtnl_link_stats64
> fields with data from pcpu_sw_netstats. Therefore factor out this code
> to a new function dev_fetch_sw_netstats().

FWIW probably fine to convert nfp_repr_get_host_stats64() as well, just
take out the drop counter and make it a separate atomic. If you're up
for that.

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

* Re: [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 22:10 ` [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
@ 2020-10-11 22:29   ` Heiner Kallweit
  2020-10-11 22:41     ` Jakub Kicinski
  0 siblings, 1 reply; 23+ messages in thread
From: Heiner Kallweit @ 2020-10-11 22:29 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David Miller, Bjørn Mork, Oliver Neukum, Igor Mitsyanko,
	Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On 12.10.2020 00:10, Jakub Kicinski wrote:
> On Sun, 11 Oct 2020 21:34:58 +0200 Heiner Kallweit wrote:
>> In several places the same code is used to populate rtnl_link_stats64
>> fields with data from pcpu_sw_netstats. Therefore factor out this code
>> to a new function dev_fetch_sw_netstats().
> 
> FWIW probably fine to convert nfp_repr_get_host_stats64() as well, just
> take out the drop counter and make it a separate atomic. If you're up
> for that.
> 
Looking at nfp_repr_get_host_stats64() I'm not sure why the authors
decided to add a 64bit tx drop counter, struct net_device_stats has
an unsigned long tx_dropped counter already. And that the number of
dropped tx packets exceeds 32bit (on 32bit systems) seems not very
likely.

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

* Re: [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
  2020-10-11 22:29   ` Heiner Kallweit
@ 2020-10-11 22:41     ` Jakub Kicinski
  0 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2020-10-11 22:41 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Bjørn Mork, Oliver Neukum, Igor Mitsyanko,
	Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

On Mon, 12 Oct 2020 00:29:52 +0200 Heiner Kallweit wrote:
> On 12.10.2020 00:10, Jakub Kicinski wrote:
> > On Sun, 11 Oct 2020 21:34:58 +0200 Heiner Kallweit wrote:  
> >> In several places the same code is used to populate rtnl_link_stats64
> >> fields with data from pcpu_sw_netstats. Therefore factor out this code
> >> to a new function dev_fetch_sw_netstats().  
> > 
> > FWIW probably fine to convert nfp_repr_get_host_stats64() as well, just
> > take out the drop counter and make it a separate atomic. If you're up
> > for that.
> >   
> Looking at nfp_repr_get_host_stats64() I'm not sure why the authors
> decided to add a 64bit tx drop counter, struct net_device_stats has
> an unsigned long tx_dropped counter already. And that the number of
> dropped tx packets exceeds 32bit (on 32bit systems) seems not very
> likely.

struct net_device::stats? That's not per-cpu.
Or do you mean struct net_device::tx_dropped? That'd work nicely.

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

* Re: [PATCH net-next 08/12] net: dsa: use new function dev_fetch_sw_netstats
  2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
  2020-10-11 20:15   ` Vladimir Oltean
@ 2020-10-12  1:49   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-10-12  1:49 UTC (permalink / raw)
  To: Heiner Kallweit, David Miller, Jakub Kicinski, Bjørn Mork,
	Oliver Neukum, Igor Mitsyanko, Sergey Matyukevich, Kalle Valo,
	Roopa Prabhu, Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Vladimir Oltean, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Johannes Berg, Pravin B Shelar, Steffen Klassert, Herbert Xu
  Cc: netdev, linux-rdma, Linux USB Mailing List, linux-wireless, bridge



On 10/11/2020 12:41 PM, Heiner Kallweit wrote:
> Simplify the code by using new function dev_fetch_sw_netstats().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH net-next 04/12] net: usb: qmi_wwan: use new function dev_fetch_sw_netstats
  2020-10-11 19:38 ` [PATCH net-next 04/12] net: usb: qmi_wwan: " Heiner Kallweit
@ 2020-10-12  6:47   ` Bjørn Mork
  0 siblings, 0 replies; 23+ messages in thread
From: Bjørn Mork @ 2020-10-12  6:47 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Jakub Kicinski, Oliver Neukum, Igor Mitsyanko,
	Sergey Matyukevich, Kalle Valo, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

Heiner Kallweit <hkallweit1@gmail.com> writes:

> Simplify the code by using new function dev_fetch_sw_netstats().
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Acked-by: Bjørn Mork <bjorn@mork.no>

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

* Re: [PATCH net-next 06/12] qtnfmac: use new function dev_fetch_sw_netstats
  2020-10-11 19:40 ` [PATCH net-next 06/12] qtnfmac: " Heiner Kallweit
@ 2020-10-12  7:10   ` Kalle Valo
  0 siblings, 0 replies; 23+ messages in thread
From: Kalle Valo @ 2020-10-12  7:10 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Jakub Kicinski, Bjørn Mork, Oliver Neukum,
	Igor Mitsyanko, Sergey Matyukevich, Roopa Prabhu,
	Nikolay Aleksandrov, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Johannes Berg, Pravin B Shelar,
	Steffen Klassert, Herbert Xu, netdev, linux-rdma,
	Linux USB Mailing List, linux-wireless, bridge

Heiner Kallweit <hkallweit1@gmail.com> writes:

> Simplify the code by using new function dev_fetch_sw_netstats().
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

I assume this goes via net-next so:

Acked-by: Kalle Valo <kvalo@codeaurora.org>

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

end of thread, other threads:[~2020-10-12  7:11 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
2020-10-11 19:54   ` Stephen Hemminger
2020-10-11 20:18     ` Heiner Kallweit
2020-10-11 22:07   ` Jakub Kicinski
2020-10-11 19:37 ` [PATCH net-next 02/12] IB/hfi1: use new function dev_fetch_sw_netstats Heiner Kallweit
2020-10-11 19:38 ` [PATCH net-next 03/12] net: macsec: " Heiner Kallweit
2020-10-11 19:38 ` [PATCH net-next 04/12] net: usb: qmi_wwan: " Heiner Kallweit
2020-10-12  6:47   ` Bjørn Mork
2020-10-11 19:39 ` [PATCH net-next 05/12] net: usbnet: " Heiner Kallweit
2020-10-11 19:40 ` [PATCH net-next 06/12] qtnfmac: " Heiner Kallweit
2020-10-12  7:10   ` Kalle Valo
2020-10-11 19:40 ` [PATCH net-next 07/12] net: bridge: " Heiner Kallweit
2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
2020-10-11 20:15   ` Vladimir Oltean
2020-10-12  1:49   ` Florian Fainelli
2020-10-11 19:42 ` [PATCH net-next 09/12] iptunnel: " Heiner Kallweit
2020-10-11 19:42 ` [PATCH net-next 10/12] mac80211: " Heiner Kallweit
2020-10-11 19:43 ` [PATCH net-next 11/12] net: openvswitch: " Heiner Kallweit
2020-10-11 19:44 ` [PATCH net-next 12/12] xfrm: " Heiner Kallweit
2020-10-11 22:10 ` [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
2020-10-11 22:29   ` Heiner Kallweit
2020-10-11 22:41     ` Jakub Kicinski

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