[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080820115656.GA7078@ff.dom.local>
Date: Wed, 20 Aug 2008 11:56:56 +0000
From: Jarek Poplawski <jarkao2@...il.com>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org
Subject: [PATCH] pkt_sched: Fix qdisc_watchdog() vs. dev_deactivate() race
On Wed, Aug 20, 2008 at 08:23:29AM +1000, Herbert Xu wrote:
> On Tue, Aug 19, 2008 at 06:48:31PM +0200, Jarek Poplawski wrote:
> >
> > I can miss something, but probably it's needed in __netif_reschedule()
>
> No this is a genuine bug. However, it's also an old bug :) Even
> with the locking and RCU barrier it could have occured.
>
> > yet. Here is a scenario:
> >
> > cpu1 cpu2
> > dev_deactivate()
> > dev_deactivate_queue()
> > qdisc_reset()
> > qdisc_run()
> > qdisc_watchdog_schedule()
> > (or hrtimer_restart in cbq)
>
> We should add an aliveness check before scheduling the timer. This
> is the slow path so adding a check shouldn't hurt.
Thanks,
Jarek P.
--------------->
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.
With feedback from Herbert Xu <herbert@...dor.apana.org.au>
Signed-off-by: Jarek Poplawski <jarkao2@...il.com>
---
net/sched/sch_api.c | 3 +++
net/sched/sch_cbq.c | 3 +++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index ef0efec..6f2bc7f 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -444,6 +444,9 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
{
ktime_t time;
+ if (test_bit(__QDISC_STATE_DEACTIVATED, &qdisc_root(wd->qdisc)->state))
+ return;
+
wd->qdisc->flags |= TCQ_F_THROTTLED;
time = ktime_set(0, 0);
time = ktime_add_ns(time, PSCHED_US2NS(expires));
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 47ef492..c04d335 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -521,6 +521,9 @@ 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(cl->qdisc)->state))
+ return;
+
if (!cl->delayed) {
psched_time_t sched = q->now;
ktime_t expires;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists