Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161689AbbEER7P (ORCPT ); Tue, 5 May 2015 13:59:15 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:33325 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031760AbbEER7G (ORCPT ); Tue, 5 May 2015 13:59:06 -0400 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H. Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner Subject: [PATCH 168/208] x86/fpu: Simplify fpstate_sanitize_xstate() calls Date: Tue, 5 May 2015 19:57:52 +0200 Message-Id: <1430848712-28064-8-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430848712-28064-1-git-send-email-mingo@kernel.org> References: <1430848712-28064-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2870 Lines: 82 Remove the extra layer of __fpstate_sanitize_xstate(): if (!use_xsaveopt()) return; __fpstate_sanitize_xstate(tsk); and move the check for use_xsaveopt() into fpstate_sanitize_xstate(). In general we optimize for the presence of CPU features, not for the absence of them. Furthermore there's little point in this inlining, as the call sites are not super hot code paths. Doing this uninlining shrinks the code a bit: text data bss dec hex filename 14108751 2573624 1634304 18316679 1177d87 vmlinux.before 14108627 2573624 1634304 18316555 1177d0b vmlinux.after Also remove a pointless '!fx' check from fpstate_sanitize_xstate(). Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/include/asm/fpu/internal.h | 9 +-------- arch/x86/kernel/fpu/xstate.c | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 6b6fa46037f8..88fec3f108de 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -139,14 +139,7 @@ static inline void fx_finit(struct i387_fxsave_struct *fx) fx->mxcsr = MXCSR_DEFAULT; } -extern void __fpstate_sanitize_xstate(struct task_struct *); - -static inline void fpstate_sanitize_xstate(struct task_struct *tsk) -{ - if (!use_xsaveopt()) - return; - __fpstate_sanitize_xstate(tsk); -} +extern void fpstate_sanitize_xstate(struct task_struct *); #define user_insn(insn, output, input...) \ ({ \ diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index fc2ff1239fea..47b9591947e1 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -92,13 +92,13 @@ EXPORT_SYMBOL_GPL(cpu_has_xfeatures); * if the corresponding header bit is zero. This is to ensure that user-space doesn't * see some stale state in the memory layout during signal handling, debugging etc. */ -void __fpstate_sanitize_xstate(struct task_struct *tsk) +void fpstate_sanitize_xstate(struct task_struct *tsk) { struct i387_fxsave_struct *fx = &tsk->thread.fpu.state.fxsave; int feature_bit; u64 xfeatures; - if (!fx) + if (!use_xsaveopt()) return; xfeatures = tsk->thread.fpu.state.xsave.header.xfeatures; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/