hrtimer: remove timerqueue node before reprogramming clockevent device

Currently the __remove_hrtimer function attempts to reprogram the
clockevent device so that we don't wake up unnecessarily from a timer we
have deleted. However, it does the reprogramming before actually
removing the timer in question from the timerqueue, so it turns into a
noop. This causes us to have an extra wakeup every time we remove the
timer that fires this. This is especially noticeable when the system
goes idle and we switch to NOHZ mode, as the system will always wakeup
one extra time when the system tick is removed.

Change-Id: If8656bbf85694228f279923fa86bd798d23e0f49
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index a9205e3..2043c08 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -885,10 +885,13 @@
 			     struct hrtimer_clock_base *base,
 			     unsigned long newstate, int reprogram)
 {
+	struct timerqueue_node *next_timer;
 	if (!(timer->state & HRTIMER_STATE_ENQUEUED))
 		goto out;
 
-	if (&timer->node == timerqueue_getnext(&base->active)) {
+	next_timer = timerqueue_getnext(&base->active);
+	timerqueue_del(&base->active, &timer->node);
+	if (&timer->node == next_timer) {
 #ifdef CONFIG_HIGH_RES_TIMERS
 		/* Reprogram the clock event device. if enabled */
 		if (reprogram && hrtimer_hres_active()) {
@@ -901,7 +904,6 @@
 		}
 #endif
 	}
-	timerqueue_del(&base->active, &timer->node);
 	if (!timerqueue_getnext(&base->active))
 		base->cpu_base->active_bases &= ~(1 << base->index);
 out: