From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030509AbdIZIld (ORCPT ); Tue, 26 Sep 2017 04:41:33 -0400 Received: from terminus.zytor.com ([65.50.211.136]:49587 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030404AbdIZIjz (ORCPT ); Tue, 26 Sep 2017 04:39:55 -0400 Date: Tue, 26 Sep 2017 01:33:15 -0700 From: tip-bot for Ingo Molnar Message-ID: Cc: torvalds@linux-foundation.org, fenghua.yu@intel.com, ebiggers3@gmail.com, yu-cheng.yu@intel.com, peterz@infradead.org, akpm@linux-foundation.org, mingo@kernel.org, oleg@redhat.com, linux-kernel@vger.kernel.org, bp@alien8.de, tglx@linutronix.de, hpa@zytor.com, riel@redhat.com, dave.hansen@linux.intel.com, luto@amacapital.net Reply-To: peterz@infradead.org, yu-cheng.yu@intel.com, ebiggers3@gmail.com, torvalds@linux-foundation.org, fenghua.yu@intel.com, hpa@zytor.com, dave.hansen@linux.intel.com, luto@amacapital.net, riel@redhat.com, bp@alien8.de, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, oleg@redhat.com, akpm@linux-foundation.org In-Reply-To: <20170923130016.21448-32-mingo@kernel.org> References: <20170923130016.21448-32-mingo@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Simplify and speed up fpu__copy() Git-Commit-ID: e10078eba69859359ce8644dd423b4132a6a8913 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e10078eba69859359ce8644dd423b4132a6a8913 Gitweb: http://git.kernel.org/tip/e10078eba69859359ce8644dd423b4132a6a8913 Author: Ingo Molnar AuthorDate: Sat, 23 Sep 2017 15:00:14 +0200 Committer: Ingo Molnar CommitDate: Tue, 26 Sep 2017 09:43:44 +0200 x86/fpu: Simplify and speed up fpu__copy() fpu__copy() has a preempt_disable()/enable() pair, which it had to do to be able to atomically unlazy the current task when doing an FNSAVE. But we don't unlazy tasks anymore, we always do direct saves/restores of FPU context. So remove both the unnecessary critical section, and update the comments. Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Eric Biggers Cc: Fenghua Yu Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: Yu-cheng Yu Link: http://lkml.kernel.org/r/20170923130016.21448-32-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 77668d9..52122dd 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -206,22 +206,13 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) * Save current FPU registers directly into the child * FPU context, without any memory-to-memory copying. * - * We have to do all this with preemption disabled, - * mostly because of the FNSAVE case, because in that - * case we must not allow preemption in the window - * between the FNSAVE and us marking the context lazy. - * - * It shouldn't be an issue as even FNSAVE is plenty - * fast in terms of critical section length. + * ( The function 'fails' in the FNSAVE case, which destroys + * register contents so we have to copy them back. ) */ - preempt_disable(); if (!copy_fpregs_to_fpstate(dst_fpu)) { - memcpy(&src_fpu->state, &dst_fpu->state, - fpu_kernel_xstate_size); - + memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); copy_kernel_to_fpregs(&src_fpu->state); } - preempt_enable(); trace_x86_fpu_copy_src(src_fpu); trace_x86_fpu_copy_dst(dst_fpu);