Re: [RFC PATCH 06/11] x86,fpu: lazily skip fpu restore with eager fpu mode, too

Oleg Nesterov
2015-01-15T19:36:13Z

On 01/14, Rik van Riel wrote:
>
> On 01/14/2015 01:36 PM, Oleg Nesterov wrote:
>
> >> @@ -466,6 +462,10 @@ static inline void switch_fpu_finish(void)
> >>
> >> __thread_fpu_begin(tsk);
> >>
> >> + /* The FPU registers already have this task's FPU state. */ +
> >> if (fpu_lazy_restore(tsk, raw_smp_processor_id())) + return; +
> >
> > Now that this is called before return to user-mode, I am not sure
> > this is correct. Note that __kernel_fpu_begin() doesn't clear
> > fpu_owner_task if use_eager_fpu().
>
> However, __kernel_fpu_begin() does call __thread_clear_has_fpu(),
> which clears the per-cpu fpu_owner variable, which is also
> evaluated by fpu_lazy_restore(), so I think this is actually
> correct.

Sure, but only if __thread_has_fpu().

But please ignore. My comment was confusing, sorry. What I actually
tried to say is that this patch is another reason why (I think) we
should start with kernel_fpu_begin/end.

If nothing else:

1. interrupted_kernel_fpu_idle() should not fail if
use_eager_fpu() && !__thread_has_fpu(), otherwise your
changes will introduce the performance regression.

And in fact I think that it should only fail if
kernel_fpu_begin() is already in progress.

2. And in this case this_cpu_write(fpu_owner_task, NULL)
can't depend on use_eager_fpu().

And in fact I think it should not depend in any case,
this only adds more confusion.

Please look at the initial cleanups I sent.

Oleg.