Skip to contentSkip to conversation

: pkt_sched: Convert qdisc_watchdog to tasklet_hrtimer

PATCH In review David Miller 3 participants 7 messages Aug 22, 2009 – Sep 1, 2009

Subsystems (3)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 1/2 : pkt_sched: Convert qdisc_watchdog to tasklet_hrtimer

None of this stuff should execute in hw IRQ context, therefore use a tasklet_hrtimer so that it runs in softirq context.

---
 include/net/pkt_sched.h |    4 ++--
 net/sched/sch_api.c     |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/pkt_sched.h +2 -2
index 82a3191..7eafb8d 100644
@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
 }
 
 struct qdisc_watchdog {
-	struct hrtimer	timer;
-	struct Qdisc	*qdisc;
+	struct tasklet_hrtimer	timer;
+	struct Qdisc		*qdisc;
 };
 
 extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
net/sched/sch_api.c +4 -4
index 24d17ce..e1c2bf7 100644
@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
 
 void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
 {
-	hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	wd->timer.function = qdisc_watchdog;
+	tasklet_hrtimer_init(&wd->timer, qdisc_watchdog,
+			     CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	wd->qdisc = qdisc;
 }
 EXPORT_SYMBOL(qdisc_watchdog_init);
@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
 	wd->qdisc->flags |= TCQ_F_THROTTLED;
 	time = ktime_set(0, 0);
 	time = ktime_add_ns(time, PSCHED_TICKS2NS(expires));
-	hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
+	tasklet_hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
 }
 EXPORT_SYMBOL(qdisc_watchdog_schedule);
 
 void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
 {
-	hrtimer_cancel(&wd->timer);
+	tasklet_hrtimer_cancel(&wd->timer);
 	wd->qdisc->flags &= ~TCQ_F_THROTTLED;
 }
 EXPORT_SYMBOL(qdisc_watchdog_cancel);
Signature · 1 line
1.6.3.4
#3 lore raw
In reply to David Miller

David Miller wrote, On 08/22/2009 02:03 AM:

Quoted 2 lines

None of this stuff should execute in hw IRQ context, therefore use a tasklet_hrtimer so that it runs in softirq context.

Do you mean __netif_schedule()? Could you explain it more?

Thanks,
Jarek P.

Quoted 53 lines
---
 include/net/pkt_sched.h |    4 ++--
 net/sched/sch_api.c     |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/pkt_sched.h +2 -2
index 82a3191..7eafb8d 100644
@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
 }
 
 struct qdisc_watchdog {
-	struct hrtimer	timer;
-	struct Qdisc	*qdisc;
+	struct tasklet_hrtimer	timer;
+	struct Qdisc		*qdisc;
 };
 
 extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
net/sched/sch_api.c +4 -4
index 24d17ce..e1c2bf7 100644
@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
 
 void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
 {
-	hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	wd->timer.function = qdisc_watchdog;
+	tasklet_hrtimer_init(&wd->timer, qdisc_watchdog,
+			     CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	wd->qdisc = qdisc;
 }
 EXPORT_SYMBOL(qdisc_watchdog_init);
@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
 	wd->qdisc->flags |= TCQ_F_THROTTLED;
 	time = ktime_set(0, 0);
 	time = ktime_add_ns(time, PSCHED_TICKS2NS(expires));
-	hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
+	tasklet_hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
 }
 EXPORT_SYMBOL(qdisc_watchdog_schedule);
 
 void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
 {
-	hrtimer_cancel(&wd->timer);
+	tasklet_hrtimer_cancel(&wd->timer);
 	wd->qdisc->flags &= ~TCQ_F_THROTTLED;
 }
 EXPORT_SYMBOL(qdisc_watchdog_cancel);
author maintainer
#4 lore raw

From: Jarek Poplawski <[email protected]>
Date: Sat, 22 Aug 2009 14:04:31 +0200

Quoted 6 lines

David Miller wrote, On 08/22/2009 02:03 AM:

Quoted 2 lines

None of this stuff should execute in hw IRQ context, therefore use a tasklet_hrtimer so that it runs in softirq context.

Do you mean __netif_schedule()?

No, that works fine from HW irq context.

Quoted 1 line

Could you explain it more?

It's that throttled flag bit setting. It's still unsafe but at least we're in a position now to use softirq locking or atomic bitops to maintain it properly.

#5 lore raw
In reply to David Miller
Quoted 5 lines · David Miller

None of this stuff should execute in hw IRQ context, therefore use a tasklet_hrtimer so that it runs in softirq context.

---

...

net/sched/sch_api.c void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) · line 497

Quoted 7 lines

void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) {

net/sched/sch_api.c +1 -1
-	hrtimer_cancel(&wd->timer);
+	tasklet_hrtimer_cancel(&wd->timer);
 	wd->qdisc->flags &= ~TCQ_F_THROTTLED;
 }
 EXPORT_SYMBOL(qdisc_watchdog_cancel);

I've had a second look at it and I wonder why it's not reported, but since qdisc_watchdog_cancel is run in qdisc_reset with BHs disabled it seems there should be (at least) a warning triggered in tasklet_kill on positive in_interrupt test (unless I miss something, but can't test it now).

Jarek P.

author maintainer
#6 lore raw

From: Jarek Poplawski <[email protected]>
Date: Thu, 27 Aug 2009 08:36:41 +0000

Quoted 7 lines · David Miller
Quoted 5 lines

None of this stuff should execute in hw IRQ context, therefore use a tasklet_hrtimer so that it runs in softirq context.

---

...

Quoted 13 lines

net/sched/sch_api.c void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) · line 497

Quoted 7 lines

void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) {

net/sched/sch_api.c +1 -1
-	hrtimer_cancel(&wd->timer);
+	tasklet_hrtimer_cancel(&wd->timer);
 	wd->qdisc->flags &= ~TCQ_F_THROTTLED;
 }
 EXPORT_SYMBOL(qdisc_watchdog_cancel);

I've had a second look at it and I wonder why it's not reported, but since qdisc_watchdog_cancel is run in qdisc_reset with BHs disabled it seems there should be (at least) a warning triggered in tasklet_kill on positive in_interrupt test (unless I miss something, but can't test it now).

There are a lot of unknowns about this stuff.

It's very likely I'm going to simply revert these two patches and try to work on these issues in net-next-2.6 instead.