From: Jun Sun <jsun@mvista.com>
To: "Kevin D. Kissell" <kevink@mips.com>
Cc: linux-mips@oss.sgi.com
Subject: Re: FPU emulator unsafe for SMP?
Date: Tue, 19 Feb 2002 17:12:38 -0800 [thread overview]
Message-ID: <20020219171238.E25739@mvista.com> (raw)
In-Reply-To: <00af01c1b9a2$c0d6d5f0$10eca8c0@grendel>; from kevink@mips.com on Wed, Feb 20, 2002 at 01:08:30AM +0100
On Wed, Feb 20, 2002 at 01:08:30AM +0100, Kevin D. Kissell wrote:
> > > > Hmm, I see. The lazy fpu context switch code is not SMP safe.
> > > > I see fishy things like "last_task_used_math" etc...
> > >
> > > What, you mean "last_task_used_math" isn't allocated in a
> > > processor-specific page of kseg3??? ;-)
> >
> > You must be talking about another OS, right? :-) I don't think
> > Linux has processor-specific page, although this sounds like
> > a good idea to explore.
>
> It's gotta be done. I mean, the last I heard (which was a long
> time ago) mips64 Linux was keeping the CPU node number in
> a watchpoint register (or something equally unwholesome)
It seems that people are getting smarter by putting cpu id to
context register. In fact isn't this part of new MIPS
standard?
>
> But getting back to the original topic, there's another fun bug
> waiting for us in MIPS/Linux SMP floating point that can't
> be fixed as easly with VM slight-of-hand. Consider processes
> "A" and "B", where A uses FP and B does not: A gets scheduled
> on CPU 1, runs for a while, gets preempted, and B gets CPU 1.
> CPU 2 gets freed, so A gets scheduled on CPU 2. Unfortunately,
> A's FP state is still in the FP register set of CPU 1. The lazy FPU
> context switch either needs to be turned off (bleah!) or be fixed
> for SMP to handle the case where the "owner" of the FPR's
> on one CPU gets scheduled on another.
>
> The brute force would be somehow to send an interrupt to the CPU
> with the FP state that will cause it to cough it up into the thread context
> area. One alternative would be to give strict CPU affinity to the thread
> that has it's FP state on a particular CPU. That could complicate load
> balancing, but might not really be too bad. At most one thread per CPU
> will be non-migratable at a given point in time. In the above scenario,
> "A" could never migrate off of CPU 1, but "B" could, and would
> presumably be picked up by an idle CPU 2 as soon as it's time slice
> is up on CPU 1. That will be less efficient than doing an "FPU shootdown"
> in some cases, but it should also be more portable and easier
> to get right.
>
As I looked into FPU/SMP issue, I realized this problem. I agree
that locking fpu owner to the current cpu is the best solution.
I bet this won't really hurt performance because any alternative would
incur transferring FPU registers across cpus, which is not a small
overhead.
> Does this come up in x86-land? The FPU state is much smaller
> there, so lazy context switching is presumably less important.
>
It appears x86 is not doing lazy fpu switching, at least not
as agressively as MIPS. I am actually curious how IRIX handles
this case, assuming IRIX is reasonable enough to have
lazy FPU switching...
Jun
next prev parent reply other threads:[~2002-02-20 2:13 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-15 1:56 FPU emulator unsafe for SMP? Jun Sun
2002-02-15 2:11 ` Ralf Baechle
2002-02-15 7:20 ` Jun Sun
2002-02-15 8:30 ` Jun Sun
2002-02-15 9:59 ` Kevin D. Kissell
2002-02-15 9:59 ` Kevin D. Kissell
2002-02-19 22:05 ` Jun Sun
2002-02-19 22:19 ` Ralf Baechle
2002-02-20 0:08 ` Kevin D. Kissell
2002-02-20 0:08 ` Kevin D. Kissell
2002-02-20 1:12 ` Jun Sun [this message]
2002-02-20 3:28 ` Greg Lindahl
2002-02-20 4:24 ` Jun Sun
2002-02-20 4:32 ` Daniel Jacobowitz
2002-02-20 9:48 ` Jun Sun
2002-02-20 10:14 ` Kevin D. Kissell
2002-02-20 10:14 ` Kevin D. Kissell
2002-02-20 13:50 ` Ralf Baechle
2002-02-20 20:53 ` Greg Lindahl
2002-02-20 13:24 ` Ralf Baechle
2002-02-20 4:48 ` Greg Lindahl
2002-02-20 9:27 ` Florian Lohoff
2002-02-20 13:18 ` Ralf Baechle
2002-02-20 9:56 ` Geert Uytterhoeven
2002-02-20 11:14 ` Kevin D. Kissell
2002-02-20 13:10 ` Ralf Baechle
2002-02-20 8:27 ` Dominic Sweetman
2002-02-20 9:30 ` Florian Lohoff
2002-02-20 13:56 ` Ralf Baechle
2002-02-20 13:09 ` Ralf Baechle
2002-02-20 14:42 ` Kevin D. Kissell
2002-02-20 14:42 ` Kevin D. Kissell
2002-02-20 14:46 ` Maciej W. Rozycki
2002-02-20 15:05 ` Ralf Baechle
2002-02-20 15:45 ` Maciej W. Rozycki
2002-02-20 13:03 ` Ralf Baechle
2002-02-15 8:14 ` Kevin D. Kissell
2002-02-15 8:14 ` Kevin D. Kissell
2002-02-15 10:57 ` Ralf Baechle
2002-02-19 22:02 ` Jun Sun
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=20020219171238.E25739@mvista.com \
--to=jsun@mvista.com \
--cc=kevink@mips.com \
--cc=linux-mips@oss.sgi.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