-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: move misc netdev_lock flavors to a separate header
Move the more esoteric helpers for netdev instance lock to a dedicated header. This avoids growing netdevice.h to infinity and makes rebuilding the kernel much faster (after touching the header with the helpers). The main netdev_lock() / netdev_unlock() functions are used in static inlines in netdevice.h and will probably be used most commonly, so keep them in netdevice.h. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250307183006.2312761-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Jakub Kicinski
committed
Mar 8, 2025
1 parent
9bfc9d6
commit 8ef890d
Showing
51 changed files
with
143 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*/ | ||
|
||
#include <linux/ethtool.h> | ||
#include <net/netdev_lock.h> | ||
|
||
#include "ipvlan.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
||
#ifndef _NET_NETDEV_LOCK_H | ||
#define _NET_NETDEV_LOCK_H | ||
|
||
#include <linux/lockdep.h> | ||
#include <linux/netdevice.h> | ||
|
||
static inline bool netdev_trylock(struct net_device *dev) | ||
{ | ||
return mutex_trylock(&dev->lock); | ||
} | ||
|
||
static inline void netdev_assert_locked(struct net_device *dev) | ||
{ | ||
lockdep_assert_held(&dev->lock); | ||
} | ||
|
||
static inline void netdev_assert_locked_or_invisible(struct net_device *dev) | ||
{ | ||
if (dev->reg_state == NETREG_REGISTERED || | ||
dev->reg_state == NETREG_UNREGISTERING) | ||
netdev_assert_locked(dev); | ||
} | ||
|
||
static inline bool netdev_need_ops_lock(struct net_device *dev) | ||
{ | ||
bool ret = dev->request_ops_lock || !!dev->queue_mgmt_ops; | ||
|
||
#if IS_ENABLED(CONFIG_NET_SHAPER) | ||
ret |= !!dev->netdev_ops->net_shaper_ops; | ||
#endif | ||
|
||
return ret; | ||
} | ||
|
||
static inline void netdev_lock_ops(struct net_device *dev) | ||
{ | ||
if (netdev_need_ops_lock(dev)) | ||
netdev_lock(dev); | ||
} | ||
|
||
static inline void netdev_unlock_ops(struct net_device *dev) | ||
{ | ||
if (netdev_need_ops_lock(dev)) | ||
netdev_unlock(dev); | ||
} | ||
|
||
static inline void netdev_ops_assert_locked(struct net_device *dev) | ||
{ | ||
if (netdev_need_ops_lock(dev)) | ||
lockdep_assert_held(&dev->lock); | ||
} | ||
|
||
static inline int netdev_lock_cmp_fn(const struct lockdep_map *a, | ||
const struct lockdep_map *b) | ||
{ | ||
/* Only lower devices currently grab the instance lock, so no | ||
* real ordering issues can occur. In the near future, only | ||
* hardware devices will grab instance lock which also does not | ||
* involve any ordering. Suppress lockdep ordering warnings | ||
* until (if) we start grabbing instance lock on pure SW | ||
* devices (bond/team/veth/etc). | ||
*/ | ||
if (a == b) | ||
return 0; | ||
return -1; | ||
} | ||
|
||
#define netdev_lockdep_set_classes(dev) \ | ||
{ \ | ||
static struct lock_class_key qdisc_tx_busylock_key; \ | ||
static struct lock_class_key qdisc_xmit_lock_key; \ | ||
static struct lock_class_key dev_addr_list_lock_key; \ | ||
static struct lock_class_key dev_instance_lock_key; \ | ||
unsigned int i; \ | ||
\ | ||
(dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key; \ | ||
lockdep_set_class(&(dev)->addr_list_lock, \ | ||
&dev_addr_list_lock_key); \ | ||
lockdep_set_class(&(dev)->lock, \ | ||
&dev_instance_lock_key); \ | ||
lock_set_cmp_fn(&dev->lock, netdev_lock_cmp_fn, NULL); \ | ||
for (i = 0; i < (dev)->num_tx_queues; i++) \ | ||
lockdep_set_class(&(dev)->_tx[i]._xmit_lock, \ | ||
&qdisc_xmit_lock_key); \ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.