Skip to content

Commit 9482fd7

Browse files
committed
hrtimer: Use raw_cpu_ptr() in clock_was_set()
clock_was_set() can be invoked from preemptible context. Use raw_cpu_ptr() to check whether high resolution mode is active or not. It does not matter whether the task migrates after acquiring the pointer. Fixes: e71a415 ("hrtimer: Force clock_was_set() handling for the HIGHRES=n, NOHZ=y case") Reported-by: Mike Galbraith <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/875ywacsmb.ffs@tglx
1 parent 1e7f7fb commit 9482fd7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/time/hrtimer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,11 @@ static bool update_needs_ipi(struct hrtimer_cpu_base *cpu_base,
944944
*/
945945
void clock_was_set(unsigned int bases)
946946
{
947+
struct hrtimer_cpu_base *cpu_base = raw_cpu_ptr(&hrtimer_bases);
947948
cpumask_var_t mask;
948949
int cpu;
949950

950-
if (!hrtimer_hres_active() && !tick_nohz_active)
951+
if (!__hrtimer_hres_active(cpu_base) && !tick_nohz_active)
951952
goto out_timerfd;
952953

953954
if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) {
@@ -958,9 +959,9 @@ void clock_was_set(unsigned int bases)
958959
/* Avoid interrupting CPUs if possible */
959960
cpus_read_lock();
960961
for_each_online_cpu(cpu) {
961-
struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
962962
unsigned long flags;
963963

964+
cpu_base = &per_cpu(hrtimer_bases, cpu);
964965
raw_spin_lock_irqsave(&cpu_base->lock, flags);
965966

966967
if (update_needs_ipi(cpu_base, bases))

0 commit comments

Comments
 (0)