mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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>
This commit is contained in:
@@ -90,6 +90,7 @@
|
||||
#include <net/tls.h>
|
||||
#endif
|
||||
#include <net/ip6_route.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/xdp.h>
|
||||
|
||||
#include "bonding_priv.h"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/rtnetlink.h>
|
||||
#include <linux/u64_stats_sync.h>
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <net/pkt_cls.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
#include <linux/align.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/netdev_queues.h>
|
||||
#include <net/netdev_rx_queue.h>
|
||||
#include <linux/pci-tph.h>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/bpf.h>
|
||||
#include <linux/bpf_trace.h>
|
||||
#include <linux/filter.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
#include "bnxt_hsi.h"
|
||||
#include "bnxt.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/* Copyright(c) 2013 - 2018 Intel Corporation. */
|
||||
|
||||
#include <linux/net/intel/libie/rx.h>
|
||||
#include <net/netdev_lock.h>
|
||||
|
||||
#include "iavf.h"
|
||||
#include "iavf_ptp.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <net/checksum.h>
|
||||
#include <net/ip6_checksum.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
#include <net/xdp.h>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <net/rtnetlink.h>
|
||||
#include <net/geneve.h>
|
||||
#include <net/gro.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/protocol.h>
|
||||
|
||||
#define GENEVE_NETDEV_VER "0.6"
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
|
||||
#include <net/ip.h>
|
||||
#include <net/arp.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include <linux/bpqether.h>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <linux/bpf.h>
|
||||
|
||||
#include <net/arp.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/route.h>
|
||||
#include <net/sock.h>
|
||||
#include <net/pkt_sched.h>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
#include <net/netdev_lock.h>
|
||||
|
||||
#include "ipvlan.h"
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <linux/u64_stats_sync.h>
|
||||
|
||||
/* blackhole_netdev - a device used for dsts that are marked expired!
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <net/gro_cells.h>
|
||||
#include <net/macsec.h>
|
||||
#include <net/dst_metadata.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/byteorder/generic.h>
|
||||
#include <linux/if_arp.h>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <linux/if_macvlan.h>
|
||||
#include <linux/hash.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/rtnetlink.h>
|
||||
#include <net/xfrm.h>
|
||||
#include <linux/netpoll.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <net/page_pool/helpers.h>
|
||||
#include <net/netlink.h>
|
||||
#include <net/net_shaper.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/pkt_cls.h>
|
||||
#include <net/rtnetlink.h>
|
||||
#include <net/udp_tunnel.h>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/slhc_vj.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/refcount.h>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <net/rtnetlink.h>
|
||||
#include <net/genetlink.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/netlink.h>
|
||||
#include <net/sch_generic.h>
|
||||
#include <linux/if_team.h>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <net/rtnetlink.h>
|
||||
#include <net/dst.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/xfrm.h>
|
||||
#include <net/xdp.h>
|
||||
#include <linux/veth.h>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <net/addrconf.h>
|
||||
#include <net/l3mdev.h>
|
||||
#include <net/fib_rules.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/sch_generic.h>
|
||||
#include <net/netns/generic.h>
|
||||
#include <net/netfilter/nf_conntrack.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <net/inet_ecn.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/netns/generic.h>
|
||||
#include <net/netdev_lock.h>
|
||||
#include <net/tun_proto.h>
|
||||
#include <net/vxlan.h>
|
||||
#include <net/nexthop.h>
|
||||
|
||||
@@ -2630,40 +2630,6 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
|
||||
f(dev, &dev->_tx[i], arg);
|
||||
}
|
||||
|
||||
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); \
|
||||
}
|
||||
|
||||
u16 netdev_pick_tx(struct net_device *dev, struct sk_buff *skb,
|
||||
struct net_device *sb_dev);
|
||||
struct netdev_queue *netdev_core_pick_tx(struct net_device *dev,
|
||||
@@ -2765,56 +2731,11 @@ static inline void netdev_lock(struct net_device *dev)
|
||||
mutex_lock(&dev->lock);
|
||||
}
|
||||
|
||||
static inline bool netdev_trylock(struct net_device *dev)
|
||||
{
|
||||
return mutex_trylock(&dev->lock);
|
||||
}
|
||||
|
||||
static inline void netdev_unlock(struct net_device *dev)
|
||||
{
|
||||
mutex_unlock(&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);
|
||||
}
|
||||
/* Additional netdev_lock()-related helpers are in net/netdev_lock.h */
|
||||
|
||||
void netif_napi_set_irq_locked(struct napi_struct *napi, int irq);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user