Skip to contentSkip to conversation

FP emulator patch

DISCUSSION Kevin D. Kissell 2 participants 3 messages Aug 16, 2001 MIPS

lore
Share & tools
lore
#0 lore raw
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 check last_task_used_math. If it is not NULL, we

should

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.

#1 lore raw
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 we

call

Quoted 4 lines
Quoted 1 line

init_fpu(), we should check last_task_used_math. If it is not NULL, we

should

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_math to 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

#2 lore raw
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_math to 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.

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.