Re: [PATCH RFC 4/5] x86,fpu: lazily skip FPU restore when still loaded

From: Rik van Riel
Date: Mon Oct 03 2016 - 16:23:07 EST


On Mon, 2016-10-03 at 13:04 -0700, Dave Hansen wrote:
> On 10/01/2016 01:31 PM, riel@xxxxxxxxxx wrote:
> >
> > Â/*
> > + * Check whether an FPU's register set is still loaded in the CPU.
> > + */
> > +static inline bool fpu_lazy_skip_restore(struct fpu *fpu)
> > +{
> > + bool still_loaded = (fpu->fpstate_active &&
> > + ÂÂÂÂÂfpu->last_cpu ==
> > raw_smp_processor_id() &&
> > + ÂÂÂÂÂ__this_cpu_read(fpu_fpregs_owner_ctx)
> > == fpu);
> > +
> > + fpu->fpregs_active = still_loaded;
> > + return still_loaded;
> > +}
> I wonder if we should call this something more along the lines of
> fpregs_activate_fast(), which returns if it managed to do the
> activation
> fast or not.ÂÂI _think_ that's more along the lines of what it is
> actually doing.ÂÂThe fact that it can be lazy is really an
> implementation detail.
>
> What are the preempt rules with this thing?ÂÂThis needs to be called
> in
> preempt-disabled contexts, right?

Indeed, all the FPU context switching code needsÂ
to be called in preempt-disabled contexts.

You do not want to get preempted halfway through
saving or restoring floating point registers.

--
All rights reversed

Attachment: signature.asc
Description: This is a digitally signed message part