|
From: NIIBE Y. <gn...@m1...> - 2001-08-07 23:56:05
|
Let me explain more. Most easy way to support FPU in kernel is (re)define the context, and save/restore all FPU registers at context switch and exception. But it's waste of time, you know. We've implemented lazy FPU save/restore. As many applications don't use FPU, we could save time not to save/restore FPU registers all the time. We don't save FPU registers for exception handling, interrupts or system call. We only save FPU registersat context switch if it's really used. And we delay the restore of FPU registers until it actually used (by exception). The FPU registers are saved at the context switch, and will be restored on demand. I think that this feature makes sence. I don't think we should remove this. Questionable feature is the one of using init_task as "kernel task" FPU usage. When I've implemented it, I thought it is good idea... When kernel uses FPU, we use init_task to save/restore FPU registers, as if it is user process. We also uses stack to save/restore FPU registers, when kernel goes to handle exception. Greg Banks wrote: > So, if we needed the FPU in the kernel, we'd have to switch FPU state > on context switch for kernel threads as well as user threads? Not exactly. Instead, we should avoid to do that for kernel threads. Currently, we have special code at context switch: if it's not init_task we save FPU register into task structure. I don't know how we can extend... Could be implemented as "it's not kernel threads." The kernel FPU save/resotre is done in the code of fpu.c, when the kernel is got exception or kernel goes back to user mode. Perhaps, we need to implement something to share FPU registers among kernel threads. > > I think that we can assume GCC provide some way of not using > > FPU for division. > > That's what -m4-nofpu is for, right? Yes, that is my intention. However, I'm sorry that it seems it's my misunderstanding. I'm now re-examining our patch of GCC, and it seems for me that -m4-nofpu is special kind of SH-3, not SH-4 (for me it's amazing :-(). I think that we should provide our own switch to disable FPU division. Kaz once has such a patch implemented, perhaps I'll take it. -- |