From: Stanislav Fomichev <sdf@fomichev.me>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Saeed Mahameed <saeed@kernel.org>
Subject: [PATCH net-next v8 10/12] net: add option to request netdev instance lock
Date: Wed, 26 Feb 2025 13:11:06 -0800 [thread overview]
Message-ID: <20250226211108.387727-11-sdf@fomichev.me> (raw)
In-Reply-To: <20250226211108.387727-1-sdf@fomichev.me>
Currently only the drivers that implement shaper or queue APIs
are grabbing instance lock. Add an explicit opt-in for the
drivers that want to grab the lock without implementing the above
APIs.
There is a 3-byte hole after @up, use it:
/* --- cacheline 47 boundary (3008 bytes) --- */
u32 napi_defer_hard_irqs; /* 3008 4 */
bool up; /* 3012 1 */
/* XXX 3 bytes hole, try to pack */
struct mutex lock; /* 3016 144 */
/* XXX last struct has 1 hole */
Cc: Saeed Mahameed <saeed@kernel.org>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
include/linux/netdevice.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f487a65f16a7..29f61bd0ddf1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2456,6 +2456,12 @@ struct net_device {
*/
bool up;
+ /**
+ * @request_ops_lock: request the core to run all @netdev_ops and
+ * @ethtool_ops under the @lock.
+ */
+ bool request_ops_lock;
+
/**
* @lock: netdev-scope lock, protects a small selection of fields.
* Should always be taken using netdev_lock() / netdev_unlock() helpers.
@@ -2745,7 +2751,7 @@ static inline void netdev_assert_locked_or_invisible(struct net_device *dev)
static inline bool netdev_need_ops_lock(struct net_device *dev)
{
- bool ret = !!dev->queue_mgmt_ops;
+ bool ret = dev->request_ops_lock || !!dev->queue_mgmt_ops;
#if IS_ENABLED(CONFIG_NET_SHAPER)
ret |= !!dev->netdev_ops->net_shaper_ops;
--
2.48.1
next prev parent reply other threads:[~2025-02-26 21:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 21:10 [PATCH net-next v8 00/12] net: Hold netdev instance lock during ndo operations Stanislav Fomichev
2025-02-26 21:10 ` [PATCH net-next v8 01/12] net: hold netdev instance lock during ndo_open/ndo_stop Stanislav Fomichev
2025-02-26 21:10 ` [PATCH net-next v8 02/12] net: hold netdev instance lock during ndo_setup_tc Stanislav Fomichev
2025-02-26 21:10 ` [PATCH net-next v8 03/12] net: hold netdev instance lock during queue operations Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 04/12] net: hold netdev instance lock during rtnetlink operations Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 05/12] net: hold netdev instance lock during ioctl operations Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 06/12] net: hold netdev instance lock during sysfs operations Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 07/12] net: hold netdev instance lock during ndo_bpf Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 08/12] net: ethtool: try to protect all callback with netdev instance lock Stanislav Fomichev
2025-02-27 8:48 ` Maxime Chevallier
2025-02-27 22:40 ` Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 09/12] net: replace dev_addr_sem " Stanislav Fomichev
2025-02-26 21:11 ` Stanislav Fomichev [this message]
2025-02-26 21:11 ` [PATCH net-next v8 11/12] docs: net: document new locking reality Stanislav Fomichev
2025-02-26 21:11 ` [PATCH net-next v8 12/12] eth: bnxt: remove most dependencies on RTNL Stanislav Fomichev
2025-02-28 1:27 ` [PATCH net-next v8 00/12] net: Hold netdev instance lock during ndo operations Jakub Kicinski
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=20250226211108.387727-11-sdf@fomichev.me \
--to=sdf@fomichev.me \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeed@kernel.org \
/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