2.6.0-test4: bug WRT lazy FPU switching and CONFIG_PREEMPT
A message that is not in the archive (sent off-list or not yet received): [email protected]
Claus-Justus Heine wrote:
[snip]
Quoted 1 line
diff -u --recursive --new-file
linux-2.6.0-test4/include/asm-i386/i387.hlinux-2.6.0-test4-mine/include/asm-i386/i387.h
[snip]
include/asm-i386/i387.h 2003-08-31 15:39:04.000000000 +0200 line 33
Quoted 8 lines
include/asm-i386/i387.h 2003-08-31 15:39:04.000000000 +0200 renamed from include/asm-i386/i387.h 2003-07-27 19:06:54.000000000 +0200 +1
-1@@ -30,7 +30,7 @@ static inline void __save_init_fpu( struct task_struct *tsk ) { if ( cpu_has_fxsr ) { - asm volatile( "fxsave %0 ; fnclex" + asm volatile( "fxsave %0 ; fclex"
I'm sorry, changing "fnclex" to "fclex" was a stupid idea, can lead to deadlocks. So that patch should have looked like this:
#########################################################################################################################
arch/i386/kernel/traps.c 2003-08-31 15:35:49.000000000 +0200 renamed from arch/i386/kernel/traps.c 2003-08-31 15:22:42.000000000 +0200 +8 -2
@@ -605,7 +605,10 @@ * Save the info for the exception handler and clear the error. */ task = current; - save_init_fpu(task); + /* don't trigger an unnecessary math_state_restore() */ + if (task->thread_info->status & TS_USEDFPU) { + save_init_fpu(task); + } task->thread.trap_no = 16; task->thread.error_code = 0; info.si_signo = SIGFPE;
@@ -667,7 +670,10 @@ * Save the info for the exception handler and clear the error. */ task = current; - save_init_fpu(task); + /* don't trigger an unnecessary math_state_restore() */ + if (task->thread_info->status & TS_USEDFPU) { + save_init_fpu(task); + } task->thread.trap_no = 19; task->thread.error_code = 0; info.si_signo = SIGFPE;
include/asm-i386/i387.h 2003-08-31 15:39:04.000000000 +0200 renamed from include/asm-i386/i387.h 2003-07-27 19:06:54.000000000 +0200 +4 -0
@@ -41,8 +41,10 @@ static inline void save_init_fpu( struct task_struct *tsk ) { + preempt_disable(); __save_init_fpu(tsk); stts(); + preempt_enable_no_resched(); }
@@ -53,11 +55,13 @@ #define clear_fpu( tsk ) \ do { \ + preempt_disable(); \ if ((tsk)->thread_info->status & TS_USEDFPU) { \ asm volatile("fwait"); \ (tsk)->thread_info->status &= ~TS_USEDFPU; \ stts(); \ } \ + preempt_enable_no_resched(); \ } while (0) /*
##########################################################################################################################################