From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932818AbcBIQMM (ORCPT ); Tue, 9 Feb 2016 11:12:12 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38565 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932710AbcBIQMI (ORCPT ); Tue, 9 Feb 2016 11:12:08 -0500 Date: Tue, 9 Feb 2016 08:10:55 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, luto@amacapital.net, bp@alien8.de, fenghua.yu@intel.com, oleg@redhat.com, tglx@linutronix.de, luto@kernel.org, sai.praneeth.prakhya@intel.com, riel@redhat.com, torvalds@linux-foundation.org, dave.hansen@linux.intel.com, mingo@kernel.org, yu-cheng.yu@intel.com, peterz@infradead.org, quentin.casasnovas@oracle.com Reply-To: oleg@redhat.com, fenghua.yu@intel.com, tglx@linutronix.de, hpa@zytor.com, luto@amacapital.net, linux-kernel@vger.kernel.org, bp@alien8.de, quentin.casasnovas@oracle.com, riel@redhat.com, sai.praneeth.prakhya@intel.com, luto@kernel.org, yu-cheng.yu@intel.com, peterz@infradead.org, dave.hansen@linux.intel.com, mingo@kernel.org, torvalds@linux-foundation.org In-Reply-To: <3eb5a63a9c5c84077b2677a7dfe684eef96fe59e.1453675014.git.luto@kernel.org> References: <3eb5a63a9c5c84077b2677a7dfe684eef96fe59e.1453675014.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Fold fpu_copy() into fpu__copy() Git-Commit-ID: a20d7297045f7fdcd676c15243192eb0e95a4306 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: a20d7297045f7fdcd676c15243192eb0e95a4306 Gitweb: http://git.kernel.org/tip/a20d7297045f7fdcd676c15243192eb0e95a4306 Author: Andy Lutomirski AuthorDate: Sun, 24 Jan 2016 14:38:08 -0800 Committer: Ingo Molnar CommitDate: Tue, 9 Feb 2016 15:42:55 +0100 x86/fpu: Fold fpu_copy() into fpu__copy() Splitting it into two functions needlessly obfuscated the code. While we're at it, improve the comment slightly. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Rik van Riel Cc: Sai Praneeth Prakhya Cc: Thomas Gleixner Cc: yu-cheng yu Link: http://lkml.kernel.org/r/3eb5a63a9c5c84077b2677a7dfe684eef96fe59e.1453675014.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 7a9244d..299b58b 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -231,14 +231,15 @@ void fpstate_init(union fpregs_state *state) } EXPORT_SYMBOL_GPL(fpstate_init); -/* - * Copy the current task's FPU state to a new task's FPU context. - * - * In both the 'eager' and the 'lazy' case we save hardware registers - * directly to the destination buffer. - */ -static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu) +int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) { + dst_fpu->counter = 0; + dst_fpu->fpregs_active = 0; + dst_fpu->last_cpu = -1; + + if (!src_fpu->fpstate_active || !cpu_has_fpu) + return 0; + WARN_ON_FPU(src_fpu != ¤t->thread.fpu); /* @@ -251,10 +252,9 @@ static void 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. - * - * If the FPU context got destroyed in the process (FNSAVE - * done on old CPUs) then copy it back into the source - * context and mark the current task for lazy restore. + * In lazy mode, if the FPU context isn't loaded into + * fpregs, CR0.TS will be set and do_device_not_available + * will load the FPU context. * * We have to do all this with preemption disabled, * mostly because of the FNSAVE case, because in that @@ -274,16 +274,6 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu) fpregs_deactivate(src_fpu); } preempt_enable(); -} - -int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) -{ - dst_fpu->counter = 0; - dst_fpu->fpregs_active = 0; - dst_fpu->last_cpu = -1; - - if (src_fpu->fpstate_active && cpu_has_fpu) - fpu_copy(dst_fpu, src_fpu); return 0; }