mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: linux@horizon.com
To: 76306.1226@compuserve.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch 2.6.13-rc3a] i386: inline restore_fpu
Date: 26 Jul 2005 21:40:27 -0400	[thread overview]
Message-ID: <20050727014027.25283.qmail@science.horizon.com> (raw)

> Since fxsave leaves the FPU state intact, there ought to be a better way
> to do this but it gets tricky.  Maybe using the TSC to put a timestamp
> in every thread save area?
> 
>   when saving FPU state:
>         put cpu# and timestamp in thread state info
>         also store timestamp in per-cpu data
> 
>   on task switch:
>         compare cpu# and timestamps for next task
>         if equal, clear TS and set TS_USEDFPU
> 
>   when state becomes invalid for some reason:
>         zero cpu's timestamp
> 
> But the extra overhead might be too much in many cases.

Simpler:
- Thread has "CPU that I last used FPU on" pointer.  Never NULL.
- Each CPU has "thread whose FPU state I hold" pointer.  May be NULL.

When *loading* FPU state:
- Set up both pointers.

On task switch:
- If the pointers point to each other, then clear TS and skip restore.
  ("Preloaded")

When state becomes invalid (kernel MMX use, or whatever)
- Set CPU's pointer to NULL.

On thread creation:
- If current CPU's thread pointer points to the newly allocated thread,
  clear it to NULL.
- Set thread's CPU pointer to current CPU.

The UP case just omits the per-thread CPU pointer.  (Well, stores
it in zero bits.)

An alternative SMP thread-creation case would be to have a NULL value for
the thread-to-CPU pointer and initialize the thread's CPU pointer to that,
but that then complicates the UP case.

             reply	other threads:[~2005-07-27  1:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-27  1:40 linux [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-07-26 21:23 Chuck Ebbert
2005-07-26 21:47 ` Linus Torvalds
2005-07-26 21:23 Chuck Ebbert
2005-07-25  2:34 Kenneth Parrish
2005-07-24 12:56 Kenneth Parrish
     [not found] <200507212309_MC3-1-A534-95EF@compuserve.com.suse.lists.linux.kernel>
     [not found] ` <20050722132756.578acca7.akpm@osdl.org.suse.lists.linux.kernel>
2005-07-23 15:35   ` Andi Kleen
2005-07-23  7:09 Chuck Ebbert
2005-07-23 17:33 ` Linus Torvalds
2005-07-23  7:09 Chuck Ebbert
2005-07-23 17:38 ` Linus Torvalds
2005-07-23 17:46   ` Arjan van de Ven
2005-07-23 18:02     ` Linus Torvalds
2005-07-22  9:58 Chuck Ebbert
2005-07-22  3:06 Chuck Ebbert
2005-07-22  3:27 ` Andrew Morton
2005-07-22  5:22   ` Linus Torvalds
2005-07-22 11:23     ` Arjan van de Ven
2005-07-22  8:14 ` Adrian Bunk
2005-07-22 18:13   ` Linus Torvalds
2005-07-25 19:26     ` Bill Davidsen
2005-07-22 23:19 ` Linus Torvalds

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=20050727014027.25283.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=76306.1226@compuserve.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®