From: Scott Wood <scottwood@freescale.com>
To: Alexander Graf <agraf@suse.de>
Cc: Caraman Mihai Claudiu-B02008 <B02008@freescale.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>
Subject: Re: [PATCH 3/6] KVM: PPC: Book3E: Increase FPU laziness
Date: Wed, 3 Jul 2013 12:17:34 -0500 [thread overview]
Message-ID: <1372871854.8183.132@snotra> (raw)
In-Reply-To: <23C56B31-5145-481E-9877-F1878F66959D@suse.de> (from agraf@suse.de on Wed Jul 3 11:59:45 2013)
On 07/03/2013 11:59:45 AM, Alexander Graf wrote:
>=20
> On 03.07.2013, at 17:41, Caraman Mihai Claudiu-B02008 wrote:
>=20
> >>>>> Increase FPU laziness by calling kvmppc_load_guest_fp() just =20
> before
> >>>>> returning to guest instead of each sched in. Without this =20
> improvement
> >>>>> an interrupt may also claim floting point corrupting guest =20
> state.
> >>>>
> >>>> Not sure I follow. Could you please describe exactly what's =20
> happening?
> >>>
> >>> This was already discussed on the list, I will forward you the =20
> thread.
> >>
> >> The only thing I've seen in that thread was some pathetic =20
> theoretical
> >> case where an interrupt handler would enable fp and clobber state
> >> carelessly. That's not something I'm worried about.
> >
> > Neither me though I don't find it pathetic. Please refer it to =20
> Scott.
>=20
> If from Linux's point of view we look like a user space program with =20
> active floating point registers, we don't have to worry about this =20
> case. Kernel code that would clobber that fp state would clobber =20
> random user space's fp state too.
This patch makes it closer to how it works with a user space program. =20
Or rather, it reduces the time window when we don't (and can't) act =20
like a normal userspace program -- and ensures that we have interrupts =20
disabled during that window. An interrupt can't randomly clobber FP =20
state; it has to call enable_kernel_fp() just like KVM does. =20
enable_kernel_fp() clears the userspace MSR_FP to ensure that the state =20
it saves gets restored before userspace uses it again, but that won't =20
have any effect on guest execution (especially in HV-mode). Thus =20
kvmppc_load_guest_fp() needs to be atomic with guest entry. =20
Conceptually it's like taking an automatic FP unavailable trap when we =20
enter the guest, since we can't be lazy in HV-mode.
> >> I really don't see where this patch improves anything tbh. It =20
> certainly
> >> makes the code flow more awkward.
> >
> > I was pointing you to this: The idea of FPU/AltiVec laziness that =20
> the kernel
> > is struggling to achieve is to reduce the number of store/restore =20
> operations.
> > Without this improvement we restore the unit each time we are sched =20
> it. If an
> > other process take the ownership of the unit (on SMP it's even =20
> worse but don't
> > bother with this) the kernel store the unit state to qemu task. =20
> This can happen
> > multiple times during handle_exit().
> >
> > Do you see it now?
>=20
> Yup. Looks good. The code flow is very hard to follow though - there =20
> are a lot of implicit assumptions that don't get documented anywhere. =20
> For example the fact that we rely on giveup_fpu() to remove MSR_FP =20
> from our thread.
That's not new to this patch...
-Scott=
next prev parent reply other threads:[~2013-07-03 17:17 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 12:42 [PATCH 0/6] KVM: PPC: Book3E: AltiVec support Mihai Caraman
2013-07-03 12:42 ` [PATCH 1/6] KVM: PPC: Book3E: Use common defines for SPE/FP/AltiVec int numbers Mihai Caraman
2013-07-03 12:42 ` [PATCH 2/6] KVM: PPC: Book3E: Refactor SPE/FP exit handling Mihai Caraman
2013-07-03 13:30 ` Alexander Graf
2013-07-03 13:53 ` Caraman Mihai Claudiu-B02008
2013-07-03 15:13 ` Alexander Graf
2013-07-03 18:28 ` Scott Wood
2013-07-03 18:42 ` Alexander Graf
2013-07-03 18:44 ` Scott Wood
2013-07-03 12:42 ` [PATCH 3/6] KVM: PPC: Book3E: Increase FPU laziness Mihai Caraman
2013-07-03 13:45 ` Alexander Graf
2013-07-03 13:55 ` Caraman Mihai Claudiu-B02008
2013-07-03 15:11 ` Alexander Graf
2013-07-03 15:41 ` Caraman Mihai Claudiu-B02008
2013-07-03 16:59 ` Alexander Graf
2013-07-03 17:17 ` Scott Wood [this message]
2013-07-03 17:22 ` Alexander Graf
2013-07-03 17:07 ` Scott Wood
2013-07-03 17:08 ` Alexander Graf
2013-07-03 17:18 ` Scott Wood
2013-07-03 17:23 ` Alexander Graf
2013-07-03 17:44 ` Scott Wood
2013-07-03 18:39 ` Alexander Graf
2013-07-03 18:37 ` Scott Wood
2013-07-03 18:40 ` Alexander Graf
2013-07-04 6:50 ` Caraman Mihai Claudiu-B02008
2013-07-03 12:42 ` [PATCH 4/6] KVM: PPC: Book3E: Add AltiVec support Mihai Caraman
2013-07-03 15:17 ` Alexander Graf
2013-07-03 16:09 ` Caraman Mihai Claudiu-B02008
2013-07-03 16:43 ` Alexander Graf
2013-07-03 16:49 ` Caraman Mihai Claudiu-B02008
2013-07-03 17:07 ` Alexander Graf
2013-07-03 18:36 ` Scott Wood
2013-07-03 18:45 ` Alexander Graf
2013-07-03 18:38 ` Scott Wood
2013-07-03 12:42 ` [PATCH 5/6] KVM: PPC: Book3E: Add ONE_REG " Mihai Caraman
2013-07-03 12:42 ` [PATCH 6/6] KVM: PPC: Book3E: Enable e6500 core Mihai Caraman
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=1372871854.8183.132@snotra \
--to=scottwood@freescale.com \
--cc=B02008@freescale.com \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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).