diff options
author | Alex Shi <alex.shi@linaro.org> | 2016-05-24 12:17:46 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2016-05-24 12:17:46 +0800 |
commit | b5db8c3eefa4d7b7ca7934610356969fa1a4547b (patch) | |
tree | fb2cc37b4da4b4611eb9920789a130a6c41af1e7 /kernel/time/timer.c | |
parent | 14c737514d0953f05e91103c05e975b3b5c1e469 (diff) | |
parent | 6c1be3bf831c5b1f2ba51425315287df2c350633 (diff) |
Merge branch 'linux-linaro-lsk-v3.18' into linux-linaro-lsk-v3.18-androidlsk-v3.18-16.05-android
Diffstat (limited to 'kernel/time/timer.c')
-rw-r--r-- | kernel/time/timer.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 3260ffdb368f..3c4e3116cdb1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -956,13 +956,27 @@ EXPORT_SYMBOL(add_timer); */ void add_timer_on(struct timer_list *timer, int cpu) { - struct tvec_base *base = per_cpu(tvec_bases, cpu); + struct tvec_base *new_base = per_cpu(tvec_bases, cpu); + struct tvec_base *base; unsigned long flags; timer_stats_timer_set_start_info(timer); BUG_ON(timer_pending(timer) || !timer->function); - spin_lock_irqsave(&base->lock, flags); - timer_set_base(timer, base); + + /* + * If @timer was on a different CPU, it should be migrated with the + * old base locked to prevent other operations proceeding with the + * wrong base locked. See lock_timer_base(). + */ + base = lock_timer_base(timer, &flags); + if (base != new_base) { + timer_set_base(timer, NULL); + spin_unlock(&base->lock); + base = new_base; + spin_lock(&base->lock); + timer_set_base(timer, base); + } + debug_activate(timer, timer->expires); internal_add_timer(base, timer); spin_unlock_irqrestore(&base->lock, flags); |