Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: let lockdep compare instance locks

AFAIU always returning -1 from lockdep's compare function
basically disables checking of dependencies between given
locks. Try to be a little more precise about what guarantees
that instance locks won't deadlock.

Right now we only nest them under protection of rtnl_lock.
Mostly in unregister_netdevice_many() and dev_close_many().

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250517200810.466531-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+7 -8
+7 -8
include/net/netdev_lock.h
··· 99 99 static inline int netdev_lock_cmp_fn(const struct lockdep_map *a, 100 100 const struct lockdep_map *b) 101 101 { 102 - /* Only lower devices currently grab the instance lock, so no 103 - * real ordering issues can occur. In the near future, only 104 - * hardware devices will grab instance lock which also does not 105 - * involve any ordering. Suppress lockdep ordering warnings 106 - * until (if) we start grabbing instance lock on pure SW 107 - * devices (bond/team/veth/etc). 108 - */ 109 102 if (a == b) 110 103 return 0; 111 - return -1; 104 + 105 + /* Allow locking multiple devices only under rtnl_lock, 106 + * the exact order doesn't matter. 107 + * Note that upper devices don't lock their ops, so nesting 108 + * mostly happens in batched device removal for now. 109 + */ 110 + return lockdep_rtnl_is_held() ? -1 : 1; 112 111 } 113 112 114 113 #define netdev_lockdep_set_classes(dev) \