mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Rik van Riel <riel@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	X86 ML <x86@kernel.org>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Andrew Lutomirski <luto@kernel.org>,
	pa@zytor.com, Borislav Petkov <bp@suse.de>
Subject: Re: [PATCH 2/9] x86/fpu: Hard-disable lazy fpu mode
Date: Wed, 5 Oct 2016 18:09:50 +0200	[thread overview]
Message-ID: <e273bc2a-7f2c-5bfb-9a91-0521548ff84e@redhat.com> (raw)
In-Reply-To: <CALCETrV9rXJOgdBY9Wyardo0NETA1meCEM_C4-e+SYsZAoUU7A@mail.gmail.com>



On 05/10/2016 17:59, Andy Lutomirski wrote:
> I actually benchmarked the underlying instructions quite a bit on
> Intel.  (Not on AMD, but I doubt the results are very different.)
> Writes to CR0.TS are *incredibly* slow, as are device-not-available
> exceptions.  Keep in mind that, while there's a (slow) CLTS
> instruction, there is no corresponding STTS instruction, so we're left
> with a fully serializing, slowly microcoded move to CR0.  On SVM, I
> think it's worse, because IIRC SVM doesn't have fancy execution
> controls that let MOV to CR0 avoid exiting.

SVM lets you choose whether to trap on TS and MP; update_cr0_intercept
is where KVM does that (the "selective CR0 write" intercept is always
on, while the "CR0 write" intercept is toggled in that function).

> We're talking a couple
> hundred cycles best case for a TS set/clear pair, and thousands of
> cycles if we actually take a fault.
> 
> In contrast, an unconditional XSAVE + XRSTOR was considerably faster.

Did you also do a comparison against FXSAVE/FXRSTOR (on either pre- or
post-SandyBridge processors)?

But yeah, it's possible that the lack of STTS screws the whole plan,
despite the fpu.preload optimization in switch_fpu_prepare.

Paolo

> This leads to the counterintuitive result that, if we switch from task
> A to B and back and task A is heavily using the FPU, then it's faster
> to unconditoinally save and restore the full state both ways than it
> is to set and clear TS so we can avoid it.

  reply	other threads:[~2016-10-05 16:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05  0:34 [PATCH 0/9] x86/fpu: remove lazy FPU mode & various FPU cleanups riel
2016-10-05  0:34 ` [PATCH 1/9] x86/crypto: Remove X86_FEATURE_EAGER_FPU ifdef from the crc32c code riel
2016-10-05  0:40   ` Rik van Riel
2016-10-07  9:43   ` [tip:x86/fpu] x86/crypto, x86/fpu: Remove X86_FEATURE_EAGER_FPU #ifdef " tip-bot for Andy Lutomirski
2016-10-05  0:34 ` [PATCH 2/9] x86/fpu: Hard-disable lazy fpu mode riel
2016-10-05  7:14   ` Paolo Bonzini
2016-10-05 13:57     ` Rik van Riel
2016-10-05 14:03       ` Paolo Bonzini
2016-10-05 15:59         ` Andy Lutomirski
2016-10-05 16:09           ` Paolo Bonzini [this message]
2016-10-07  9:43   ` [tip:x86/fpu] x86/fpu: Hard-disable lazy FPU mode tip-bot for Andy Lutomirski
2016-10-05  0:34 ` [PATCH 3/9] x86/fpu: Remove the XFEATURE_MASK_EAGER/LAZY distinction riel
2016-10-07  9:44   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
2016-10-05  0:34 ` [PATCH 4/9] x86/fpu: Remove use_eager_fpu() riel
2016-10-07  9:44   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
2016-10-05  0:34 ` [PATCH 5/9] x86/fpu: remove fpu.counter riel
2016-10-05  2:07   ` Andy Lutomirski
2016-10-07  9:45   ` [tip:x86/fpu] x86/fpu: Remove struct fpu::counter tip-bot for Rik van Riel
2016-10-05  0:34 ` [PATCH 6/9] x86/fpu,kvm: remove kvm vcpu->fpu_counter riel
2016-10-07  9:45   ` [tip:x86/fpu] x86/fpu, kvm: Remove KVM vcpu->fpu_counter tip-bot for Rik van Riel
2016-10-05  0:34 ` [PATCH 7/9] x86/fpu: rename lazy restore functions to "register state valid" riel
2016-10-05  2:09   ` Andy Lutomirski
2016-10-07  9:46   ` [tip:x86/fpu] x86/fpu: Rename " tip-bot for Rik van Riel
2016-10-05  0:34 ` [PATCH 8/9] x86/fpu: remove __fpregs_(de)activate riel
2016-10-05  2:10   ` Andy Lutomirski
2016-10-07  9:46   ` [tip:x86/fpu] x86/fpu: Remove __fpregs_(de)activate() tip-bot for Rik van Riel
2016-10-05  0:34 ` [PATCH 9/9] x86/fpu: split old & new fpu code paths riel
2016-10-07  9:47   ` [tip:x86/fpu] x86/fpu: Split old & new FPU " tip-bot for Rik van Riel

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=e273bc2a-7f2c-5bfb-9a91-0521548ff84e@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pa@zytor.com \
    --cc=riel@redhat.com \
    --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

all inboxes | Powered by JetHome®