[PATCH][BUGFIX] Bug in timer_tsc cpufreq callback

From: Pallipadi, Venkatesh
Date: Sat Oct 11 2003 - 14:23:16 EST



Hi,

There is a bug in cpufreq call back funtion in timer_tsc routines,
that can result in system deadlock. The issue is: grabbing the
write_lock on xtime_lock without disabling the interrupts. So,
if we happen to get a timer interrupt while we are in this code,
system will go into a deadlock.

This bug only effects the kernels that have CONFIG_CPU_FREQ enabled.
Attached patch fixes it. Please apply.


Thanks,
-Venkatesh


--- linux-2.6.0-test6/arch/i386/kernel/timers/timer_tsc.c.org
2003-10-10 14:01:02.000000000 -0700
+++ linux-2.6.0-test6/arch/i386/kernel/timers/timer_tsc.c
2003-10-10 14:01:24.000000000 -0700
@@ -321,7 +321,7 @@ time_cpufreq_notifier(struct notifier_bl
{
struct cpufreq_freqs *freq = data;

- write_seqlock(&xtime_lock);
+ write_seqlock_irq(&xtime_lock);
if (!ref_freq) {
ref_freq = freq->old;
loops_per_jiffy_ref =
cpu_data[freq->cpu].loops_per_jiffy;
@@ -342,7 +342,7 @@ time_cpufreq_notifier(struct notifier_bl
}
#endif
}
- write_sequnlock(&xtime_lock);
+ write_sequnlock_irq(&xtime_lock);

return 0;
}

Attachment: tsc-deadlock.patch
Description: tsc-deadlock.patch