diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2007-11-14 17:00:41 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-11-26 09:42:29 -0800 |
commit | 778b656e0e63efe0437fe337b9556bec73dc2f9d (patch) | |
tree | 351f3a7a7dd9ce211163613151a5195fcb9d1989 /arch/i386 | |
parent | e35595f90a819298c9d518a2a84007a4d5a797fe (diff) |
x86: disable preemption in delay_tsc()
patch 35d5d08a085c56f153458c3f5d8ce24123617faf in mainline.
Marin Mitov points out that delay_tsc() can misbehave if it is preempted and
rescheduled on a different CPU which has a skewed TSC. Fix it by disabling
preemption.
(I assume that the worst-case behaviour here is a stall of 2^32 cycles)
Cc: Andi Kleen <ak@suse.de>
Cc: Marin Mitov <mitov@issp.bas.bg>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/lib/delay.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/i386/lib/delay.c b/arch/i386/lib/delay.c index f6edb11364d..66595edcd7b 100644 --- a/arch/i386/lib/delay.c +++ b/arch/i386/lib/delay.c @@ -12,6 +12,7 @@ #include <linux/module.h> #include <linux/sched.h> +#include <linux/preempt.h> #include <linux/delay.h> #include <asm/processor.h> @@ -42,11 +43,13 @@ static void delay_tsc(unsigned long loops) { unsigned long bclock, now; + preempt_disable(); /* TSC's are per-cpu */ rdtscl(bclock); do { rep_nop(); rdtscl(now); } while ((now-bclock) < loops); + preempt_enable(); } /* |