From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030309AbdIZIgg (ORCPT ); Tue, 26 Sep 2017 04:36:36 -0400 Received: from terminus.zytor.com ([65.50.211.136]:36667 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968119AbdIZIft (ORCPT ); Tue, 26 Sep 2017 04:35:49 -0400 Date: Tue, 26 Sep 2017 01:28:59 -0700 From: tip-bot for Ingo Molnar Message-ID: Cc: torvalds@linux-foundation.org, yu-cheng.yu@intel.com, peterz@infradead.org, hpa@zytor.com, oleg@redhat.com, linux-kernel@vger.kernel.org, bp@alien8.de, ebiggers3@gmail.com, riel@redhat.com, tglx@linutronix.de, mingo@kernel.org, luto@kernel.org, dave.hansen@linux.intel.com, fenghua.yu@intel.com, akpm@linux-foundation.org, luto@amacapital.net Reply-To: riel@redhat.com, tglx@linutronix.de, dave.hansen@linux.intel.com, luto@kernel.org, mingo@kernel.org, luto@amacapital.net, akpm@linux-foundation.org, fenghua.yu@intel.com, hpa@zytor.com, peterz@infradead.org, yu-cheng.yu@intel.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, oleg@redhat.com, ebiggers3@gmail.com, bp@alien8.de In-Reply-To: <20170923130016.21448-20-mingo@kernel.org> References: <20170923130016.21448-20-mingo@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active Git-Commit-ID: 6cf4edbe0526db311a28734609da888fdfcb3604 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: 6cf4edbe0526db311a28734609da888fdfcb3604 Gitweb: http://git.kernel.org/tip/6cf4edbe0526db311a28734609da888fdfcb3604 Author: Ingo Molnar AuthorDate: Sat, 23 Sep 2017 15:00:02 +0200 Committer: Ingo Molnar CommitDate: Sun, 24 Sep 2017 13:04:34 +0200 x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active The fpregs_activate()/fpregs_deactivate() are currently called in such a pattern: if (!fpu->fpregs_active) fpregs_activate(fpu); ... if (fpu->fpregs_active) fpregs_deactivate(fpu); But note that it's actually safe to call them without checking the flag first. This further decouples the fpu->fpregs_active flag from actual FPU logic. Cc: Andrew Morton Cc: Andy Lutomirski 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-20-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/fpu/internal.h | 7 +------ arch/x86/kernel/fpu/core.c | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 7fa676f..42a6016 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -526,8 +526,6 @@ static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu) */ static inline void fpregs_deactivate(struct fpu *fpu) { - WARN_ON_FPU(!fpu->fpregs_active); - fpu->fpregs_active = 0; this_cpu_write(fpu_fpregs_owner_ctx, NULL); trace_x86_fpu_regs_deactivated(fpu); @@ -535,8 +533,6 @@ static inline void fpregs_deactivate(struct fpu *fpu) static inline void fpregs_activate(struct fpu *fpu) { - WARN_ON_FPU(fpu->fpregs_active); - fpu->fpregs_active = 1; this_cpu_write(fpu_fpregs_owner_ctx, fpu); trace_x86_fpu_regs_activated(fpu); @@ -604,8 +600,7 @@ static inline void user_fpu_begin(void) struct fpu *fpu = ¤t->thread.fpu; preempt_disable(); - if (!fpu->fpregs_active) - fpregs_activate(fpu); + fpregs_activate(fpu); preempt_enable(); } diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index eab2446..01a47e9 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -426,8 +426,7 @@ void fpu__drop(struct fpu *fpu) asm volatile("1: fwait\n" "2:\n" _ASM_EXTABLE(1b, 2b)); - if (fpu->fpregs_active) - fpregs_deactivate(fpu); + fpregs_deactivate(fpu); } } else { WARN_ON_FPU(fpu->fpregs_active);