linux/arch/x86
Linus Torvalds 34ddc81a23 i387: re-introduce FPU state preloading at context switch time
After all the FPU state cleanups and finally finding the problem that
caused all our FPU save/restore problems, this re-introduces the
preloading of FPU state that was removed in commit b3b0870ef3 ("i387:
do not preload FPU state at task switch time").

However, instead of simply reverting the removal, this reimplements
preloading with several fixes, most notably

 - properly abstracted as a true FPU state switch, rather than as
   open-coded save and restore with various hacks.

   In particular, implementing it as a proper FPU state switch allows us
   to optimize the CR0.TS flag accesses: there is no reason to set the
   TS bit only to then almost immediately clear it again.  CR0 accesses
   are quite slow and expensive, don't flip the bit back and forth for
   no good reason.

 - Make sure that the same model works for both x86-32 and x86-64, so
   that there are no gratuitous differences between the two due to the
   way they save and restore segment state differently due to
   architectural differences that really don't matter to the FPU state.

 - Avoid exposing the "preload" state to the context switch routines,
   and in particular allow the concept of lazy state restore: if nothing
   else has used the FPU in the meantime, and the process is still on
   the same CPU, we can avoid restoring state from memory entirely, just
   re-expose the state that is still in the FPU unit.

   That optimized lazy restore isn't actually implemented here, but the
   infrastructure is set up for it.  Of course, older CPU's that use
   'fnsave' to save the state cannot take advantage of this, since the
   state saving also trashes the state.

In other words, there is now an actual _design_ to the FPU state saving,
rather than just random historical baggage.  Hopefully it's easier to
follow as a result.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-02-18 14:03:48 -08:00
..
boot x86/boot-image: Don't leak phdrs in arch/x86/boot/compressed/misc.c::Parse_elf() 2012-01-26 11:30:29 +01:00
configs
crypto
ia32 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit 2012-01-17 16:41:31 -08:00
include/asm i387: re-introduce FPU state preloading at context switch time 2012-02-18 14:03:48 -08:00
kernel i387: re-introduce FPU state preloading at context switch time 2012-02-18 14:03:48 -08:00
kvm i387: move TS_USEDFPU flag from thread_info to task_struct 2012-02-18 10:19:41 -08:00
lguest lguest: Make sure interrupt is allocated ok by lguest_setup_irq 2012-01-12 15:44:47 +10:30
lib Merge branches 'sched-urgent-for-linus', 'perf-urgent-for-linus' and 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-01-19 14:53:06 -08:00
math-emu
mm Merge branches 'core-urgent-for-linus', 'perf-urgent-for-linus', 'sched-urgent-for-linus' and 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-02-02 11:11:13 -08:00
net net: bpf_jit: fix divide by 0 generation 2012-01-18 16:04:26 -05:00
oprofile
pci xen pvhvm: do not remap pirqs onto evtchns if !xen_have_vector_callback 2012-02-03 16:06:27 -05:00
platform x86/uv: Fix uninitialized spinlocks 2012-01-26 10:58:34 +01:00
power
syscalls
tools
um uml: fix compile for x86-64 2012-01-18 19:26:11 -08:00
vdso
video
xen xen/smp: Fix CPU online/offline bug triggering a BUG: scheduling while atomic. 2012-02-03 16:05:42 -05:00
.gitignore x86/kprobes: Add arch/x86/tools/insn_sanity to .gitignore 2012-01-16 08:21:59 +01:00
Kbuild
Kconfig x86/numachip: Drop unnecessary conflict with EDAC 2012-01-26 11:03:03 +01:00
Kconfig.cpu mm,x86,um: move CMPXCHG_DOUBLE config option 2012-01-12 20:13:03 -08:00
Kconfig.debug Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-01-11 19:13:40 -08:00
Makefile
Makefile.um
Makefile_32.cpu