]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
pkt_sched: Fix qdisc_watchdog() vs. dev_deactivate() race
authorJarek Poplawski <jarkao2@gmail.com>
Thu, 21 Aug 2008 12:11:14 +0000 (05:11 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Aug 2008 12:11:14 +0000 (05:11 -0700)
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>
include/net/sch_generic.h
net/sched/sch_api.c
net/sched/sch_cbq.c

index 84d25f2e6188764931268b5b6b6a3b70e4516c18..b1d2cfea89c5221b568a709c34ccb7031dfeff69 100644 (file)
@@ -193,6 +193,11 @@ static inline struct Qdisc *qdisc_root(struct Qdisc *qdisc)
        return qdisc->dev_queue->qdisc;
 }
 
+static inline struct Qdisc *qdisc_root_sleeping(struct Qdisc *qdisc)
+{
+       return qdisc->dev_queue->qdisc_sleeping;
+}
+
 /* The qdisc root lock is a mechanism by which to top level
  * of a qdisc tree can be locked from any qdisc node in the
  * forest.  This allows changing the configuration of some
index ef0efeca63521600fc7cf3cbfde0f858b5454c83..45f442d7de4703e2c398a7bafb2338a94cf39075 100644 (file)
@@ -444,6 +444,10 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
 {
        ktime_t time;
 
+       if (test_bit(__QDISC_STATE_DEACTIVATED,
+                    &qdisc_root_sleeping(wd->qdisc)->state))
+               return;
+
        wd->qdisc->flags |= TCQ_F_THROTTLED;
        time = ktime_set(0, 0);
        time = ktime_add_ns(time, PSCHED_US2NS(expires));
index 47ef492c4ff40ad23735aa6254885b503e094e2f..8fa90d68ec6d8ab2f7ac47efcd511e31553bece6 100644 (file)
@@ -521,6 +521,10 @@ static void cbq_ovl_delay(struct cbq_class *cl)
        struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
        psched_tdiff_t delay = cl->undertime - q->now;
 
+       if (test_bit(__QDISC_STATE_DEACTIVATED,
+                    &qdisc_root_sleeping(cl->qdisc)->state))
+               return;
+
        if (!cl->delayed) {
                psched_time_t sched = q->now;
                ktime_t expires;