Skip to content

Commit 1a33e10

Browse files
congwangdavem330
authored andcommitted
net: partially revert dynamic lockdep key changes
This patch reverts the folowing commits: commit 064ff66 "bonding: add missing netdev_update_lockdep_key()" commit 53d3749 "net: avoid updating qdisc_xmit_lock_key in netdev_update_lockdep_key()" commit 1f26c0d "net: fix kernel-doc warning in <linux/netdevice.h>" commit ab92d68 "net: core: add generic lockdep keys" but keeps the addr_list_lock_key because we still lock addr_list_lock nestedly on stack devices, unlikely xmit_lock this is safe because we don't take addr_list_lock on any fast path. Reported-and-tested-by: [email protected] Cc: Dmitry Vyukov <[email protected]> Cc: Taehee Yoo <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Taehee Yoo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ea84c84 commit 1a33e10

File tree

22 files changed

+294
-33
lines changed

22 files changed

+294
-33
lines changed

drivers/net/bonding/bond_main.c

+1
Original file line numberDiff line numberDiff line change
@@ -4898,6 +4898,7 @@ static int bond_init(struct net_device *bond_dev)
48984898
spin_lock_init(&bond->stats_lock);
48994899
lockdep_register_key(&bond->stats_lock_key);
49004900
lockdep_set_class(&bond->stats_lock, &bond->stats_lock_key);
4901+
netdev_lockdep_set_classes(bond_dev);
49014902

49024903
list_add_tail(&bond->bond_list, &bn->dev_list);
49034904

drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

+16
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ static void nfp_repr_clean(struct nfp_repr *repr)
299299
nfp_port_free(repr->port);
300300
}
301301

302+
static struct lock_class_key nfp_repr_netdev_xmit_lock_key;
303+
304+
static void nfp_repr_set_lockdep_class_one(struct net_device *dev,
305+
struct netdev_queue *txq,
306+
void *_unused)
307+
{
308+
lockdep_set_class(&txq->_xmit_lock, &nfp_repr_netdev_xmit_lock_key);
309+
}
310+
311+
static void nfp_repr_set_lockdep_class(struct net_device *dev)
312+
{
313+
netdev_for_each_tx_queue(dev, nfp_repr_set_lockdep_class_one, NULL);
314+
}
315+
302316
int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
303317
u32 cmsg_port_id, struct nfp_port *port,
304318
struct net_device *pf_netdev)
@@ -308,6 +322,8 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
308322
u32 repr_cap = nn->tlv_caps.repr_cap;
309323
int err;
310324

325+
nfp_repr_set_lockdep_class(netdev);
326+
311327
repr->port = port;
312328
repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL);
313329
if (!repr->dst)

drivers/net/hamradio/bpqether.c

+20
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ struct bpqdev {
107107

108108
static LIST_HEAD(bpq_devices);
109109

110+
/*
111+
* bpqether network devices are paired with ethernet devices below them, so
112+
* form a special "super class" of normal ethernet devices; split their locks
113+
* off into a separate class since they always nest.
114+
*/
115+
static struct lock_class_key bpq_netdev_xmit_lock_key;
116+
117+
static void bpq_set_lockdep_class_one(struct net_device *dev,
118+
struct netdev_queue *txq,
119+
void *_unused)
120+
{
121+
lockdep_set_class(&txq->_xmit_lock, &bpq_netdev_xmit_lock_key);
122+
}
123+
124+
static void bpq_set_lockdep_class(struct net_device *dev)
125+
{
126+
netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL);
127+
}
128+
110129
/* ------------------------------------------------------------------------ */
111130

112131

@@ -477,6 +496,7 @@ static int bpq_new_device(struct net_device *edev)
477496
err = register_netdevice(ndev);
478497
if (err)
479498
goto error;
499+
bpq_set_lockdep_class(ndev);
480500

481501
/* List protected by RTNL */
482502
list_add_rcu(&bpq->bpq_list, &bpq_devices);

drivers/net/hyperv/netvsc_drv.c

+2
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,8 @@ static int netvsc_probe(struct hv_device *dev,
24562456
NETIF_F_HW_VLAN_CTAG_RX;
24572457
net->vlan_features = net->features;
24582458

2459+
netdev_lockdep_set_classes(net);
2460+
24592461
/* MTU range: 68 - 1500 or 65521 */
24602462
net->min_mtu = NETVSC_MTU_MIN;
24612463
if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)

drivers/net/ipvlan/ipvlan_main.c

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ static int ipvlan_init(struct net_device *dev)
131131
dev->gso_max_segs = phy_dev->gso_max_segs;
132132
dev->hard_header_len = phy_dev->hard_header_len;
133133

134+
netdev_lockdep_set_classes(dev);
135+
134136
ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats);
135137
if (!ipvlan->pcpu_stats)
136138
return -ENOMEM;

