Skip to content

Commit

Permalink
x86, tsc: Fix cpufreq lockup
Browse files Browse the repository at this point in the history
Mauro reported that his AMD X2 using the powernow-k8 cpufreq driver
locked up when doing cpu hotplug.

Because we called set_cyc2ns_scale() from the time_cpufreq_notifier()
unconditionally, it gets called multiple times for each freq change,
instead of only the once, when the tsc_khz value actually changes.

Because it gets called more than once, we run out of cyc2ns data slots
and stall, waiting for a free one, but because we're half way offline,
there's no consumers to free slots.

By placing the call inside the condition that actually changes tsc_khz
we avoid superfluous calls and avoid the problem.

Reported-by: Mauro <[email protected]>
Tested-by: Mauro <[email protected]>
Fixes: 20d1c86 ("sched/clock, x86: Rewrite cyc2ns() to avoid the need to disable IRQs")
Cc: <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Bin Gao <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Mika Westerberg <[email protected]>
Cc: Paul Gortmaker <[email protected]>
Cc: Stefani Seibold <[email protected]>
Cc: [email protected]
Signed-off-by: Peter Zijlstra <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jul 2, 2014
1 parent 16874b2 commit 3896c32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kernel/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,9 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);
if (!(freq->flags & CPUFREQ_CONST_LOOPS))
mark_tsc_unstable("cpufreq changes");
}

set_cyc2ns_scale(tsc_khz, freq->cpu);
set_cyc2ns_scale(tsc_khz, freq->cpu);
}

return 0;
}
Expand Down

0 comments on commit 3896c32

Please sign in to comment.