All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] net: xfrm: use core API for updating TX stats
@ 2020-11-12 11:13 Lev Stipakov
  2020-11-13  7:46 ` Heiner Kallweit
  0 siblings, 1 reply; 6+ messages in thread
From: Lev Stipakov @ 2020-11-12 11:13 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller, Jakub Kicinski,
	netdev, linux-kernel
  Cc: Lev Stipakov

Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
stats.

Use this function instead of own code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 net/xfrm/xfrm_interface.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 9b8e292a7c6a..43ee4c5a6fa9 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 
 	err = dst_output(xi->net, skb->sk, skb);
 	if (net_xmit_eval(err) == 0) {
-		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
-
-		u64_stats_update_begin(&tstats->syncp);
-		tstats->tx_bytes += length;
-		tstats->tx_packets++;
-		u64_stats_update_end(&tstats->syncp);
+		dev_sw_netstats_tx_add(dev, 1, length);
 	} else {
 		stats->tx_errors++;
 		stats->tx_aborted_errors++;
-- 
2.25.1


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

* Re: [PATCH 3/3] net: xfrm: use core API for updating TX stats
  2020-11-12 11:13 [PATCH 3/3] net: xfrm: use core API for updating TX stats Lev Stipakov
@ 2020-11-13  7:46 ` Heiner Kallweit
  2020-11-13  9:07   ` [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats Lev Stipakov
  0 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2020-11-13  7:46 UTC (permalink / raw)
  To: Lev Stipakov, Steffen Klassert, Herbert Xu, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel
  Cc: Lev Stipakov

Am 12.11.2020 um 12:13 schrieb Lev Stipakov:
> Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
> function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
> stats.
> 
> Use this function instead of own code.
> 
LGTM. In addition you can replace xfrmi_get_stats64() with
dev_get_tstats64().

> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> ---
>  net/xfrm/xfrm_interface.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
> index 9b8e292a7c6a..43ee4c5a6fa9 100644
> --- a/net/xfrm/xfrm_interface.c
> +++ b/net/xfrm/xfrm_interface.c
> @@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
>  
>  	err = dst_output(xi->net, skb->sk, skb);
>  	if (net_xmit_eval(err) == 0) {
> -		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
> -
> -		u64_stats_update_begin(&tstats->syncp);
> -		tstats->tx_bytes += length;
> -		tstats->tx_packets++;
> -		u64_stats_update_end(&tstats->syncp);
> +		dev_sw_netstats_tx_add(dev, 1, length);
>  	} else {
>  		stats->tx_errors++;
>  		stats->tx_aborted_errors++;
> 


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

* [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats
  2020-11-13  7:46 ` Heiner Kallweit
@ 2020-11-13  9:07   ` Lev Stipakov
  2020-11-13 10:46     ` Heiner Kallweit
  0 siblings, 1 reply; 6+ messages in thread
From: Lev Stipakov @ 2020-11-13  9:07 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller, Jakub Kicinski,
	netdev, linux-kernel, Heiner Kallweit
  Cc: Lev Stipakov

Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
stats.

Use this function instead of own code.

While on it, remove xfrmi_get_stats64() and replace it with
dev_get_tstats64().

Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 
 v2: replace xfrmi_get_stats64() vs dev_get_tstats64()

 net/xfrm/xfrm_interface.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 9b8e292a7c6a..697cdcfbb5e1 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 
 	err = dst_output(xi->net, skb->sk, skb);
 	if (net_xmit_eval(err) == 0) {
-		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
-
-		u64_stats_update_begin(&tstats->syncp);
-		tstats->tx_bytes += length;
-		tstats->tx_packets++;
-		u64_stats_update_end(&tstats->syncp);
+		dev_sw_netstats_tx_add(dev, 1, length);
 	} else {
 		stats->tx_errors++;
 		stats->tx_aborted_errors++;
@@ -538,15 +533,6 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p)
 	return err;
 }
 
-static void xfrmi_get_stats64(struct net_device *dev,
-			       struct rtnl_link_stats64 *s)
-{
-	dev_fetch_sw_netstats(s, dev->tstats);
-
-	s->rx_dropped = dev->stats.rx_dropped;
-	s->tx_dropped = dev->stats.tx_dropped;
-}
-
 static int xfrmi_get_iflink(const struct net_device *dev)
 {
 	struct xfrm_if *xi = netdev_priv(dev);
@@ -554,12 +540,11 @@ static int xfrmi_get_iflink(const struct net_device *dev)
 	return xi->p.link;
 }
 
