* [PATCH] suppress needless timer reprogramming {tick-sched.c}
[not found] ` <200806150130.32901.david-b@pacbell.net>
@ 2008-06-17 0:05 ` Woodruff, Richard
[not found] ` <13B9B4C6EF24D648824FF11BE8967162035B963D16@dlee02.ent.ti.com>
1 sibling, 0 replies; 2+ messages in thread
From: Woodruff, Richard @ 2008-06-17 0:05 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Tony Lindgren, David Brownell, 'linux-kernel@vger.kernel.org'
[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]
Thomas,
Does this patch look ok?
It simply does a check to see if the about to be reprogrammed 1 shot already is the last event programmed in the hardware. If it is it skips calling the hardware.
In my device I get many interrupts from a high speed USB device in a very short period of time. The system spends a lot of time reprogramming the hardware timer which is in a slower timing domain as compared to the CPU. This results in the CPU spending a huge amount of time waiting for the timer posting to be done. All of this reprogramming is useless as the wake up time has not changed.
As measured using ETM trace this drops my reprogramming penalty from almost 60% CPU load down to 15% during high interrupt rate. If you like I can send traces to show this.
Regards,
Richard W.
BTW:
I can much the other 15% by keeping the ticker on by using a function like there is for rcu today in tick-sched.c. Something like an irq_needs_cpu() by the rcu_needs_cpu() check. Where return = 1 if (curr_irq_ts - last_irq_ts < min_delta_ns). A time stamp is taken in irq code at entry.
[-- Attachment #2: suppress_reprogram_2626-rc5.diff --]
[-- Type: application/octet-stream, Size: 1454 bytes --]
Suppress setting of duplicate timer event when timer already stopped.
Timer programming can be very costly and can result in long cpu
stall/wait times.
Signed-off-by: Richard Woodruff <r-woodruff2@ti.com>
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index b854a89..ff6b967 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -254,6 +254,17 @@ void tick_nohz_stop_sched_tick(void)
/* Schedule the tick, if we are at least one jiffie off */
if ((long)delta_jiffies >= 1) {
+ /*
+ * calculate the expiry time for the next timer wheel
+ * timer
+ */
+ expires = ktime_add_ns(last_update, tick_period.tv64 *
+ delta_jiffies);
+
+ /* Skip reprogram of event if its not changed */
+ if(ts->tick_stopped && ktime_equal(expires, dev->next_event))
+ goto out2;
+
if (delta_jiffies > 1)
cpu_set(cpu, nohz_cpu_mask);
/*
@@ -304,12 +315,7 @@ void tick_nohz_stop_sched_tick(void)
goto out;
}
- /*
- * calculate the expiry time for the next timer wheel
- * timer
- */
- expires = ktime_add_ns(last_update, tick_period.tv64 *
- delta_jiffies);
+ /* Mark expiries */
ts->idle_expires = expires;
if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
@@ -328,6 +334,7 @@ void tick_nohz_stop_sched_tick(void)
tick_do_update_jiffies64(ktime_get());
cpu_clear(cpu, nohz_cpu_mask);
}
+out2:
raise_softirq_irqoff(TIMER_SOFTIRQ);
out:
ts->next_jiffies = next_jiffies;
^ permalink raw reply [flat|nested] 2+ messages in thread