drivers/net/macsec.c

+2
Original file line numberDiff line numberDiff line change
@@ -4047,6 +4047,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
40474047
if (err < 0)
40484048
return err;
40494049

4050+
netdev_lockdep_set_classes(dev);
4051+
40504052
err = netdev_upper_dev_link(real_dev, dev, extack);
40514053
if (err < 0)
40524054
goto unregister;

drivers/net/macvlan.c

+2
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ static int macvlan_init(struct net_device *dev)
890890
dev->gso_max_segs = lowerdev->gso_max_segs;
891891
dev->hard_header_len = lowerdev->hard_header_len;
892892

893+
netdev_lockdep_set_classes(dev);
894+
893895
vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
894896
if (!vlan->pcpu_stats)
895897
return -ENOMEM;

drivers/net/ppp/ppp_generic.c

+2
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,8 @@ static int ppp_dev_init(struct net_device *dev)
14101410
{
14111411
struct ppp *ppp;
14121412

1413+
netdev_lockdep_set_classes(dev);
1414+
14131415
ppp = netdev_priv(dev);
14141416
/* Let the netdevice take a reference on the ppp file. This ensures
14151417
* that ppp_destroy_interface() won't run before the device gets

drivers/net/team/team.c

+1
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ static int team_init(struct net_device *dev)
16471647

16481648
lockdep_register_key(&team->team_lock_key);
16491649
__mutex_init(&team->lock, "team->team_lock_key", &team->team_lock_key);
1650+
netdev_lockdep_set_classes(dev);
16501651

16511652
return 0;
16521653

drivers/net/vrf.c

+1
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ static int vrf_dev_init(struct net_device *dev)
867867

868868
/* similarly, oper state is irrelevant; set to up to avoid confusion */
869869
dev->operstate = IF_OPER_UP;
870+
netdev_lockdep_set_classes(dev);
870871
return 0;
871872

872873
out_rth:

drivers/net/wireless/intersil/hostap/hostap_hw.c

+22
Original file line numberDiff line numberDiff line change
@@ -3041,6 +3041,27 @@ static void prism2_clear_set_tim_queue(local_info_t *local)
30413041
}
30423042
}
30433043

3044+
3045+
/*
3046+
* HostAP uses two layers of net devices, where the inner
3047+
* layer gets called all the time from the outer layer.
3048+
* This is a natural nesting, which needs a split lock type.
3049+
*/
3050+
static struct lock_class_key hostap_netdev_xmit_lock_key;
3051+
3052+
static void prism2_set_lockdep_class_one(struct net_device *dev,
3053+
struct netdev_queue *txq,
3054+
void *_unused)
3055+
{
3056+
lockdep_set_class(&txq->_xmit_lock,
3057+
&hostap_netdev_xmit_lock_key);
3058+
}
3059+
3060+
static void prism2_set_lockdep_class(struct net_device *dev)
3061+
{
3062+
netdev_for_each_tx_queue(dev, prism2_set_lockdep_class_one, NULL);
3063+
}
3064+
30443065
static struct net_device *
30453066
prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
30463067
struct device *sdev)
@@ -3199,6 +3220,7 @@ while (0)
31993220
if (ret >= 0)
32003221
ret = register_netdevice(dev);
32013222

