Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace
From: Rik van Riel
Date: Mon Oct 03 2016 - 22:48:14 EST
On Mon, 2016-10-03 at 19:09 -0700, Andy Lutomirski wrote:
> > Having two separate status booleans for "registers valid"
> > and "memory valid" may make more sense.
> I have no problem with the concept of "owner_ctx", and I think it's a
> perfectly reasonable data structure.ÂÂMy problem with it is that it's
> subtle and knowledge of it is spread all over the place.ÂÂJust going
> with "registers valid" in a variable won't work, I think, because
> there's nowhere to put it.ÂÂWe need to be able to delete a struct fpu
> while that struct fpu might have a valid copy in a different cpu's
> Anyway, feel free to tell me that I'm making this too difficult :)
How about we renameÂfpu_want_lazy_restore to
fpu_registers_valid()? ÂProblem solved :)
Then we can renameÂ__cpu_disable_lazy_restore
to fpu_invalidate_registers(), and call that
before we modify any in-memory FPU state.
> > We can get rid of fpu.counter, since nobody uses it
> > any more.
> We should definitely do this.
> Maybe getting in some cleanups first (my lazy fpu deletion,
> fpu.counter removal, etc) first is the way to go.
Sounds good. ÂI will keep my patch 1/4 as part of the
cleanup series, and will not move on to the harder
stuff until after the cleanups.
Any other stuff I should clean up while we're there?
> > > > >Â
> > You are right, read_pkru() and write_pkru() can only deal with
> > the pkru state being present in registers. Is this because of an
> > assumption in the code, or because of a hardware requirement?
read_pkru and write_pkru would be candidates for using
fpu_registers_valid, and potentially a fpu_make_registers_valid,
which restores the contents of the fpu registers from memory,
if fpu_registers_valid is not true.
Likewise, we can have an fpu_make_memory_valid to ensure the
in kernel memory copy of the FPU registers is valid, potentially
a _read and _write version that do exactly what the pstate code
Would that make sense as an API?
All Rights Reversed.
Description: This is a digitally signed message part