From 7f311acbfb7bc53a1bce6a65f83e2d1f4642ac0b Mon Sep 17 00:00:00 2001 From: Srinivas Ramana Date: Sat, 15 Sep 2018 22:58:48 +0530 Subject: [PATCH] hrtimer: Initialize cpu_base.next_timer to NULL conditionally hrtimer_cpu_base.next_timer stores the pointer to the next expiring timer in a CPU base. This pointer is used to check whether a hrtimer which is removed is the hrtimer which is the first to expire in the CPU base. To get the estimated sleep length cpuidle_select call from governor depends on hrtimer_next_event_without() which does __hrtimer_get_next_event() excluding tick_sched_timer. cpu_base.next_timer is made NULL unconditionally but actual timer assignment is skipped in case of exclude call. So this pointer stays NULL and we skip programming the hrtimer event even though the hrtimer being removed is the first one to expire. This may result in an unwanted old event getting triggered. Fix this by initializing cpu_base.next_timer to NULL only for non exclude calls. Change-Id: I3c64f34e487e224a6a3b75a840869fc1371dd5b7 Signed-off-by: Srinivas Ramana Signed-off-by: Rishabh Bhatnagar --- kernel/time/hrtimer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 8116c8634008..4d506f6b0596 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -499,6 +499,12 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base, struct hrtimer_clock_base *base; ktime_t expires; + /* + * Skip initializing cpu_base->next_timer to NULL as we skip updating + * next_timer in below loop if the timer is being exluded. + */ + if (!exclude) + cpu_base->next_timer = NULL; for_each_active_base(base, cpu_base, active) { struct timerqueue_node *next; struct hrtimer *timer;