3223+
prism2_set_lockdep_class(dev);
32023224
rtnl_unlock();
32033225
if (ret < 0) {
32043226
printk(KERN_WARNING "%s: register netdevice failed!\n",

include/linux/netdevice.h

+19-8
Original file line numberDiff line numberDiff line change
@@ -1805,13 +1805,11 @@ enum netdev_priv_flags {
18051805
* @phydev: Physical device may attach itself
18061806
* for hardware timestamping
18071807
* @sfp_bus: attached &struct sfp_bus structure.
1808-
* @qdisc_tx_busylock_key: lockdep class annotating Qdisc->busylock
1809-
* spinlock
1810-
* @qdisc_running_key: lockdep class annotating Qdisc->running seqcount
1811-
* @qdisc_xmit_lock_key: lockdep class annotating
1812-
* netdev_queue->_xmit_lock spinlock
1808+
*
18131809
* @addr_list_lock_key: lockdep class annotating
18141810
* net_device->addr_list_lock spinlock
1811+
* @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock
1812+
* @qdisc_running_key: lockdep class annotating Qdisc->running seqcount
18151813
*
18161814
* @proto_down: protocol port state information can be sent to the
18171815
* switch driver and used to set the phys state of the
@@ -2112,10 +2110,9 @@ struct net_device {
21122110
#endif
21132111
struct phy_device *phydev;
21142112
struct sfp_bus *sfp_bus;
2115-
struct lock_class_key qdisc_tx_busylock_key;
2116-
struct lock_class_key qdisc_running_key;
2117-
struct lock_class_key qdisc_xmit_lock_key;
21182113
struct lock_class_key addr_list_lock_key;
2114+
struct lock_class_key *qdisc_tx_busylock;
2115+
struct lock_class_key *qdisc_running_key;
21192116
bool proto_down;
21202117
unsigned wol_enabled:1;
21212118

@@ -2200,6 +2197,20 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
22002197
f(dev, &dev->_tx[i], arg);
22012198
}
22022199

2200+
#define netdev_lockdep_set_classes(dev) \
2201+
{ \
2202+
static struct lock_class_key qdisc_tx_busylock_key; \
2203+
static struct lock_class_key qdisc_running_key; \
2204+
static struct lock_class_key qdisc_xmit_lock_key; \
2205+
unsigned int i; \
2206+
\
2207+
(dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key; \
2208+
(dev)->qdisc_running_key = &qdisc_running_key; \
2209+
for (i = 0; i < (dev)->num_tx_queues; i++) \
2210+
lockdep_set_class(&(dev)->_tx[i]._xmit_lock, \
2211+
&qdisc_xmit_lock_key); \
2212+
}
2213+
22032214
u16 netdev_pick_tx(struct net_device *dev, struct sk_buff *skb,
22042215
struct net_device *sb_dev);
22052216
struct netdev_queue *netdev_core_pick_tx(struct net_device *dev,

net/8021q/vlan_dev.c

+21
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,25 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev)
489489
dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev);
490490
}
491491

492+
/*
493+
* vlan network devices have devices nesting below it, and are a special
494+
* "super class" of normal network devices; split their locks off into a
495+
* separate class since they always nest.
496+
*/
497+
static struct lock_class_key vlan_netdev_xmit_lock_key;
498+
499+
static void vlan_dev_set_lockdep_one(struct net_device *dev,
500+
struct netdev_queue *txq,
501+
void *unused)
502+
{
503+
lockdep_set_class(&txq->_xmit_lock, &vlan_netdev_xmit_lock_key);
504+
}
505+
506+
static void vlan_dev_set_lockdep_class(struct net_device *dev)
507+
{
508+
netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL);
509+
}
510+
492511
static const struct header_ops vlan_header_ops = {
493512
.create = vlan_dev_hard_header,
494513
.parse = eth_header_parse,
@@ -579,6 +598,8 @@ static int vlan_dev_init(struct net_device *dev)
579598

580599
SET_NETDEV_DEVTYPE(dev, &vlan_type);
581600

601+
vlan_dev_set_lockdep_class(dev);
602+
582603
vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
583604
if (!vlan->vlan_pcpu_stats)
584605
return -ENOMEM;

net/batman-adv/soft-interface.c

+30
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,34 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto,
739739
return 0;
740740
}
741741

742+
/* batman-adv network devices have devices nesting below it and are a special
743+
* "super class" of normal network devices; split their locks off into a
744+
* separate class since they always nest.
745+
*/
746+
static struct lock_class_key batadv_netdev_xmit_lock_key;
747+
748+
/**
749+
* batadv_set_lockdep_class_one() - Set lockdep class for a single tx queue
750+
* @dev: device which owns the tx queue
751+
* @txq: tx queue to modify
752+
* @_unused: always NULL
753+
*/
754+
static void batadv_set_lockdep_class_one(struct net_device *dev,
755+
struct netdev_queue *txq,
756+
void *_unused)
757+
{
758+
lockdep_set_class(&txq->_xmit_lock, &batadv_netdev_xmit_lock_key);
759+
}
760+
761+
/**
762+
* batadv_set_lockdep_class() - Set txq and addr_list lockdep class
763+
* @dev: network device to modify
764+
*/
765+
static void batadv_set_lockdep_class(struct net_device *dev)
766+
{
767+
netdev_for_each_tx_queue(dev, batadv_set_lockdep_class_one, NULL);
768+
}
769+
742770
/**
743771
* batadv_softif_init_late() - late stage initialization of soft interface
744772
* @dev: registered network device to modify
@@ -752,6 +780,8 @@ static int batadv_softif_init_late(struct net_device *dev)
752780
int ret;
753781
size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM;
754782

783+
batadv_set_lockdep_class(dev);
784+
755785
bat_priv = netdev_priv(dev);
756786
bat_priv->soft_iface = dev;
757787

net/bluetooth/6lowpan.c

+8
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,15 @@ static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev)
571571
return err < 0 ? NET_XMIT_DROP : err;
572572
}
573573

574+
static int bt_dev_init(struct net_device *dev)
575+
{
576+
netdev_lockdep_set_classes(dev);
577+
578+
return 0;
579+
}
580+
574581
static const struct net_device_ops netdev_ops = {
582+
.ndo_init = bt_dev_init,
575583
.ndo_start_xmit = bt_xmit,
576584
};
577585

0 commit comments

Comments
 (0)