From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
Jakub Kicinski <kuba@kernel.org>,
andrew@lunn.ch, maxime.chevallier@bootlin.com
Subject: [PATCH net-next] net: ethtool: don't take rtnl_lock for global string dump
Date: Wed, 27 May 2026 09:25:22 -0700 [thread overview]
Message-ID: <20260527162522.3344231-1-kuba@kernel.org> (raw)
ETHTOOL_MSG_STRSET_GET is the only op which sets allow_nodev_do.
When no device is provided it dumps static tables, there's no
need to hold rtnl_lock for this.
Not taking rtnl_lock is a minor win in itself so I think this
patch stands on its own merits. Later on it will be useful
to do locking only in paths which have access to a netdev,
so that we can decide which locks to take per-netdev.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: maxime.chevallier@bootlin.com
---
net/ethtool/netlink.h | 4 +++-
net/ethtool/netlink.c | 10 ++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index aaf6f2468768..b31de00fe683 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -333,7 +333,9 @@ int ethnl_sock_priv_set(struct sk_buff *skb, struct net_device *dev, u32 portid,
* @hdr_attr: attribute type for request header
* @req_info_size: size of request info
* @reply_data_size: size of reply data
- * @allow_nodev_do: allow non-dump request with no device identification
+ * @allow_nodev_do:
+ * Allow non-dump request with no device identification.
+ * Note that locks (rtnl_lock etc.) are only taken if device is set.
* @set_ntf_cmd: notification to generate on changes (SET)
* @parse_request:
* Parse request except common header (struct ethnl_req_info). Common
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 5046023a30b1..a42bdd5ded51 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -526,13 +526,15 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
goto err_free;
ethnl_init_reply_data(reply_data, ops, req_info->dev);
- rtnl_lock();
- if (req_info->dev)
+ if (req_info->dev) {
+ rtnl_lock();
netdev_lock_ops(req_info->dev);
+ }
ret = ops->prepare_data(req_info, reply_data, info);
- if (req_info->dev)
+ if (req_info->dev) {
netdev_unlock_ops(req_info->dev);
- rtnl_unlock();
+ rtnl_unlock();
+ }
if (ret < 0)
goto err_dev;
ret = ops->reply_size(req_info, reply_data);
--
2.54.0
next reply other threads:[~2026-05-27 16:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 16:25 Jakub Kicinski [this message]
2026-05-27 16:40 ` [PATCH net-next] net: ethtool: don't take rtnl_lock for global string dump Vadim Fedorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260527162522.3344231-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox