linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question about lazy FPU restore
@ 2013-05-02 22:19 Rik van Riel
  0 siblings, 0 replies; only message in thread
From: Rik van Riel @ 2013-05-02 22:19 UTC (permalink / raw)
  To: Suresh Siddha; +Cc: H. Peter Anvin, Andi Kleen, linux-kernel

Hi Suresh,

I have a question about the lazy fpu restore code in
switch_fpu_prepare.  Specifically, about the case where
the old task did not use the FPU, and the new task's
FPU state is still in the cpu.

         } else {
                 old->fpu_counter = 0;
                 old->thread.fpu.last_cpu = ~0;
                 if (fpu.preload) {
                         new->fpu_counter++;
                         if (!use_eager_fpu() && fpu_lazy_restore(new, cpu))
                                 fpu.preload = 0;
                         else
                                 prefetch(new->thread.fpu.state);
                         __thread_fpu_begin(new);
                 }
         }

In this branch, we call fpu_lazy_restore, which
confirms that the CPU still has the new task's state
in it.

However, if we are in eager fpu mode, we still end up
calling restore_fpu_checking from switch_fpu_finish,
even if the new task's FPU state is still resident in
the CPU.

Is there a particular reason we do this?

Would it be possible to always set fpu.preload = 0,
call clts, and __thread_set_has_fpu if fpu_lazy_restore
returns true?

That would allow us to skip the loading of FPU state
when re-entering a process that went briefly idle, before
getting something else to do, a common occurrance in
message passing workloads.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-02 22:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-02 22:19 question about lazy FPU restore Rik van Riel

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).