aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-08-21 08:11:14 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-21 08:11:14 -0400
commit2540e0511ea17e25831be543cdf9381e6209950d (patch)
tree31c505b9957d82125cd7e779d83da0d389f9d336
parent5e739d1752aca4e8f3e794d431503bfca3162df4 (diff)
pkt_sched: Fix qdisc_watchdog() vs. dev_deactivate() race
dev_deactivate() can skip rescheduling of a qdisc by qdisc_watchdog() or other timer calling netif_schedule() after dev_queue_deactivate(). We prevent this checking aliveness before scheduling the timer. Since during deactivation the root qdisc is available only as qdisc_sleeping additional accessor qdisc_root_sleeping() is created. With feedback from Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sch_generic.h5
-rw-r--r--net/sched/sch_api.c4
-rw-r--r--net/sched/sch_cbq.c4
3 files changed, 13 insertions, 0 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 84d25f2e6188..b1d2cfea89c5 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -193,6 +193,11 @@ static inline struct Qdisc *qdisc_root(struct Qdisc *qdisc)
193 return qdisc->dev_queue->qdisc; 193 return qdisc->dev_queue->qdisc;
194} 194}
195 195
196static inline struct Qdisc *qdisc_root_sleeping(struct Qdisc *qdisc)
197{
198 return qdisc->dev_queue->qdisc_sleeping;
199}
200
196/* The qdisc root lock is a mechanism by which to top level 201/* The qdisc root lock is a mechanism by which to top level
197 * of a qdisc tree can be locked from any qdisc node in the 202 * of a qdisc tree can be locked from any qdisc node in the
198 * forest. This allows changing the configuration of some 203 * forest. This allows changing the configuration of some
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index ef0efeca6352..45f442d7de47 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -444,6 +444,10 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
444{ 444{
445 ktime_t time; 445 ktime_t time;
446 446
447 if (test_bit(__QDISC_STATE_DEACTIVATED,
448 &qdisc_root_sleeping(wd->qdisc)->state))
449 return;
450
447 wd->qdisc->flags |= TCQ_F_THROTTLED; 451 wd->qdisc->flags |= TCQ_F_THROTTLED;
448 time = ktime_set(0, 0); 452 time = ktime_set(0, 0);
449 time = ktime_add_ns(time, PSCHED_US2NS(expires)); 453 time = ktime_add_ns(time, PSCHED_US2NS(expires));
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 47ef492c4ff4..8fa90d68ec6d 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -521,6 +521,10 @@ static void cbq_ovl_delay(struct cbq_class *cl)
521 struct cbq_sched_data *q = qdisc_priv(cl->qdisc); 521 struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
522 psched_tdiff_t delay = cl->undertime - q->now; 522 psched_tdiff_t delay = cl->undertime - q->now;
523 523
524 if (test_bit(__QDISC_STATE_DEACTIVATED,
525 &qdisc_root_sleeping(cl->qdisc)->state))
526 return;
527
524 if (!cl->delayed) { 528 if (!cl->delayed) {
525 psched_time_t sched = q->now; 529 psched_time_t sched = q->now;
526 ktime_t expires; 530 ktime_t expires;