Revert "net/sched: fix false lockdep warning on qdisc root lock"

This reverts commit 048b33817a 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 <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-08-17 09:39:22 +00:00
committed by Treehugger Robot
parent 0a6ad70f07
commit 47b24bf8ea
3 changed files with 19 additions and 8 deletions

View File

@@ -127,8 +127,6 @@ struct Qdisc {
struct rcu_head rcu; struct rcu_head rcu;
netdevice_tracker dev_tracker; netdevice_tracker dev_tracker;
struct lock_class_key root_lock_key;
ANDROID_KABI_RESERVE(1); ANDROID_KABI_RESERVE(1);
/* private data */ /* private data */

View File

@@ -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->gso_skb);
__skb_queue_head_init(&sch->skb_bad_txq); __skb_queue_head_init(&sch->skb_bad_txq);
gnet_stats_basic_sync_init(&sch->bstats); gnet_stats_basic_sync_init(&sch->bstats);
lockdep_register_key(&sch->root_lock_key);
spin_lock_init(&sch->q.lock); spin_lock_init(&sch->q.lock);
lockdep_set_class(&sch->q.lock, &sch->root_lock_key);
if (ops->static_flags & TCQ_F_CPUSTATS) { if (ops->static_flags & TCQ_F_CPUSTATS) {
sch->cpu_bstats = sch->cpu_bstats =
@@ -1064,7 +1062,6 @@ static void __qdisc_destroy(struct Qdisc *qdisc)
if (ops->destroy) if (ops->destroy)
ops->destroy(qdisc); ops->destroy(qdisc);
lockdep_unregister_key(&qdisc->root_lock_key);
module_put(ops->owner); module_put(ops->owner);
netdev_put(qdisc_dev(qdisc), &qdisc->dev_tracker); netdev_put(qdisc_dev(qdisc), &qdisc->dev_tracker);

View File

@@ -1036,6 +1036,13 @@ static void htb_work_func(struct work_struct *work)
rcu_read_unlock(); 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) 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); 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; return -ENOMEM;
} }
htb_set_lockdep_class_child(qdisc);
q->direct_qdiscs[ntx] = qdisc; q->direct_qdiscs[ntx] = qdisc;
qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 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) { if (q->offload) {
htb_set_lockdep_class_child(new);
/* One ref for cl->leaf.q, the other for dev_queue->qdisc. */ /* One ref for cl->leaf.q, the other for dev_queue->qdisc. */
qdisc_refcount_inc(new); qdisc_refcount_inc(new);
old_q = htb_graft_helper(dev_queue, 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, new_q = qdisc_create_dflt(dev_queue, &pfifo_qdisc_ops,
cl->parent->common.classid, cl->parent->common.classid,
NULL); 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); htb_parent_to_leaf_offload(sch, dev_queue, new_q);
}
} }
sch_tree_lock(sch); 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, new_q = qdisc_create_dflt(dev_queue, &pfifo_qdisc_ops,
classid, NULL); classid, NULL);
if (q->offload) { 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); qdisc_refcount_inc(new_q);
}
old_q = htb_graft_helper(dev_queue, new_q); old_q = htb_graft_helper(dev_queue, new_q);
/* No qdisc_put needed. */ /* No qdisc_put needed. */
WARN_ON(!(old_q->flags & TCQ_F_BUILTIN)); WARN_ON(!(old_q->flags & TCQ_F_BUILTIN));