From: "Fenghua Yu" <fenghua.yu@intel.com>
To: "H. Peter Anvin" <hpa@linux.intel.com>,
"Ingo Molnar" <mingo@elte.hu>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Dave Hansen" <dave.hansen@intel.com>,
"Asit K Mallick" <asit.k.mallick@intel.com>,
"Glenn Williamson" <glenn.p.williamson@intel.com>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
"x86" <x86@kernel.org>, "Fenghua Yu" <fenghua.yu@intel.com>
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 [thread overview]
Message-ID: <1431120665-36841-6-git-send-email-fenghua.yu@intel.com> (raw)
In-Reply-To: <1431120665-36841-1-git-send-email-fenghua.yu@intel.com>
From: Fenghua Yu <fenghua.yu@intel.com>
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 <fenghua.yu@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
---
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
next prev parent reply other threads:[~2015-05-08 21:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 21:30 [PATCH v3 Bugfix 0/6] xstate/fpu bug fixes Fenghua Yu
2015-05-08 21:31 ` [PATCH v3 Bugfix 1/6] x86/xsave.c: Fix xstate offsets and sizes enumeration Fenghua Yu
2015-05-08 21:31 ` [PATCH v3 Bugfix 2/6] x86/xsaves: Define and use user_xstate_size for xstate size in signal context Fenghua Yu
2015-05-08 21:31 ` [PATCH v3 Bugfix 3/6] x86/xsaves: Rename xstate_size to kernel_xstate_size to explicitly distinguish xstate size in kernel from user space Fenghua Yu
2015-05-08 21:31 ` [PATCH v3 Bugfix 4/6] x86/xsave: Don't add new states in xsave_struct Fenghua Yu
2015-05-08 21:31 ` Fenghua Yu [this message]
2015-05-08 21:31 ` [PATCH v3 Bugfix 6/6] x86/xsave.c: Introduce a new check that allows correct xstates copy from kernel to user directly Fenghua Yu
2015-05-09 6:09 ` [PATCH v3 Bugfix 0/6] xstate/fpu bug fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431120665-36841-6-git-send-email-fenghua.yu@intel.com \
--to=fenghua.yu@intel.com \
--cc=asit.k.mallick@intel.com \
--cc=dave.hansen@intel.com \
--cc=glenn.p.williamson@intel.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome