From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH RFC] x86/xsave: prefer eager clearing of state over eager restoring
Date: Thu, 16 Aug 2018 12:27:43 +0100 [thread overview]
Message-ID: <0f98ef13-021e-38f4-4f51-e1ad4c7f14e6@citrix.com> (raw)
In-Reply-To: <5B754BFA02000078001DECD2@prv1-mh.provo.novell.com>
On 16/08/18 11:03, Jan Beulich wrote:
>>>> On 16.08.18 at 11:07, <andrew.cooper3@citrix.com> wrote:
>> On 22/06/2018 11:57, Jan Beulich wrote:
>>> --- a/xen/arch/x86/spec_ctrl.c
>>> +++ b/xen/arch/x86/spec_ctrl.c
>>> @@ -616,7 +616,7 @@ void __init init_speculation_mitigations
>>>
>>> /* Check whether Eager FPU should be enabled by default. */
>>> if ( opt_eager_fpu == -1 )
>>> - opt_eager_fpu = should_use_eager_fpu();
>>> + opt_eager_fpu = !cpu_has_xsave && should_use_eager_fpu();
>> I'd not spotted this the first time round.
>>
>> Intel is very clear that, if you're using xsave, you should be using
>> eager FPU. Therefore, this goes specifically against the advice in the
>> ORM, and the advise we were given during the LazyFPU timeframe.
>>
>> Furthermore we (XenServer) and customers have seen a reliable perf
>> improvement from the LazyFPU security fix, up to 8% in places, for
>> normal VDI and server workloads. As I said during the development the
>> LazyFPU fixes, this is almost certainly down to the fact that all code
>> uses the FPU these days.
> Well - as said in the description, observation in my tests (which are
> not a typical server workload) were that about 50% of the context
> switches were no followed by a (lazy) restore, until the vCPU was
> de-scheduled again.
Counting absolute numbers gives a false impression.
You've got to account for the relative difference in cycles between an
xrstor and servicing #NM (which includes the xrstor you previously skipped).
The 50/50 split you see here is definitely going to result in a net perf
hit because servicing #NM is several orders of magnitude more expensive
than xrstor. (For HVM guests, you've got to add another order of
magnitude for the vmexit).
(At a guess, seeing as its been a little too long since I last did this
kind of stats), you've got to get to somewhere like 85-95% before you're
likely to break even from a performance point of view.
> The change as presented is in fact trying to move to a middle ground,
> in that it doesn't leave stale state in the registers anymore, but
> instead frees the underlying physical ones up for other uses (by
> putting the state components into init state).
>
>> I'm still waiting on a more formal statement from AMD, and don't yet
>> have any perf numbers on their hardware.
>>
>> However, as we will definitely get an extra perf boost from fully
>> deleting the remaining lazy paths (no more clts/stts in the context
>> switch path), my gut feeing is that there is going to have to be some
>> terrible chronic case on AMD for for us to consider not switching to
>> fully eager.
> Yes, eliminating in particular the stts() is certainly going to help
> performance. With ever growing state sizes I'm not convinced though
> that in the long run (and even already with AVX-512, with its well over
> 2k of state) the CR0 access is indeed (going to remain) worse than the
> (perhaps unnecessary) state load.
You've got to consider what code does in practice, and in practice code
is either number crunching heavily (in which case eager is definitely
the best option), or its using vzeroall/upper/etc in which case you're
not loading 2k of state, and eager is still the better option.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-08-16 11:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 10:57 [PATCH RFC] x86/xsave: prefer eager clearing of state over eager restoring Jan Beulich
2018-08-16 7:58 ` Ping: " Jan Beulich
2018-08-16 9:07 ` Andrew Cooper
2018-08-16 9:12 ` Andrew Cooper
2018-08-16 10:03 ` Jan Beulich
2018-08-16 11:27 ` Andrew Cooper [this message]
2018-08-16 11:40 ` Jan Beulich
2018-08-21 10:10 ` Wei Liu
2018-08-21 11:21 ` Jan Beulich
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=0f98ef13-021e-38f4-4f51-e1ad4c7f14e6@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).