From: "David S. Miller" <davem@davemloft.net>
To: sparclinux@vger.kernel.org
Subject: Re: FPU context switching fix for SMP
Date: Tue, 15 Feb 2005 17:40:57 +0000 [thread overview]
Message-ID: <20050215094057.04da9ef2.davem@davemloft.net> (raw)
In-Reply-To: <41f753cabb795@wp.pl>
On Wed, 26 Jan 2005 09:24:42 +0100
"Krzysztof Helt" <krzysztof.h1@wp.pl> wrote:
> Here is a patch for FPU context switching in SMP.
>
> A copy_thread() function clears PF_USEDFPU flag for a new thread,
> but it does not clear the PSR_EF bit. Thus, a first FPU exception
> called from the child thread is not handled properly. I made the
> patch after PPC and MIPS architectures - both clear a similar bit
> in copy_thread.
> This bug does not exist in the UP kernel, probably because it
> does not rely on PF_USEDFPU flag.
>
> The patch below should be applied for both 2.4 and 2.6 branches.
I've modified your patch to only do this in the SMP case.
Here is how the two mechanisms work:
UP:
last_task_used_math keeps trash of the last thread to
use the FPU. As we context switch, we clear PSR_EF in
the %psr register. If we take a FPU disabled trap:
1) if this is last_task_used_math, simply re-enable FPU
2) else, save FPU state to last_task_used_math, restore
FPU state of current thread, and update last_task_used_math
value
When we exec() or exit() and last_task_used_math is the
current thread, we reset it to NULL.
SMP:
last_task_used_math is not used at all.
Instead, a state bit assosciated with each thread keeps
track of whether that thread used the FPU or not.
At schedule() time, if set we clear the bit and save
the FPU state of that task and clear PSR_EF.
At FPU disabled trap time, we set the state bit
and load the FPU state for the process.
The SMP case works in that each thread, when scheduled(), has
it's PSR_EF flag cleared.
This fork() bug takes away that invariant, which is why the
problems arose.
Thanks a lot Krzysztof.
next prev parent reply other threads:[~2005-02-15 17:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-26 8:24 FPU context switching fix for SMP Krzysztof Helt
2005-01-26 8:26 ` William Lee Irwin III
2005-01-26 8:57 ` Krzysztof Helt
2005-01-26 22:06 ` Baurjan Ismagulov
2005-01-26 23:09 ` David S. Miller
2005-01-29 18:22 ` Baurjan Ismagulov
2005-02-15 17:40 ` David S. Miller [this message]
2005-02-15 20:01 ` William Lee Irwin III
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=20050215094057.04da9ef2.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=sparclinux@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.