Skip to content

Commit 87eba40

Browse files
committed
docs: netdev: break down the instance locking info per ops struct
Explicitly list all the ops structs and what locking they provide. Use "ops locked" as a term for drivers which have ops called under the instance lock. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Reviewed-by: Joe Damato <jdamato@fastly.com> Link: https://patch.msgid.link/20250408195956.412733-8-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 99e44f3 commit 87eba40

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

Documentation/networking/netdevices.rst

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,22 @@ napi->poll:
314314
softirq
315315
will be called with interrupts disabled by netconsole.
316316

317-
struct netdev_queue_mgmt_ops synchronization rules
318-
==================================================
319-
320-
All queue management ndo callbacks are holding netdev instance lock.
321-
322-
RTNL and netdev instance lock
323-
=============================
317+
netdev instance lock
318+
====================
324319

325320
Historically, all networking control operations were protected by a single
326321
global lock known as ``rtnl_lock``. There is an ongoing effort to replace this
327322
global lock with separate locks for each network namespace. Additionally,
328323
properties of individual netdev are increasingly protected by per-netdev locks.
329324

330325
For device drivers that implement shaping or queue management APIs, all control
331-
operations will be performed under the netdev instance lock. Currently, this
332-
instance lock is acquired within the context of ``rtnl_lock``. The drivers
333-
can also explicitly request instance lock to be acquired via
334-
``request_ops_lock``. In the future, there will be an option for individual
326+
operations will be performed under the netdev instance lock.
327+
Drivers can also explicitly request instance lock to be held during ops
328+
by setting ``request_ops_lock`` to true. Code comments and docs refer
329+
to drivers which have ops called under the instance lock as "ops locked".
330+
See also the documentation of the ``lock`` member of struct net_device.
331+
332+
In the future, there will be an option for individual
335333
drivers to opt out of using ``rtnl_lock`` and instead perform their control
336334
operations directly under the netdev instance lock.
337335

@@ -343,8 +341,40 @@ there are two sets of interfaces: ``dev_xxx`` and ``netif_xxx`` (e.g.,
343341
acquiring the instance lock themselves, while the ``netif_xxx`` functions
344342
assume that the driver has already acquired the instance lock.
345343

344+
struct net_device_ops
345+
---------------------
346+
347+
``ndos`` are called without holding the instance lock for most drivers.
348+
349+
"Ops locked" drivers will have most of the ``ndos`` invoked under
350+
the instance lock.
351+
352+
struct ethtool_ops
353+
------------------
354+
355+
Similarly to ``ndos`` the instance lock is only held for select drivers.
356+
For "ops locked" drivers all ethtool ops without exceptions should
357+
be called under the instance lock.
358+
359+
struct net_shaper_ops
360+
---------------------
361+
362+
All net shaper callbacks are invoked while holding the netdev instance
363+
lock. ``rtnl_lock`` may or may not be held.
364+
365+
Note that supporting net shapers automatically enables "ops locking".
366+
367+
struct netdev_queue_mgmt_ops
368+
----------------------------
369+
370+
All queue management callbacks are invoked while holding the netdev instance
371+
lock. ``rtnl_lock`` may or may not be held.
372+
373+
Note that supporting struct netdev_queue_mgmt_ops automatically enables
374+
"ops locking".
375+
346376
Notifiers and netdev instance lock
347-
==================================
377+
----------------------------------
348378

349379
For device drivers that implement shaping or queue management APIs,
350380
some of the notifiers (``enum netdev_cmd``) are running under the netdev

0 commit comments

Comments
 (0)