Commit ead81cc5 authored by David S. Miller's avatar David S. Miller

netdevice: Move qdisc_list back into net_device proper.

And give it it's own lock.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15b458fa
...@@ -450,7 +450,6 @@ struct netdev_queue { ...@@ -450,7 +450,6 @@ struct netdev_queue {
spinlock_t _xmit_lock; spinlock_t _xmit_lock;
int xmit_lock_owner; int xmit_lock_owner;
struct Qdisc *qdisc_sleeping; struct Qdisc *qdisc_sleeping;
struct list_head qdisc_list;
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
/* /*
...@@ -638,6 +637,8 @@ struct net_device ...@@ -638,6 +637,8 @@ struct net_device
unsigned int real_num_tx_queues; unsigned int real_num_tx_queues;
unsigned long tx_queue_len; /* Max frames per queue allowed */ unsigned long tx_queue_len; /* Max frames per queue allowed */
spinlock_t qdisc_list_lock;
struct list_head qdisc_list;
/* /*
* One part is mostly used on xmit path (device) * One part is mostly used on xmit path (device)
......
...@@ -3886,6 +3886,8 @@ int register_netdevice(struct net_device *dev) ...@@ -3886,6 +3886,8 @@ int register_netdevice(struct net_device *dev)
net = dev_net(dev); net = dev_net(dev);
spin_lock_init(&dev->addr_list_lock); spin_lock_init(&dev->addr_list_lock);
spin_lock_init(&dev->qdisc_list_lock);
INIT_LIST_HEAD(&dev->qdisc_list);
netdev_init_queue_locks(dev); netdev_init_queue_locks(dev);
dev->iflink = -1; dev->iflink = -1;
......
...@@ -183,30 +183,17 @@ EXPORT_SYMBOL(unregister_qdisc); ...@@ -183,30 +183,17 @@ EXPORT_SYMBOL(unregister_qdisc);
(root qdisc, all its children, children of children etc.) (root qdisc, all its children, children of children etc.)
*/ */
static struct Qdisc *__qdisc_lookup(struct netdev_queue *dev_queue, u32 handle) struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
{ {
struct Qdisc *q; struct Qdisc *q;
list_for_each_entry(q, &dev_queue->qdisc_list, list) { list_for_each_entry(q, &dev->qdisc_list, list) {
if (q->handle == handle) if (q->handle == handle)
return q; return q;
} }
return NULL; return NULL;
} }
struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
{
unsigned int i;
for (i = 0; i < dev->num_tx_queues; i++) {
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
struct Qdisc *q = __qdisc_lookup(txq, handle);
if (q)
return q;
}
return NULL;
}
static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
{ {
unsigned long cl; unsigned long cl;
...@@ -645,9 +632,9 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, ...@@ -645,9 +632,9 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
goto err_out3; goto err_out3;
} }
} }
qdisc_lock_tree(dev); spin_lock_bh(&dev->qdisc_list_lock);
list_add_tail(&sch->list, &dev_queue->qdisc_list); list_add_tail(&sch->list, &dev->qdisc_list);
qdisc_unlock_tree(dev); spin_unlock_bh(&dev->qdisc_list_lock);
return sch; return sch;
} }
...@@ -1032,14 +1019,12 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1032,14 +1019,12 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
idx = 0; idx = 0;
for_each_netdev(&init_net, dev) { for_each_netdev(&init_net, dev) {
struct netdev_queue *dev_queue;
if (idx < s_idx) if (idx < s_idx)
goto cont; goto cont;
if (idx > s_idx) if (idx > s_idx)
s_q_idx = 0; s_q_idx = 0;
q_idx = 0; q_idx = 0;
dev_queue = netdev_get_tx_queue(dev, 0); list_for_each_entry(q, &dev->qdisc_list, list) {
list_for_each_entry(q, &dev_queue->qdisc_list, list) {
if (q_idx < s_q_idx) { if (q_idx < s_q_idx) {
q_idx++; q_idx++;
continue; continue;
...@@ -1269,7 +1254,6 @@ static int qdisc_class_dump(struct Qdisc *q, unsigned long cl, struct qdisc_walk ...@@ -1269,7 +1254,6 @@ static int qdisc_class_dump(struct Qdisc *q, unsigned long cl, struct qdisc_walk
static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct netdev_queue *dev_queue;
int t; int t;
int s_t; int s_t;
struct net_device *dev; struct net_device *dev;
...@@ -1288,8 +1272,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1288,8 +1272,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
s_t = cb->args[0]; s_t = cb->args[0];
t = 0; t = 0;
dev_queue = netdev_get_tx_queue(dev, 0); list_for_each_entry(q, &dev->qdisc_list, list) {
list_for_each_entry(q, &dev_queue->qdisc_list, list) {
if (t < s_t || !q->ops->cl_ops || if (t < s_t || !q->ops->cl_ops ||
(tcm->tcm_parent && (tcm->tcm_parent &&
TC_H_MAJ(tcm->tcm_parent) != q->handle)) { TC_H_MAJ(tcm->tcm_parent) != q->handle)) {
......
...@@ -563,11 +563,15 @@ static void __qdisc_destroy(struct rcu_head *head) ...@@ -563,11 +563,15 @@ static void __qdisc_destroy(struct rcu_head *head)
void qdisc_destroy(struct Qdisc *qdisc) void qdisc_destroy(struct Qdisc *qdisc)
{ {
struct net_device *dev = qdisc_dev(qdisc);
if (qdisc->flags & TCQ_F_BUILTIN || if (qdisc->flags & TCQ_F_BUILTIN ||
!atomic_dec_and_test(&qdisc->refcnt)) !atomic_dec_and_test(&qdisc->refcnt))
return; return;
spin_lock_bh(&dev->qdisc_list_lock);
list_del(&qdisc->list); list_del(&qdisc->list);
spin_unlock_bh(&dev->qdisc_list_lock);
call_rcu(&qdisc->q_rcu, __qdisc_destroy); call_rcu(&qdisc->q_rcu, __qdisc_destroy);
} }
...@@ -599,7 +603,9 @@ static void attach_one_default_qdisc(struct net_device *dev, ...@@ -599,7 +603,9 @@ static void attach_one_default_qdisc(struct net_device *dev,
printk(KERN_INFO "%s: activation failed\n", dev->name); printk(KERN_INFO "%s: activation failed\n", dev->name);
return; return;
} }
list_add_tail(&qdisc->list, &dev_queue->qdisc_list); spin_lock_bh(&dev->qdisc_list_lock);
list_add_tail(&qdisc->list, &dev->qdisc_list);
spin_unlock_bh(&dev->qdisc_list_lock);
} else { } else {
qdisc = &noqueue_qdisc; qdisc = &noqueue_qdisc;
} }
...@@ -738,7 +744,6 @@ static void dev_init_scheduler_queue(struct net_device *dev, ...@@ -738,7 +744,6 @@ static void dev_init_scheduler_queue(struct net_device *dev,
dev_queue->qdisc = qdisc; dev_queue->qdisc = qdisc;
dev_queue->qdisc_sleeping = qdisc; dev_queue->qdisc_sleeping = qdisc;
INIT_LIST_HEAD(&dev_queue->qdisc_list);
} }
void dev_init_scheduler(struct net_device *dev) void dev_init_scheduler(struct net_device *dev)
......
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