linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Andi Kleen <andi@firstfloor.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: question about lazy FPU restore
Date: Thu, 02 May 2013 18:19:19 -0400	[thread overview]
Message-ID: <5182E667.1000603@surriel.com> (raw)

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.

                 reply	other threads:[~2013-05-02 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=5182E667.1000603@surriel.com \
    --to=riel@surriel.com \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suresh.b.siddha@intel.com \
    /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).