From: Jun Sun <jsun@mvista.com>
To: linux-mips@oss.sgi.com
Subject: ieee754_csr is the problem (Re: lazy fpu switch irrelavant to no-fpu case?
Date: Thu, 21 Feb 2002 19:57:16 -0800 [thread overview]
Message-ID: <3C75C19C.13BB0FCC@mvista.com> (raw)
In-Reply-To: 3C75B181.C5A065A1@mvista.com
[-- Attachment #1: Type: text/plain, Size: 697 bytes --]
Jun Sun wrote:
> Anyhow, the problem I am seeing with FPU/SMP case seems to be caused by FPU
> emulation code itself, if we can assume it is not caused by fpu context
> switch. Right now the FPU is not turned on on the box.
>
OK, I found the guilt part in FPU emul. It is the global variable
ieee754_csr. The following patch seems to fix the problem. I am sure someone
who are more familiar with FPU might be able to make it more elegant.
There is another global variable which is potentially dangerous for SMP. It
is fpuemuprivate. Currently it is used in almost used for accounting and
read-only purpose. I did not bother to change it. It should be fixed too, I
suppose.
Cheers.
Jun
[-- Attachment #2: patch3 --]
[-- Type: text/plain, Size: 2183 bytes --]
diff -Nru linux/arch/mips/math-emu/ieee754.h.orig linux/arch/mips/math-emu/ieee754.h
--- linux/arch/mips/math-emu/ieee754.h.orig Thu Jan 31 17:13:26 2002
+++ linux/arch/mips/math-emu/ieee754.h Thu Feb 21 19:34:06 2002
@@ -323,7 +323,7 @@
/* the control status register
*/
-struct ieee754_csr {
+struct ieee754_csr_struct {
unsigned pad:13;
unsigned nod:1; /* set 1 for no denormalised numbers */
unsigned cx:5; /* exceptions this operation */
@@ -331,7 +331,13 @@
unsigned sx:5; /* exceptions total */
unsigned rm:2; /* current rounding mode */
};
-extern struct ieee754_csr ieee754_csr;
+
+#include <linux/sched.h>
+#include <linux/threads.h>
+#include <linux/smp.h>
+#include <asm/current.h>
+extern struct ieee754_csr_struct ieee754_csr_array[NR_CPUS];
+#define ieee754_csr ieee754_csr_array[smp_processor_id()]
static __inline unsigned ieee754_getrm(void)
{
diff -Nru linux/arch/mips/math-emu/ieee754.c.orig linux/arch/mips/math-emu/ieee754.c
--- linux/arch/mips/math-emu/ieee754.c.orig Mon Jan 28 11:17:14 2002
+++ linux/arch/mips/math-emu/ieee754.c Thu Feb 21 19:37:32 2002
@@ -52,7 +52,7 @@
/* the control status register
*/
-struct ieee754_csr ieee754_csr;
+struct ieee754_csr_struct ieee754_csr_array[NR_CPUS];
/* special constants
*/
diff -Nru linux/arch/mips/math-emu/cp1emu.c.orig linux/arch/mips/math-emu/cp1emu.c
--- linux/arch/mips/math-emu/cp1emu.c.orig Mon Jan 28 11:17:14 2002
+++ linux/arch/mips/math-emu/cp1emu.c Thu Feb 21 19:22:45 2002
@@ -945,7 +945,7 @@
static ieee754##p fpemu_##p##_##name (ieee754##p r, ieee754##p s, \
ieee754##p t) \
{ \
- struct ieee754_csr ieee754_csr_save; \
+ struct ieee754_csr_struct ieee754_csr_save; \
s = f1 (s, t); \
ieee754_csr_save = ieee754_csr; \
s = f2 (s, r); \
diff -Nru linux/arch/mips/math-emu/dp_sqrt.c.orig linux/arch/mips/math-emu/dp_sqrt.c
--- linux/arch/mips/math-emu/dp_sqrt.c.orig Thu Feb 21 19:41:09 2002
+++ linux/arch/mips/math-emu/dp_sqrt.c Thu Feb 21 19:39:08 2002
@@ -37,7 +37,7 @@
ieee754dp ieee754dp_sqrt(ieee754dp x)
{
- struct ieee754_csr oldcsr;
+ struct ieee754_csr_struct oldcsr;
ieee754dp y, z, t;
unsigned scalx, yh;
COMPXDP;
WARNING: multiple messages have this Message-ID (diff)
From: Jun Sun <jsun@mvista.com>
To: linux-mips@oss.sgi.com
Subject: ieee754_csr is the problem (Re: lazy fpu switch irrelavant to no-fpu case?
Date: Thu, 21 Feb 2002 19:57:16 -0800 [thread overview]
Message-ID: <3C75C19C.13BB0FCC@mvista.com> (raw)
Message-ID: <20020222035716.tFNDnkl0IGuRY-FZBSFZd1sAQUa41edIH_eDlw8hZE8@z> (raw)
In-Reply-To: 3C75B181.C5A065A1@mvista.com
[-- Attachment #1: Type: text/plain, Size: 697 bytes --]
Jun Sun wrote:
> Anyhow, the problem I am seeing with FPU/SMP case seems to be caused by FPU
> emulation code itself, if we can assume it is not caused by fpu context
> switch. Right now the FPU is not turned on on the box.
>
OK, I found the guilt part in FPU emul. It is the global variable
ieee754_csr. The following patch seems to fix the problem. I am sure someone
who are more familiar with FPU might be able to make it more elegant.
There is another global variable which is potentially dangerous for SMP. It
is fpuemuprivate. Currently it is used in almost used for accounting and
read-only purpose. I did not bother to change it. It should be fixed too, I
suppose.
Cheers.
Jun
[-- Attachment #2: patch3 --]
[-- Type: text/plain, Size: 2183 bytes --]
diff -Nru linux/arch/mips/math-emu/ieee754.h.orig linux/arch/mips/math-emu/ieee754.h
--- linux/arch/mips/math-emu/ieee754.h.orig Thu Jan 31 17:13:26 2002
+++ linux/arch/mips/math-emu/ieee754.h Thu Feb 21 19:34:06 2002
@@ -323,7 +323,7 @@
/* the control status register
*/
-struct ieee754_csr {
+struct ieee754_csr_struct {
unsigned pad:13;
unsigned nod:1; /* set 1 for no denormalised numbers */
unsigned cx:5; /* exceptions this operation */
@@ -331,7 +331,13 @@
unsigned sx:5; /* exceptions total */
unsigned rm:2; /* current rounding mode */
};
-extern struct ieee754_csr ieee754_csr;
+
+#include <linux/sched.h>
+#include <linux/threads.h>
+#include <linux/smp.h>
+#include <asm/current.h>
+extern struct ieee754_csr_struct ieee754_csr_array[NR_CPUS];
+#define ieee754_csr ieee754_csr_array[smp_processor_id()]
static __inline unsigned ieee754_getrm(void)
{
diff -Nru linux/arch/mips/math-emu/ieee754.c.orig linux/arch/mips/math-emu/ieee754.c
--- linux/arch/mips/math-emu/ieee754.c.orig Mon Jan 28 11:17:14 2002
+++ linux/arch/mips/math-emu/ieee754.c Thu Feb 21 19:37:32 2002
@@ -52,7 +52,7 @@
/* the control status register
*/
-struct ieee754_csr ieee754_csr;
+struct ieee754_csr_struct ieee754_csr_array[NR_CPUS];
/* special constants
*/
diff -Nru linux/arch/mips/math-emu/cp1emu.c.orig linux/arch/mips/math-emu/cp1emu.c
--- linux/arch/mips/math-emu/cp1emu.c.orig Mon Jan 28 11:17:14 2002
+++ linux/arch/mips/math-emu/cp1emu.c Thu Feb 21 19:22:45 2002
@@ -945,7 +945,7 @@
static ieee754##p fpemu_##p##_##name (ieee754##p r, ieee754##p s, \
ieee754##p t) \
{ \
- struct ieee754_csr ieee754_csr_save; \
+ struct ieee754_csr_struct ieee754_csr_save; \
s = f1 (s, t); \
ieee754_csr_save = ieee754_csr; \
s = f2 (s, r); \
diff -Nru linux/arch/mips/math-emu/dp_sqrt.c.orig linux/arch/mips/math-emu/dp_sqrt.c
--- linux/arch/mips/math-emu/dp_sqrt.c.orig Thu Feb 21 19:41:09 2002
+++ linux/arch/mips/math-emu/dp_sqrt.c Thu Feb 21 19:39:08 2002
@@ -37,7 +37,7 @@
ieee754dp ieee754dp_sqrt(ieee754dp x)
{
- struct ieee754_csr oldcsr;
+ struct ieee754_csr_struct oldcsr;
ieee754dp y, z, t;
unsigned scalx, yh;
COMPXDP;
next prev parent reply other threads:[~2002-02-22 4:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-22 2:48 lazy fpu switch irrelavant to no-fpu case? Jun Sun
2002-02-22 3:57 ` Jun Sun [this message]
2002-02-22 3:57 ` ieee754_csr is the problem (Re: " Jun Sun
2002-02-22 9:59 ` Kevin D. Kissell
2002-02-22 9:59 ` Kevin D. Kissell
2002-02-22 17:08 ` Kjeld Borch Egevang
2002-02-22 17:08 ` Kjeld Borch Egevang
2002-02-22 9:45 ` Kevin D. Kissell
2002-02-22 9:45 ` Kevin D. Kissell
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=3C75C19C.13BB0FCC@mvista.com \
--to=jsun@mvista.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 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.