Commit 806a8376 authored by Gao Feng's avatar Gao Feng Committed by David S. Miller

pkt_sched: Remove useless qdisc_stab_lock

The qdisc_stab_lock is used in qdisc_get_stab and qdisc_put_stab.
These two functions are invoked in qdisc_create, qdisc_change, and
qdisc_destroy which run fully under RTNL.

So it already makes sure only one could access the qdisc_stab_list at
the same time. Then it is unnecessary to use qdisc_stab_lock now.
Signed-off-by: default avatarGao Feng <fgao@ikuai8.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 88c4845d
...@@ -440,7 +440,6 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab) ...@@ -440,7 +440,6 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab)
EXPORT_SYMBOL(qdisc_put_rtab); EXPORT_SYMBOL(qdisc_put_rtab);
static LIST_HEAD(qdisc_stab_list); static LIST_HEAD(qdisc_stab_list);
static DEFINE_SPINLOCK(qdisc_stab_lock);
static const struct nla_policy stab_policy[TCA_STAB_MAX + 1] = { static const struct nla_policy stab_policy[TCA_STAB_MAX + 1] = {
[TCA_STAB_BASE] = { .len = sizeof(struct tc_sizespec) }, [TCA_STAB_BASE] = { .len = sizeof(struct tc_sizespec) },
...@@ -474,20 +473,15 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) ...@@ -474,20 +473,15 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
if (tsize != s->tsize || (!tab && tsize > 0)) if (tsize != s->tsize || (!tab && tsize > 0))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
spin_lock(&qdisc_stab_lock);
list_for_each_entry(stab, &qdisc_stab_list, list) { list_for_each_entry(stab, &qdisc_stab_list, list) {
if (memcmp(&stab->szopts, s, sizeof(*s))) if (memcmp(&stab->szopts, s, sizeof(*s)))
continue; continue;
if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16))) if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16)))
continue; continue;
stab->refcnt++; stab->refcnt++;
spin_unlock(&qdisc_stab_lock);
return stab; return stab;
} }
spin_unlock(&qdisc_stab_lock);
stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL); stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL);
if (!stab) if (!stab)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -497,9 +491,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) ...@@ -497,9 +491,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
if (tsize > 0) if (tsize > 0)
memcpy(stab->data, tab, tsize * sizeof(u16)); memcpy(stab->data, tab, tsize * sizeof(u16));
spin_lock(&qdisc_stab_lock);
list_add_tail(&stab->list, &qdisc_stab_list); list_add_tail(&stab->list, &qdisc_stab_list);
spin_unlock(&qdisc_stab_lock);
return stab; return stab;
} }
...@@ -514,14 +506,10 @@ void qdisc_put_stab(struct qdisc_size_table *tab) ...@@ -514,14 +506,10 @@ void qdisc_put_stab(struct qdisc_size_table *tab)
if (!tab) if (!tab)
return; return;
spin_lock(&qdisc_stab_lock);
if (--tab->refcnt == 0) { if (--tab->refcnt == 0) {
list_del(&tab->list); list_del(&tab->list);
call_rcu_bh(&tab->rcu, stab_kfree_rcu); call_rcu_bh(&tab->rcu, stab_kfree_rcu);
} }
spin_unlock(&qdisc_stab_lock);
} }
EXPORT_SYMBOL(qdisc_put_stab); EXPORT_SYMBOL(qdisc_put_stab);
......
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