-
 static const struct net_device_ops xfrmi_netdev_ops = {
 	.ndo_init	= xfrmi_dev_init,
 	.ndo_uninit	= xfrmi_dev_uninit,
 	.ndo_start_xmit = xfrmi_xmit,
-	.ndo_get_stats64 = xfrmi_get_stats64,
+	.ndo_get_stats64 = dev_get_tstats64,
 	.ndo_get_iflink = xfrmi_get_iflink,
 };
 
-- 
2.25.1


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

* Re: [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats
  2020-11-13  9:07   ` [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats Lev Stipakov
@ 2020-11-13 10:46     ` Heiner Kallweit
  2020-11-13 21:59       ` [PATCH v3] " Lev Stipakov
  0 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2020-11-13 10:46 UTC (permalink / raw)
  To: Lev Stipakov, Steffen Klassert, Herbert Xu, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel
  Cc: Lev Stipakov

Am 13.11.2020 um 10:07 schrieb Lev Stipakov:
> Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
> function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
> stats.
> 
> Use this function instead of own code.
> 
> While on it, remove xfrmi_get_stats64() and replace it with
> dev_get_tstats64().
> 
> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> ---
>  
Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>

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

* [PATCH v3] net: xfrm: use core API for updating/providing stats
  2020-11-13 10:46     ` Heiner Kallweit
@ 2020-11-13 21:59       ` Lev Stipakov
  2020-11-15  1:03         ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Lev Stipakov @ 2020-11-13 21:59 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller, Jakub Kicinski,
	netdev, linux-kernel, Heiner Kallweit
  Cc: Lev Stipakov

Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
stats.

Use this function instead of own code.

While on it, remove xfrmi_get_stats64() and replace it with
dev_get_tstats64().

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 v3: no code changes, just send separate patch instead of series as
requested
 v2: replace xfrmi_get_stats64() vs dev_get_tstats64()

 net/xfrm/xfrm_interface.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 9b8e292a7c6a..697cdcfbb5e1 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 
 	err = dst_output(xi->net, skb->sk, skb);
 	if (net_xmit_eval(err) == 0) {
-		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
-
-		u64_stats_update_begin(&tstats->syncp);
-		tstats->tx_bytes += length;
-		tstats->tx_packets++;
-		u64_stats_update_end(&tstats->syncp);
+		dev_sw_netstats_tx_add(dev, 1, length);
 	} else {
 		stats->tx_errors++;
 		stats->tx_aborted_errors++;
@@ -538,15 +533,6 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p)
 	return err;
 }
 
-static void xfrmi_get_stats64(struct net_device *dev,
-			       struct rtnl_link_stats64 *s)
-{
-	dev_fetch_sw_netstats(s, dev->tstats);
-
-	s->rx_dropped = dev->stats.rx_dropped;
-	s->tx_dropped = dev->stats.tx_dropped;
-}
-
 static int xfrmi_get_iflink(const struct net_device *dev)
 {
 	struct xfrm_if *xi = netdev_priv(dev);
@@ -554,12 +540,11 @@ static int xfrmi_get_iflink(const struct net_device *dev)
 	return xi->p.link;
 }
 
-
 static const struct net_device_ops xfrmi_netdev_ops = {
 	.ndo_init	= xfrmi_dev_init,
 	.ndo_uninit	= xfrmi_dev_uninit,
 	.ndo_start_xmit = xfrmi_xmit,
-	.ndo_get_stats64 = xfrmi_get_stats64,
+	.ndo_get_stats64 = dev_get_tstats64,
 	.ndo_get_iflink = xfrmi_get_iflink,
 };
 
-- 
2.25.1


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

* Re: [PATCH v3] net: xfrm: use core API for updating/providing stats
  2020-11-13 21:59       ` [PATCH v3] " Lev Stipakov
@ 2020-11-15  1:03         ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2020-11-15  1:03 UTC (permalink / raw)
  To: Lev Stipakov
  Cc: Steffen Klassert, Herbert Xu, David S. Miller, netdev,
	linux-kernel, Heiner Kallweit, Lev Stipakov

On Fri, 13 Nov 2020 23:59:40 +0200 Lev Stipakov wrote:
> Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
> function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
> stats.
> 
> Use this function instead of own code.
> 
> While on it, remove xfrmi_get_stats64() and replace it with
> dev_get_tstats64().
> 
> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>

Since this is a follow up to Heiner's work I'll apply directly as well.

Thanks!

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

end of thread, other threads:[~2020-11-15  1:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 11:13 [PATCH 3/3] net: xfrm: use core API for updating TX stats Lev Stipakov
2020-11-13  7:46 ` Heiner Kallweit
2020-11-13  9:07   ` [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats Lev Stipakov
2020-11-13 10:46     ` Heiner Kallweit
2020-11-13 21:59       ` [PATCH v3] " Lev Stipakov
2020-11-15  1:03         ` Jakub Kicinski

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.