Re: [PATCH v6] x86: load FPU registers on return to userland
From: Sebastian Andrzej Siewior
Date: Wed Feb 13 2019 - 10:54:45 EST
On 2019-02-08 14:12:33 [+0100], To Borislav Petkov wrote:
> Then we have lat_sig [0]. Without the series 64bit:
> |Signal handler overhead: 2.6839 microseconds
> |Signal handler overhead: 2.6996 microseconds
> |Signal handler overhead: 2.6821 microseconds
>
> with the series:
> |Signal handler overhead: 3.2976 microseconds
> |Signal handler overhead: 3.3033 microseconds
> |Signal handler overhead: 3.2980 microseconds
Did a patch-by-patch run (64bit only, server preemption model, output in
us ("commit")):
2.368 ("Linux 5.0-rc5")
2.603 ("x86/fpu: Always store the registers in copy_fpstate_to_sigframe()")
copy_fpstate_to_sigframe() stores to thread's FPU area and then copies
user stack area.
2.668 ("x86/fpu: Prepare copy_fpstate_to_sigframe() for TIF_NEED_FPU_LOAD")
this should be noise since preempt_disable/enable is a nop -
test_thread_flag() isn't.
2.701 ("x86/fpu: Inline copy_user_to_fpregs_zeroing()")
This pops up somehow but is simply code movement.
3.474 ("x86/fpu: Let __fpu__restore_sig() restore the !32bit+fxsr frame from kernel memory")
This stands out. There a kmalloc() + saving to kernel memory + copy
instead a direct save to kernel stack.
2.928 ("x86/fpu: Defer FPU state load until return to userspace")
The kmalloc() has been removed. Just "copy-to-kernel-memory" and
copy_to_user() remained.
So this looks like 0.3us for the save-copy + 0.3us for copy-restore. The
numbers for the preempt/low-lat-desktop have the same two spikes and
drop at the end.
Sebastian