FP emulator patch
Quoted 6 lines
Quoted 2 lines
if (current->used_math) { /* Using the FPU again.*/
Quoted 2 lines
lazy_fpu_switch(last_task_used_math); } else { /* First time FPU user.*/
Quoted 10 lines
Quoted 6 lines
init_fpu(); current->used_math = 1; } last_task_used_math = current;Clearly the second path is logically the correct one.
Not really. See below.
Quoted 1 line
BTW, do I see another bug here in
do_cpu()? It seems that before we
call
Quoted 8 lines
Quoted 1 line
init_fpu(), we should checklast_task_used_math. If it is not NULL, weshould
Quoted 1 line
save the FP state to the
last_task_used_math. Hmm, strange ...Strange indeed. And note that if the code were correct, your surmise about the
init_fpu()path being "logically the correct" one would no longer be true - we'd be saving the FPU state of the current process for no good reason.
And note further that, by forcing current->used_math to zero, the old code was in fact driving the signal handler needlessly into the broken code...
Kevin K.
Quoted 22 lines · Kevin D. Kissell
Quoted 7 lines
Quoted 3 lines
if (current->used_math) { /* Using the FPU again.*/
Quoted 2 lines
lazy_fpu_switch(last_task_used_math); } else { /* First time FPU user.*/
Quoted 10 lines
Quoted 6 lines
init_fpu(); current->used_math = 1; } last_task_used_math = current;Clearly the second path is logically the correct one.
Not really. See below.
Quoted 1 line
BTW, do I see another bug here in
do_cpu()? It seems that before wecall
Quoted 4 lines
Quoted 1 line
init_fpu(), we should checklast_task_used_math. If it is not NULL, weshould
Quoted 1 line
save the FP state to the
last_task_used_math. Hmm, strange ...
Quoted 9 lines
Quoted 4 lines
Strange indeed. And note that if the code were correct, your surmise about the
init_fpu()path being "logically the correct" one would no longer be true - we'd be saving the FPU state of the current process for no good reason.And note further that, by forcing
current->used_mathto zero, the old code was in fact driving the signal handler needlessly into the broken code...
By not clearing current->used_math bit, you are in fact restoring an FPU context unnecessarily.
Jun
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Strange indeed. And note that if the code were correct, your surmise about the
init_fpu()path being "logically the correct" one would no longer be true - we'd be saving the FPU state of the current process for no good reason.
Quoted 7 lines
Quoted 4 lines
And note further that, by forcing
current->used_mathto zero, the old code was in fact driving the signal handler needlessly into the broken code...By not clearing
current->used_mathbit, you are in fact restoring an FPU context unnecessarily.
And by clearing it, you are destroying an FPU context unnecessarily. I'll take the overhead, thanks! ;-) Seriously, if that optimization is really that important, let's find some other mechanism for communicating to do_cpu() the fact that we're doing a signal.
Regards,
Kevin K.