LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: loopback: Do not allocate tstats explicitly
@ 2024-04-29  8:55 Breno Leitao
  2024-04-29 13:47 ` Sabrina Dubroca
  0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2024-04-29  8:55 UTC (permalink / raw
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: leit, open list:NETWORKING DRIVERS, open list

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 in 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 loopback driver and leverage the network
core allocation instead.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/loopback.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index f6eab66c2660..2b486e7c749c 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -141,9 +141,6 @@ static const struct ethtool_ops loopback_ethtool_ops = {
 
 static int loopback_dev_init(struct net_device *dev)
 {
-	dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
-	if (!dev->lstats)
-		return -ENOMEM;
 	netdev_lockdep_set_classes(dev);
 	return 0;
 }
@@ -151,7 +148,6 @@ static int loopback_dev_init(struct net_device *dev)
 static void loopback_dev_free(struct net_device *dev)
 {
 	dev_net(dev)->loopback_dev = NULL;
-	free_percpu(dev->lstats);
 }
 
 static const struct net_device_ops loopback_ops = {
@@ -191,6 +187,7 @@ static void gen_lo_setup(struct net_device *dev,
 	dev->header_ops		= hdr_ops;
 	dev->netdev_ops		= dev_ops;
 	dev->needs_free_netdev	= true;
+	dev->pcpu_stat_type	= NETDEV_PCPU_STAT_LSTATS;
 	dev->priv_destructor	= dev_destructor;
 
 	netif_set_tso_max_size(dev, GSO_MAX_SIZE);
-- 
2.43.0


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

* Re: [PATCH net-next] net: loopback: Do not allocate tstats explicitly
  2024-04-29  8:55 [PATCH net-next] net: loopback: Do not allocate tstats explicitly Breno Leitao
@ 2024-04-29 13:47 ` Sabrina Dubroca
  2024-05-01  2:03   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Sabrina Dubroca @ 2024-04-29 13:47 UTC (permalink / raw
  To: Breno Leitao
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, leit,
	open list:NETWORKING DRIVERS, open list

(nit on the subject: you mention "tstats", but the code actually uses
lstats. I guess that's not worth a v2)

2024-04-29, 01:55:58 -0700, 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 in 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 loopback driver and leverage the network
> core allocation instead.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>

-- 
Sabrina


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

* Re: [PATCH net-next] net: loopback: Do not allocate tstats explicitly
  2024-04-29 13:47 ` Sabrina Dubroca
@ 2024-05-01  2:03   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-05-01  2:03 UTC (permalink / raw
  To: Sabrina Dubroca
  Cc: Breno Leitao, David S. Miller, Eric Dumazet, Paolo Abeni, leit,
	open list:NETWORKING DRIVERS, open list

On Mon, 29 Apr 2024 15:47:05 +0200 Sabrina Dubroca wrote:
> (nit on the subject: you mention "tstats", but the code actually uses
> lstats. I guess that's not worth a v2)

Good catch, corrected when applying - 3b5933e99c32 ("net: loopback: Do
not allocate lstats explicitly") in net-next.
-- 
pw-bot: accept

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

end of thread, other threads:[~2024-05-01  2:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29  8:55 [PATCH net-next] net: loopback: Do not allocate tstats explicitly Breno Leitao
2024-04-29 13:47 ` Sabrina Dubroca
2024-05-01  2:03   ` 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 read-only IMAP folder(s) and NNTP newsgroup(s).