[patch 3/3] net: use HRTIMER_RESTART in sched_cbq

From: Thomas Gleixner
Date: Thu Jul 09 2009 - 18:00:46 EST


Restarting a hrtimer from the callback function via hrtimer_start is
inefficient. The canonical way is to modify the expiry value of the
timer and return HRTIMER_RESTART to the hrtimer core code which takes
care of the restart.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
net/sched/sch_cbq.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6/net/sched/sch_cbq.c
===================================================================
--- linux-2.6.orig/net/sched/sch_cbq.c
+++ linux-2.6/net/sched/sch_cbq.c
@@ -605,6 +605,7 @@ static enum hrtimer_restart cbq_undelay(
struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
delay_timer);
struct Qdisc *sch = q->watchdog.qdisc;
+ enum hrtimer_restart ret = HRTIMER_NORESTART;
psched_time_t now;
psched_tdiff_t delay = 0;
unsigned pmask;
@@ -634,13 +635,14 @@ static enum hrtimer_restart cbq_undelay(

time = ktime_set(0, 0);
time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
- hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);
+ hrtimer_set_expires(&q->delay_timer, time);
+ ret = HRTIMER_RESTART;
}
spin_unlock(&q->lock);

sch->flags &= ~TCQ_F_THROTTLED;
__netif_schedule(qdisc_root(sch));
- return HRTIMER_NORESTART;
+ return ret;
}

#ifdef CONFIG_NET_CLS_ACT


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/