alpha: lazy FPU switching
On each context switch we save the FPU registers on stack
of old process and restore FPU registers from the stack of new one.
That allows us to avoid doing that each time we enter/leave the
kernel mode; however, that can get suboptimal in some cases.
For one thing, we don't need to bother saving anything
for kernel threads. For another, if between entering and leaving
the kernel a thread gives CPU up more than once, it will do
useless work, saving the same values every time, only to discard
the saved copy as soon as it returns from switch_to().
Alternative solution:
* move the array we save into from switch_stack to thread_info
* have a (thread-synchronous) flag set when we save them
* do *NOT* save/restore them in do_switch_stack()/undo_switch_stack().
* restore on the exit to user mode (and clear the flag) if the flag had
been set.
* on context switch, entry to fork()/clone()/vfork() and on entry into
straced syscall save (and set the flag) if the flag had not been set.
* have copy_thread() set the flag for child, so they would be restored
once the child returns to userland.
* save (again, conditionally and setting the flag) before do_signal(),
use the saved data in setup_sigcontext()
* have restore_sigcontext() set the flag and copy from sigframe to
save area.
* teach ptrace to look for FPU registers in thread_info instead of
switch_stack.
* teach isolated accesses to FPU registers (rdfpcr, wrfpcr, etc.)
to check the flag (under preempt_disable()) and work with the save area
if it's been set.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
10 files changed