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: no longer acquire RTNL in threaded_show()

dev->threaded can be read locklessly, if we add
corresponding READ_ONCE()/WRITE_ONCE() annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240502173926.2010646-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
c1742dcb 3e51f2cb

+7 -7
+1 -1
include/linux/netdevice.h
··· 2370 2370 struct sfp_bus *sfp_bus; 2371 2371 struct lock_class_key *qdisc_tx_busylock; 2372 2372 bool proto_down; 2373 + bool threaded; 2373 2374 unsigned wol_enabled:1; 2374 - unsigned threaded:1; 2375 2375 2376 2376 struct list_head net_notifier_list; 2377 2377
+2 -2
net/core/dev.c
··· 6531 6531 } 6532 6532 } 6533 6533 6534 - dev->threaded = threaded; 6534 + WRITE_ONCE(dev->threaded, threaded); 6535 6535 6536 6536 /* Make sure kthread is created before THREADED bit 6537 6537 * is set. ··· 6622 6622 * threaded mode will not be enabled in napi_enable(). 6623 6623 */ 6624 6624 if (dev->threaded && napi_kthread_create(napi)) 6625 - dev->threaded = 0; 6625 + dev->threaded = false; 6626 6626 netif_napi_set_irq(napi, -1); 6627 6627 } 6628 6628 EXPORT_SYMBOL(netif_napi_add_weight);
+4 -4
net/core/net-sysfs.c
··· 605 605 struct net_device *netdev = to_net_dev(dev); 606 606 ssize_t ret = -EINVAL; 607 607 608 - if (!rtnl_trylock()) 609 - return restart_syscall(); 608 + rcu_read_lock(); 610 609 611 610 if (dev_isalive(netdev)) 612 - ret = sysfs_emit(buf, fmt_dec, netdev->threaded); 611 + ret = sysfs_emit(buf, fmt_dec, READ_ONCE(netdev->threaded)); 613 612 614 - rtnl_unlock(); 613 + rcu_read_unlock(); 614 + 615 615 return ret; 616 616 } 617 617