Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: loopback: Do not allocate lstats explicitly

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>
Link: https://lore.kernel.org/r/20240429085559.2841918-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Breno Leitao and committed by
Jakub Kicinski
3b5933e9 035ec292

+1 -4
+1 -4
drivers/net/loopback.c
··· 141 141 142 142 static int loopback_dev_init(struct net_device *dev) 143 143 { 144 - dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); 145 - if (!dev->lstats) 146 - return -ENOMEM; 147 144 netdev_lockdep_set_classes(dev); 148 145 return 0; 149 146 } ··· 148 151 static void loopback_dev_free(struct net_device *dev) 149 152 { 150 153 dev_net(dev)->loopback_dev = NULL; 151 - free_percpu(dev->lstats); 152 154 } 153 155 154 156 static const struct net_device_ops loopback_ops = { ··· 187 191 dev->header_ops = hdr_ops; 188 192 dev->netdev_ops = dev_ops; 189 193 dev->needs_free_netdev = true; 194 + dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS; 190 195 dev->priv_destructor = dev_destructor; 191 196 192 197 netif_set_tso_max_size(dev, GSO_MAX_SIZE);