diff options
author | David S. Miller <davem@davemloft.net> | 2008-07-16 04:42:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-17 22:21:19 -0400 |
commit | 7698b4fcabcd790efc4f226bada1e7b5870653af (patch) | |
tree | 031ce7a911fc5bff995421a5615d9ab25416a479 /net/sched/sch_netem.c | |
parent | e2627c8c2241bce45e368e150654d076b58a4595 (diff) |
pkt_sched: Add and use qdisc_root() and qdisc_root_lock().
When code wants to lock the qdisc tree state, the logic
operation it's doing is locking the top-level qdisc that
sits of the root of the netdev_queue.
Add qdisc_root_lock() to represent this and convert the
easiest cases.
In order for this to work out in all cases, we have to
hook up the noop_qdisc to a dummy netdev_queue.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_netem.c')
-rw-r--r-- | net/sched/sch_netem.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index bc585f2089ff..c5ea40c9eb21 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -180,7 +180,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
180 | * skb will be queued. | 180 | * skb will be queued. |
181 | */ | 181 | */ |
182 | if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { | 182 | if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { |
183 | struct Qdisc *rootq = sch->dev_queue->qdisc; | 183 | struct Qdisc *rootq = qdisc_root(sch); |
184 | u32 dupsave = q->duplicate; /* prevent duplicating a dup... */ | 184 | u32 dupsave = q->duplicate; /* prevent duplicating a dup... */ |
185 | q->duplicate = 0; | 185 | q->duplicate = 0; |
186 | 186 | ||
@@ -319,6 +319,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) | |||
319 | struct netem_sched_data *q = qdisc_priv(sch); | 319 | struct netem_sched_data *q = qdisc_priv(sch); |
320 | unsigned long n = nla_len(attr)/sizeof(__s16); | 320 | unsigned long n = nla_len(attr)/sizeof(__s16); |
321 | const __s16 *data = nla_data(attr); | 321 | const __s16 *data = nla_data(attr); |
322 | spinlock_t *root_lock; | ||
322 | struct disttable *d; | 323 | struct disttable *d; |
323 | int i; | 324 | int i; |
324 | 325 | ||
@@ -333,9 +334,11 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) | |||
333 | for (i = 0; i < n; i++) | 334 | for (i = 0; i < n; i++) |
334 | d->table[i] = data[i]; | 335 | d->table[i] = data[i]; |
335 | 336 | ||
336 | spin_lock_bh(&sch->dev_queue->lock); | 337 | root_lock = qdisc_root_lock(sch); |
338 | |||
339 | spin_lock_bh(root_lock); | ||
337 | d = xchg(&q->delay_dist, d); | 340 | d = xchg(&q->delay_dist, d); |
338 | spin_unlock_bh(&sch->dev_queue->lock); | 341 | spin_unlock_bh(root_lock); |
339 | 342 | ||
340 | kfree(d); | 343 | kfree(d); |
341 | return 0; | 344 | return 0; |