Commit 5c7ff181 authored by David S. Miller's avatar David S. Miller

Merge branch 'qdisc-destroy'

Vlad Buslov says:

====================
Fix Qdisc destroy issues caused by adding fine-grained locking to filter API

TC filter API unlocking introduced several new fine-grained locks. The
change caused sleeping-while-atomic BUGs in several Qdiscs that call cls
APIs which need to obtain new mutex while holding sch tree spinlock. This
series fixes affected Qdiscs by ensuring that cls API that became sleeping
is only called outside of sch tree lock critical section.
====================
Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 05733434 e3ae1f96
...@@ -1302,6 +1302,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1302,6 +1302,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
struct htb_class *cl = (struct htb_class *)*arg, *parent; struct htb_class *cl = (struct htb_class *)*arg, *parent;
struct nlattr *opt = tca[TCA_OPTIONS]; struct nlattr *opt = tca[TCA_OPTIONS];
struct nlattr *tb[TCA_HTB_MAX + 1]; struct nlattr *tb[TCA_HTB_MAX + 1];
struct Qdisc *parent_qdisc = NULL;
struct tc_htb_opt *hopt; struct tc_htb_opt *hopt;
u64 rate64, ceil64; u64 rate64, ceil64;
int warn = 0; int warn = 0;
...@@ -1401,7 +1402,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1401,7 +1402,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
if (parent && !parent->level) { if (parent && !parent->level) {
/* turn parent into inner node */ /* turn parent into inner node */
qdisc_purge_queue(parent->leaf.q); qdisc_purge_queue(parent->leaf.q);
qdisc_put(parent->leaf.q); parent_qdisc = parent->leaf.q;
if (parent->prio_activity) if (parent->prio_activity)
htb_deactivate(q, parent); htb_deactivate(q, parent);
...@@ -1480,6 +1481,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1480,6 +1481,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer); cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer);
sch_tree_unlock(sch); sch_tree_unlock(sch);
qdisc_put(parent_qdisc);
if (warn) if (warn)
pr_warn("HTB: quantum of class %X is %s. Consider r2q change.\n", pr_warn("HTB: quantum of class %X is %s. Consider r2q change.\n",
......
...@@ -174,7 +174,8 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -174,7 +174,8 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
{ {
struct multiq_sched_data *q = qdisc_priv(sch); struct multiq_sched_data *q = qdisc_priv(sch);
struct tc_multiq_qopt *qopt; struct tc_multiq_qopt *qopt;
int i; struct Qdisc **removed;
int i, n_removed = 0;
if (!netif_is_multiqueue(qdisc_dev(sch))) if (!netif_is_multiqueue(qdisc_dev(sch)))
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -185,6 +186,11 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -185,6 +186,11 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
qopt->bands = qdisc_dev(sch)->real_num_tx_queues; qopt->bands = qdisc_dev(sch)->real_num_tx_queues;
removed = kmalloc(sizeof(*removed) * (q->max_bands - q->bands),
GFP_KERNEL);
if (!removed)
return -ENOMEM;
sch_tree_lock(sch); sch_tree_lock(sch);
q->bands = qopt->bands; q->bands = qopt->bands;
for (i = q->bands; i < q->max_bands; i++) { for (i = q->bands; i < q->max_bands; i++) {
...@@ -192,13 +198,17 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -192,13 +198,17 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
struct Qdisc *child = q->queues[i]; struct Qdisc *child = q->queues[i];
q->queues[i] = &noop_qdisc; q->queues[i] = &noop_qdisc;
qdisc_tree_flush_backlog(child); qdisc_purge_queue(child);
qdisc_put(child); removed[n_removed++] = child;
} }
} }
sch_tree_unlock(sch); sch_tree_unlock(sch);
for (i = 0; i < n_removed; i++)
qdisc_put(removed[i]);
kfree(removed);
for (i = 0; i < q->bands; i++) { for (i = 0; i < q->bands; i++) {
if (q->queues[i] == &noop_qdisc) { if (q->queues[i] == &noop_qdisc) {
struct Qdisc *child, *old; struct Qdisc *child, *old;
...@@ -213,11 +223,10 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -213,11 +223,10 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
if (child != &noop_qdisc) if (child != &noop_qdisc)
qdisc_hash_add(child, true); qdisc_hash_add(child, true);
if (old != &noop_qdisc) { if (old != &noop_qdisc)
qdisc_tree_flush_backlog(old); qdisc_purge_queue(old);
qdisc_put(old);
}
sch_tree_unlock(sch); sch_tree_unlock(sch);
qdisc_put(old);
} }
} }
} }
......
...@@ -488,7 +488,7 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt, ...@@ -488,7 +488,7 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct sfb_sched_data *q = qdisc_priv(sch); struct sfb_sched_data *q = qdisc_priv(sch);
struct Qdisc *child; struct Qdisc *child, *old;
struct nlattr *tb[TCA_SFB_MAX + 1]; struct nlattr *tb[TCA_SFB_MAX + 1];
const struct tc_sfb_qopt *ctl = &sfb_default_ops; const struct tc_sfb_qopt *ctl = &sfb_default_ops;
u32 limit; u32 limit;
...@@ -518,8 +518,8 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt, ...@@ -518,8 +518,8 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt,
qdisc_hash_add(child, true); qdisc_hash_add(child, true);
sch_tree_lock(sch); sch_tree_lock(sch);
qdisc_tree_flush_backlog(q->qdisc); qdisc_purge_queue(q->qdisc);
qdisc_put(q->qdisc); old = q->qdisc;
q->qdisc = child; q->qdisc = child;
q->rehash_interval = msecs_to_jiffies(ctl->rehash_interval); q->rehash_interval = msecs_to_jiffies(ctl->rehash_interval);
...@@ -542,6 +542,7 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt, ...@@ -542,6 +542,7 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt,
sfb_init_perturbation(1, q); sfb_init_perturbation(1, q);
sch_tree_unlock(sch); sch_tree_unlock(sch);
qdisc_put(old);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment