* [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
* Re: [PATCH] suppress needless timer reprogramming {tick-sched.c}
[not found] ` <13B9B4C6EF24D648824FF11BE8967162035B963D16@dlee02.ent.ti.com>
@ 2008-06-18 16:28 ` David Brownell
0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2008-06-18 16:28 UTC (permalink / raw)
To: Woodruff, Richard
Cc: Thomas Gleixner, Tony Lindgren,
'linux-kernel@vger.kernel.org',
linux-omap, TK, Pratheesh Gangadhar
On Wednesday 18 June 2008, Woodruff, Richard wrote:
> >
> > 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.
More than doubling the available-for-real-use CPU time! Impressive.
I'd imagine that many systems using reprogrammable 32K timers for
scheduling could win from such a patch, although not necessarily
quite so visibly as on this ARM unless their CPU clocks were also
in the 500+ MHz range.
Seems like a "law of unintended consequences" here. Use a 32K
timer since it takes less power than a multi-MHz one, and so the
faster clocks can be gated off more comprehensively (in hardware)
to give more power savings. Then throw NO_HZ on top to get one
more increment of power savings ... whoops, it was assuming that
it was dirt cheap to reprogram timers, major badness!
- Dave
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-18 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <3B6D69C3A9EBCA4BA5DA60D91302742904554EE1@dlee13.ent.ti.com>
[not found] ` <200805161055.17252.david-b@pacbell.net>
[not found] ` <13B9B4C6EF24D648824FF11BE8967162035B87F9B8@dlee02.ent.ti.com>
[not found] ` <200806150130.32901.david-b@pacbell.net>
2008-06-17 0:05 ` [PATCH] suppress needless timer reprogramming {tick-sched.c} Woodruff, Richard
[not found] ` <13B9B4C6EF24D648824FF11BE8967162035B963D16@dlee02.ent.ti.com>
2008-06-18 16:28 ` David Brownell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®