From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbbEHVfS (ORCPT ); Fri, 8 May 2015 17:35:18 -0400 Received: from mga09.intel.com ([134.134.136.24]:47150 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932277AbbEHVe4 (ORCPT ); Fri, 8 May 2015 17:34:56 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,393,1427785200"; d="scan'208";a="726206277" From: "Fenghua Yu" To: "H. Peter Anvin" , "Ingo Molnar" , "Thomas Gleixner" , "Dave Hansen" , "Asit K Mallick" , "Glenn Williamson" Cc: "linux-kernel" , "x86" , "Fenghua Yu" Subject: [PATCH v3 Bugfix 5/6] x86/xsaves: Keep xstate_bv in init_xstate_buf header as zero for init optimimization Date: Fri, 8 May 2015 14:31:04 -0700 Message-Id: <1431120665-36841-6-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1431120665-36841-1-git-send-email-fenghua.yu@intel.com> References: <1431120665-36841-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu Keep xstate_bv in init_xstate_buf header as zero for init optimization. This is important for init optimization that is implemented in processor. If a bit corresponding to an xstate in xstate_bv is 0, it means the xstate is in init status and will not be read from memory to the processor during xrestor* instruction. This largely impacts context switch performance. Signed-off-by: Fenghua Yu Reviewed-by: Dave Hansen --- arch/x86/kernel/xsave.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c index 4217bec..547f293 100644 --- a/arch/x86/kernel/xsave.c +++ b/arch/x86/kernel/xsave.c @@ -545,6 +545,12 @@ static void __init setup_init_fpu_buf(void) */ init_xstate_buf = alloc_bootmem_align(kernel_xstate_size, __alignof__(struct xsave_struct)); + + /* + * Make sure xstate_bv is zero to allow init optimization work. + */ + init_xstate_buf->xsave_hdr.xstate_bv = 0; + fx_finit(&init_xstate_buf->i387); if (!cpu_has_xsave) @@ -552,11 +558,9 @@ static void __init setup_init_fpu_buf(void) setup_xstate_features(); - if (cpu_has_xsaves) { + if (cpu_has_xsaves) init_xstate_buf->xsave_hdr.xcomp_bv = (u64)1 << 63 | pcntxt_mask; - init_xstate_buf->xsave_hdr.xstate_bv = pcntxt_mask; - } /* * Init all the features state with header_bv being 0x0 -- 1.8.1.2