Skip to content

Commit

Permalink
staging: android-alarm: Update hrtimer if alarm at the head of the qu…
Browse files Browse the repository at this point in the history
…eue is reprogrammed

If an alarm was restarted with a value that moved it away from the head
of a queue, the hrtimer would not be updated. This would cause unnecessary
wakeups.

CC: Arve Hjønnevåg <arve@android.com>
CC: Android Kernel Team <kernel-team@android.com>
Change-Id: If379f8dd92b0bdb3173bd8d057adfe0dc1d15259
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Arve Hjønnevåg authored and Greg Kroah-Hartman committed Feb 10, 2012
1 parent 58a38ff commit 66c4810
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/staging/android/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ static void alarm_enqueue_locked(struct android_alarm *alarm)
struct rb_node *parent = NULL;
struct android_alarm *entry;
int leftmost = 1;
bool was_first = false;

pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires));

if (base->first == &alarm->node)
if (base->first == &alarm->node) {
base->first = rb_next(&alarm->node);
was_first = true;
}
if (!RB_EMPTY_NODE(&alarm->node)) {
rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node);
Expand All @@ -144,10 +147,10 @@ static void alarm_enqueue_locked(struct android_alarm *alarm)
leftmost = 0;
}
}
if (leftmost) {
if (leftmost)
base->first = &alarm->node;
update_timer_locked(base, false);
}
if (leftmost || was_first)
update_timer_locked(base, was_first);

rb_link_node(&alarm->node, parent, link);
rb_insert_color(&alarm->node, &base->alarms);
Expand Down

0 comments on commit 66c4810

Please sign in to comment.