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: introduce netdev_napi_exit()

After 1b23cdbd2bbc ("net: protect netdev->napi_list with netdev_lock()")
it makes sense to iterate through dev->napi_list while holding
the device lock.

Also call synchronize_net() at most one time.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250117232113.1612899-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
185e5b86 12d5151b

+17 -6
+17 -6
net/core/dev.c
··· 11568 11568 } 11569 11569 EXPORT_SYMBOL(alloc_netdev_mqs); 11570 11570 11571 + static void netdev_napi_exit(struct net_device *dev) 11572 + { 11573 + if (!list_empty(&dev->napi_list)) { 11574 + struct napi_struct *p, *n; 11575 + 11576 + netdev_lock(dev); 11577 + list_for_each_entry_safe(p, n, &dev->napi_list, dev_list) 11578 + __netif_napi_del_locked(p); 11579 + netdev_unlock(dev); 11580 + 11581 + synchronize_net(); 11582 + } 11583 + 11584 + kvfree(dev->napi_config); 11585 + } 11586 + 11571 11587 /** 11572 11588 * free_netdev - free network device 11573 11589 * @dev: device ··· 11595 11579 */ 11596 11580 void free_netdev(struct net_device *dev) 11597 11581 { 11598 - struct napi_struct *p, *n; 11599 - 11600 11582 might_sleep(); 11601 11583 11602 11584 /* When called immediately after register_netdevice() failed the unwind ··· 11616 11602 /* Flush device addresses */ 11617 11603 dev_addr_flush(dev); 11618 11604 11619 - list_for_each_entry_safe(p, n, &dev->napi_list, dev_list) 11620 - netif_napi_del(p); 11621 - 11622 - kvfree(dev->napi_config); 11605 + netdev_napi_exit(dev); 11623 11606 11624 11607 ref_tracker_dir_exit(&dev->refcnt_tracker); 11625 11608 #ifdef CONFIG_PCPU_DEV_REFCNT