Commit-ID:  3896c329df8092661dac80f55a8c3f60136fd61a
Gitweb:     http://git.kernel.org/tip/3896c329df8092661dac80f55a8c3f60136fd61a
Author:     Peter Zijlstra <pet...@infradead.org>
AuthorDate: Tue, 24 Jun 2014 14:48:19 +0200
Committer:  Ingo Molnar <mi...@kernel.org>
CommitDate: Wed, 2 Jul 2014 08:33:47 +0200

x86, tsc: Fix cpufreq lockup

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 <registosi...@hotmail.com>
Tested-by: Mauro <registosi...@hotmail.com>
Fixes: 20d1c86a5776 ("sched/clock, x86: Rewrite cyc2ns() to avoid the need to 
disable IRQs")
Cc: <stable@vger.kernel.org>
Cc: "Rafael J. Wysocki" <r...@rjwysocki.net>
Cc: Viresh Kumar <viresh.ku...@linaro.org>
Cc: Bin Gao <bin....@intel.com>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Mika Westerberg <mika.westerb...@linux.intel.com>
Cc: Paul Gortmaker <paul.gortma...@windriver.com>
Cc: Stefani Seibold <stef...@seibold.net>
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Peter Zijlstra <pet...@infradead.org>
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 57e5ce1..ea03031 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -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;
 }
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to