Skip to content

Commit c919279

Browse files
committed
Merge branch 'timers-for-linus-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: hrtimer: Preserve timer state in remove_hrtimer()
2 parents 1bbee7d + f13d4f9 commit c919279

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/hrtimer.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ static inline int
931931
remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
932932
{
933933
if (hrtimer_is_queued(timer)) {
934+
unsigned long state;
934935
int reprogram;
935936

936937
/*
@@ -944,8 +945,13 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
944945
debug_deactivate(timer);
945946
timer_stats_hrtimer_clear_start_info(timer);
946947
reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases);
947-
__remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE,
948-
reprogram);
948+
/*
949+
* We must preserve the CALLBACK state flag here,
950+
* otherwise we could move the timer base in
951+
* switch_hrtimer_base.
952+
*/
953+
state = timer->state & HRTIMER_STATE_CALLBACK;
954+
__remove_hrtimer(timer, base, state, reprogram);
949955
return 1;
950956
}
951957
return 0;
@@ -1231,6 +1237,9 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
12311237
BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
12321238
enqueue_hrtimer(timer, base);
12331239
}
1240+
1241+
WARN_ON_ONCE(!(timer->state & HRTIMER_STATE_CALLBACK));
1242+
12341243
timer->state &= ~HRTIMER_STATE_CALLBACK;
12351244
}
12361245

0 commit comments

Comments
 (0)