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 <sramana@codeaurora.org>
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
This commit is contained in:
Srinivas Ramana 2018-09-15 22:58:48 +05:30 committed by Gerrit - the friendly Code Review server
parent 5f62bf9b0b
commit 7f311acbfb

View file

@ -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;