diff options
author | Eric Dumazet <edumazet@google.com> | 2024-05-02 19:39:26 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-05-04 00:14:01 +0200 |
commit | c1742dcb6bda5fd535fbaa2145f0a180bc329aa6 (patch) | |
tree | 2552435caf76a6cf8dd78f0d734c953b517ace36 /net/core | |
parent | tools: ynl: add --list-ops and --list-msgs to CLI (diff) | |
download | linux-c1742dcb6bda5fd535fbaa2145f0a180bc329aa6.tar.xz linux-c1742dcb6bda5fd535fbaa2145f0a180bc329aa6.zip |
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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 4 | ||||
-rw-r--r-- | net/core/net-sysfs.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index e02d2363347e..d6b24749eb2e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6531,7 +6531,7 @@ int dev_set_threaded(struct net_device *dev, bool threaded) } } - dev->threaded = threaded; + WRITE_ONCE(dev->threaded, threaded); /* Make sure kthread is created before THREADED bit * is set. @@ -6622,7 +6622,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, * threaded mode will not be enabled in napi_enable(). */ if (dev->threaded && napi_kthread_create(napi)) - dev->threaded = 0; + dev->threaded = false; netif_napi_set_irq(napi, -1); } EXPORT_SYMBOL(netif_napi_add_weight); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 1f7f09e56771..4c27a360c294 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -605,13 +605,13 @@ static ssize_t threaded_show(struct device *dev, struct net_device *netdev = to_net_dev(dev); ssize_t ret = -EINVAL; - if (!rtnl_trylock()) - return restart_syscall(); + rcu_read_lock(); if (dev_isalive(netdev)) - ret = sysfs_emit(buf, fmt_dec, netdev->threaded); + ret = sysfs_emit(buf, fmt_dec, READ_ONCE(netdev->threaded)); + + rcu_read_unlock(); - rtnl_unlock(); return ret; } |