Re: [PATCH net-next 3/8] netdev: add "ops compat locking" helpers

Joe Damato
2025-04-08T02:41:22Z

On Mon, Apr 07, 2025 at 12:01:12PM -0700, Jakub Kicinski wrote:
> Add helpers to "lock a netdev in a backward-compatible way",
> which for ops-locked netdevs will mean take the instance lock.
> For drivers which haven't opted into the ops locking we'll take
> rtnl_lock.
>
> The scoped foreach is dropping and re-taking the lock for each
> device, even if prev and next are both under rtnl_lock.
> I hope that's fine since we expect that netdev nl to be mostly
> supported by modern drivers, and modern drivers should also
> opt into the instance locking.
>
> Note that these helpers are mostly needed for queue related state,
> because drivers modify queue config in their ops in a non-atomic
> way. Or differently put, queue changes don't have a clear-cut API
> like NAPI configuration. Any state that can should just use the
> instance lock directly, not the "compat" hacks.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> include/net/netdev_lock.h | 16 ++++++++++++
> net/core/dev.h | 15 ++++++++++++
> net/core/dev.c | 51 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 82 insertions(+)
>

Reviewed-by: Joe Damato <jdamato@fastly.com>