Skip to content

Commit

Permalink
hrtimer: Use raw_cpu_ptr() in clock_was_set()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KAGA-KOKO committed Aug 12, 2021
1 parent 1e7f7fb commit 9482fd7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/time/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,11 @@ static bool update_needs_ipi(struct hrtimer_cpu_base *cpu_base,
*/
void clock_was_set(unsigned int bases)
{
struct hrtimer_cpu_base *cpu_base = raw_cpu_ptr(&hrtimer_bases);
cpumask_var_t mask;
int cpu;

if (!hrtimer_hres_active() && !tick_nohz_active)
if (!__hrtimer_hres_active(cpu_base) && !tick_nohz_active)
goto out_timerfd;

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

cpu_base = &per_cpu(hrtimer_bases, cpu);
raw_spin_lock_irqsave(&cpu_base->lock, flags);

if (update_needs_ipi(cpu_base, bases))
Expand Down

0 comments on commit 9482fd7

Please sign in to comment.