Skip to content

Commit 5d2295f

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
hrtimer: Add a missing bracket and hide `migration_base' on !SMP
The recent change to avoid taking the expiry lock when a timer is currently migrated missed to add a bracket at the end of the if statement leading to compile errors. Since that commit the variable `migration_base' is always used but it is only available on SMP configuration thus leading to another compile error. The changelog says "The timer base and base->cpu_base cannot be NULL in the code path", so it is safe to limit this check to SMP configurations only. Add the missing bracket to the if statement and hide `migration_base' behind CONFIG_SMP bars. [ tglx: Mark the functions inline ... ] Fixes: 68b2c8c ("hrtimer: Don't take expiry_lock when timer is currently migrated") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a2ed4fd commit 5d2295f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kernel/time/hrtimer.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ static struct hrtimer_cpu_base migration_cpu_base = {
140140

141141
#define migration_base migration_cpu_base.clock_base[0]
142142

143+
static inline bool is_migration_base(struct hrtimer_clock_base *base)
144+
{
145+
return base == &migration_base;
146+
}
147+
143148
/*
144149
* We are using hashed locking: holding per_cpu(hrtimer_bases)[n].lock
145150
* means that all timers which are tied to this base via timer->base are
@@ -264,6 +269,11 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
264269

265270
#else /* CONFIG_SMP */
266271

272+
static inline bool is_migration_base(struct hrtimer_clock_base *base)
273+
{
274+
return false;
275+
}
276+
267277
static inline struct hrtimer_clock_base *
268278
lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
269279
{
@@ -1221,7 +1231,7 @@ void hrtimer_cancel_wait_running(const struct hrtimer *timer)
12211231
* Just relax if the timer expires in hard interrupt context or if
12221232
* it is currently on the migration base.
12231233
*/
1224-
if (!timer->is_soft || base == &migration_base)
1234+
if (!timer->is_soft || is_migration_base(base)) {
12251235
cpu_relax();
12261236
return;
12271237
}

0 commit comments

Comments
 (0)