From: Sebastian Andrzej Siewior Subject: Re: [PATCH v6] x86: load FPU registers on return to userland Date: Wed, 13 Feb 2019 16:54:35 +0100 Message-ID: <20190213155435.vnvgzu76ienzvfhv@linutronix.de> References: <20190109114744.10936-1-bigeasy@linutronix.de> <20190130113555.GC18383@zn.tnic> <20190130120647.abbf2cbbpguaz356@linutronix.de> <20190130122713.GG18383@zn.tnic> <20190208131233.5g5guefglq6ik2ow@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Dave Hansen To: Borislav Petkov Return-path: Content-Disposition: inline In-Reply-To: <20190208131233.5g5guefglq6ik2ow@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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