From 47b24bf8ea851b82c0c290c547d36e80428d5141 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 17 Aug 2024 09:39:22 +0000 Subject: [PATCH] Revert "net/sched: fix false lockdep warning on qdisc root lock" This reverts commit 048b33817a7f0967f159bdbb4371df62a3a47438 which is commit af0cb3fa3f9ed258d14abab0152e28a0f9593084 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I1a0434ee7eb3b2ff625e5eba9a7d9547452f0bb3 Signed-off-by: Greg Kroah-Hartman --- include/net/sch_generic.h | 2 -- net/sched/sch_generic.c | 3 --- net/sched/sch_htb.c | 22 +++++++++++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 9185a4a5de8f..c1ca075be574 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -127,8 +127,6 @@ struct Qdisc { struct rcu_head rcu; netdevice_tracker dev_tracker; - struct lock_class_key root_lock_key; - ANDROID_KABI_RESERVE(1); /* private data */ diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index d4b4e32aa0e0..a5693e25b248 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -942,9 +942,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, __skb_queue_head_init(&sch->gso_skb); __skb_queue_head_init(&sch->skb_bad_txq); gnet_stats_basic_sync_init(&sch->bstats); - lockdep_register_key(&sch->root_lock_key); spin_lock_init(&sch->q.lock); - lockdep_set_class(&sch->q.lock, &sch->root_lock_key); if (ops->static_flags & TCQ_F_CPUSTATS) { sch->cpu_bstats = @@ -1064,7 +1062,6 @@ static void __qdisc_destroy(struct Qdisc *qdisc) if (ops->destroy) ops->destroy(qdisc); - lockdep_unregister_key(&qdisc->root_lock_key); module_put(ops->owner); netdev_put(qdisc_dev(qdisc), &qdisc->dev_tracker); diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index d23f8ea63082..67b1879ea8e1 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1036,6 +1036,13 @@ static void htb_work_func(struct work_struct *work) rcu_read_unlock(); } +static void htb_set_lockdep_class_child(struct Qdisc *q) +{ + static struct lock_class_key child_key; + + lockdep_set_class(qdisc_lock(q), &child_key); +} + static int htb_offload(struct net_device *dev, struct tc_htb_qopt_offload *opt) { return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_HTB, opt); @@ -1122,6 +1129,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt, return -ENOMEM; } + htb_set_lockdep_class_child(qdisc); q->direct_qdiscs[ntx] = qdisc; qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; } @@ -1457,6 +1465,7 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, } if (q->offload) { + htb_set_lockdep_class_child(new); /* One ref for cl->leaf.q, the other for dev_queue->qdisc. */ qdisc_refcount_inc(new); old_q = htb_graft_helper(dev_queue, new); @@ -1719,8 +1728,11 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg, new_q = qdisc_create_dflt(dev_queue, &pfifo_qdisc_ops, cl->parent->common.classid, NULL); - if (q->offload) + if (q->offload) { + if (new_q) + htb_set_lockdep_class_child(new_q); htb_parent_to_leaf_offload(sch, dev_queue, new_q); + } } sch_tree_lock(sch); @@ -1934,9 +1946,13 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, new_q = qdisc_create_dflt(dev_queue, &pfifo_qdisc_ops, classid, NULL); if (q->offload) { - /* One ref for cl->leaf.q, the other for dev_queue->qdisc. */ - if (new_q) + if (new_q) { + htb_set_lockdep_class_child(new_q); + /* One ref for cl->leaf.q, the other for + * dev_queue->qdisc. + */ qdisc_refcount_inc(new_q); + } old_q = htb_graft_helper(dev_queue, new_q); /* No qdisc_put needed. */ WARN_ON(!(old_q->flags & TCQ_F_BUILTIN));