linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] xfrm: Do not allocate stats in the driver
@ 2024-02-22 14:41 Breno Leitao
  2024-02-26 13:47 ` Simon Horman
  2024-02-27 11:54 ` Steffen Klassert
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-02-22 14:41 UTC (permalink / raw)
  To: kuba, davem, pabeni, edumazet, Steffen Klassert, Herbert Xu
  Cc: netdev, linux-kernel, horms

With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
convert veth & vrf"), stats allocation could be done on net core
instead of this driver.

With this new approach, the driver doesn't have to bother with error
handling (allocation failure checking, making sure free happens in the
right spot, etc). This is core responsibility now.

Remove the allocation in the xfrm driver and leverage the network
core allocation.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/xfrm/xfrm_interface_core.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c
index dafefef3cf51..cc19aa7fdc11 100644
--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -240,7 +240,6 @@ static void xfrmi_dev_free(struct net_device *dev)
 	struct xfrm_if *xi = netdev_priv(dev);
 
 	gro_cells_destroy(&xi->gro_cells);
-	free_percpu(dev->tstats);
 }
 
 static int xfrmi_create(struct net_device *dev)
@@ -749,6 +748,7 @@ static void xfrmi_dev_setup(struct net_device *dev)
 	dev->flags 		= IFF_NOARP;
 	dev->needs_free_netdev	= true;
 	dev->priv_destructor	= xfrmi_dev_free;
+	dev->pcpu_stat_type	= NETDEV_PCPU_STAT_TSTATS;
 	netif_keep_dst(dev);
 
 	eth_broadcast_addr(dev->broadcast);
@@ -765,15 +765,9 @@ static int xfrmi_dev_init(struct net_device *dev)
 	struct net_device *phydev = __dev_get_by_index(xi->net, xi->p.link);
 	int err;
 
-	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
-	if (!dev->tstats)
-		return -ENOMEM;
-
 	err = gro_cells_init(&xi->gro_cells, dev);
-	if (err) {
-		free_percpu(dev->tstats);
+	if (err)
 		return err;
-	}
 
 	dev->features |= NETIF_F_LLTX;
 	dev->features |= XFRMI_FEATURES;
-- 
2.39.3


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

* Re: [PATCH net-next] xfrm: Do not allocate stats in the driver
  2024-02-22 14:41 [PATCH net-next] xfrm: Do not allocate stats in the driver Breno Leitao
@ 2024-02-26 13:47 ` Simon Horman
  2024-02-27 11:54 ` Steffen Klassert
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-02-26 13:47 UTC (permalink / raw)
  To: Breno Leitao
  Cc: kuba, davem, pabeni, edumazet, Steffen Klassert, Herbert Xu,
	netdev, linux-kernel

On Thu, Feb 22, 2024 at 06:41:17AM -0800, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> Remove the allocation in the xfrm driver and leverage the network
> core allocation.

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next] xfrm: Do not allocate stats in the driver
  2024-02-22 14:41 [PATCH net-next] xfrm: Do not allocate stats in the driver Breno Leitao
  2024-02-26 13:47 ` Simon Horman
@ 2024-02-27 11:54 ` Steffen Klassert
  1 sibling, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2024-02-27 11:54 UTC (permalink / raw)
  To: Breno Leitao
  Cc: kuba, davem, pabeni, edumazet, Herbert Xu, netdev, linux-kernel, horms

On Thu, Feb 22, 2024 at 06:41:17AM -0800, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> Remove the allocation in the xfrm driver and leverage the network
> core allocation.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Applied to ipsec-next, thanks Breno!

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

end of thread, other threads:[~2024-02-27 11:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 14:41 [PATCH net-next] xfrm: Do not allocate stats in the driver Breno Leitao
2024-02-26 13:47 ` Simon Horman
2024-02-27 11:54 ` Steffen Klassert

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