hrtimers: calculate expires_next after all timers are executed
Hi Thomas,
In this patch, we are only setting the flag cpu_base->in_hrtirq = 1; in hrtimer_interrupt() and not resetting it.
Review void hrtimer_interrupt(struct clock_even · line 1254
Quoted 5 lines
(quoted diff) +1
-0@@ -1251,9 +1251,9 @@ void hrtimer_interrupt(struct clock_even dev->next_event.tv64 = KTIME_MAX; raw_spin_lock(&cpu_base->lock); + cpu_base->in_hrtirq = 1;
Since this is the case, after the hrtimer_interrupt routine completes and new timer is started and say it happens to be leftmost,
we don't allow hrtimer_reprogram() since we bail out given that cpu_base->in_hrtirq=1 :
timer irq comes
--->hrtimer_interrupt()
---->cpu_base->in_hrtirq flag is set
------>Interrupt is serviced
After sometime
-->__hrtimer_start_range_ns()
--->happens to be leftmost hence call hrtimer_enqueue_reprogram() ----->hrtimer_reprogram()
------->bail out since cpu_base->in_hrtirq flag is stil set
At the end of hrtimer interrupt routine, i think we should also clear this flag.
Something like the following can be added ?
kernel/time/hrtimer.c +2 -1
@@ -1251,9 +1251,9 @@ void hrtimer_interrupt(struct clock_event_device *dev) dev->next_event.tv64 =KTIME_MAX ;raw_spin_lock (&cpu_base->lock); - cpu_base->in_hrtirq =1 ; entry_time = now =hrtimer_update_base (cpu_base); retry: + cpu_base->in_hrtirq =1 ;/* * We set expires_next to KTIME_MAX here with cpu_base->lock * held to prevent that a timer is enqueued in our queue via
@@ -1304,6 +1304,7 @@ retry:* against it. */ cpu_base->expires_next = expires_next; + cpu_base->in_hrtirq =0 ;raw_spin_unlock (&cpu_base->lock);/* Reprogramming necessary ? */
Thanks and regards,
vignesh Radhakrishnan
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 24 lines · On Wed, 21 Jan 2015, [email protected] wrote:
Hi Thomas,
In this patch, we are only setting the flag
cpu_base->in_hrtirq= 1; inhrtimer_interrupt()and not resetting it.kernel/time/hrtimer.c void hrtimer_interrupt(struct clock_even · line 1254
Quoted 5 lines
kernel/time/hrtimer.c +1
-0@@ -1251,9 +1251,9 @@ void hrtimer_interrupt(struct clock_even dev->next_event.tv64 =KTIME_MAX ;raw_spin_lock (&cpu_base->lock); + cpu_base->in_hrtirq =1 ;Since this is the case, after the
hrtimer_interruptroutine completes and new timer is started and say it happens to be leftmost,
we don't allowhrtimer_reprogram()since we bail out given that cpu_base->in_hrtirq=1 :timer irq comes
--->hrtimer_interrupt()
---->cpu_base->in_hrtirq flag is set
------>Interrupt is servicedAfter sometime
Quoted 7 lines
-->__hrtimer_start_range_ns()
--->happens to be leftmost hence callhrtimer_enqueue_reprogram()----->hrtimer_reprogram()
------->bail out sincecpu_base->in_hrtirqflag is stil setAt the end of hrtimer interrupt routine, i think we should also clear this flag.
Bah, yes. I moved it around several times and then dropped it.
Thanks for spotting it!
tglx
Hi Thomas,
Slightly tested your version (with Vignesh's fixes), no issues so far, thanks!