<ragge@ludd.luth.se>
From: Jason Thorpe <thorpej@shagadelic.org>
List: port-alpha
Date: 07/25/2005 21:36:52
--Apple-Mail-5-164008267
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
On Jul 24, 2005, at 6:00 AM, <ragge@ludd.luth.se>
<ragge@ludd.luth.se> wrote:
>> If so, see PR #26383 (although my current patch is using splipi()
>> instead of splhigh() as in the PR).
>>
>>
> Great! I will try it and see how it works out!
Can you try this patch instead?
Thanks!
-- thorpej
--Apple-Mail-5-164008267
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
x-mac-type=54455854;
x-unix-mode=0755;
x-mac-creator=74747874;
name="alpha-fp-ipi-patch.txt"
Content-Disposition: attachment;
filename=alpha-fp-ipi-patch.txt
Index: alpha/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.286
diff -u -p -r1.286 machdep.c
--- alpha/machdep.c 3 Jun 2005 15:06:40 -0000 1.286
+++ alpha/machdep.c 26 Jul 2005 04:34:38 -0000
@@ -1706,6 +1706,7 @@ fpusave_cpu(struct cpu_info *ci, int sav
KDASSERT(ci == curcpu());
#if defined(MULTIPROCESSOR)
+ s = splhigh(); /* block IPIs for the duration */
atomic_setbits_ulong(&ci->ci_flags, CPUF_FPUSAVE);
#endif
@@ -1720,16 +1721,17 @@ fpusave_cpu(struct cpu_info *ci, int sav
alpha_pal_wrfen(0);
- FPCPU_LOCK(&l->l_addr->u_pcb, s);
+ FPCPU_LOCK(&l->l_addr->u_pcb);
l->l_addr->u_pcb.pcb_fpcpu = NULL;
ci->ci_fpcurlwp = NULL;
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
out:
#if defined(MULTIPROCESSOR)
atomic_clearbits_ulong(&ci->ci_flags, CPUF_FPUSAVE);
+ splx(s);
#endif
return;
}
@@ -1749,25 +1751,32 @@ fpusave_proc(struct lwp *l, int save)
KDASSERT(l->l_addr != NULL);
- FPCPU_LOCK(&l->l_addr->u_pcb, s);
+#if defined(MULTIPROCESSOR)
+ s = splhigh(); /* block IPIs for the duration */
+#endif
+ FPCPU_LOCK(&l->l_addr->u_pcb);
oci = l->l_addr->u_pcb.pcb_fpcpu;
if (oci == NULL) {
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
+#if defined(MULTIPROCESSOR)
+ splx(s);
+#endif
return;
}
#if defined(MULTIPROCESSOR)
if (oci == ci) {
KASSERT(ci->ci_fpcurlwp == l);
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
+ splx(s);
fpusave_cpu(ci, save);
return;
}
KASSERT(oci->ci_fpcurlwp == l);
alpha_send_ipi(oci->ci_cpuid, ipi);
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
spincount = 0;
while (l->l_addr->u_pcb.pcb_fpcpu != NULL) {
@@ -1778,7 +1787,7 @@ fpusave_proc(struct lwp *l, int save)
}
#else
KASSERT(ci->ci_fpcurlwp == l);
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
fpusave_cpu(ci, save);
#endif /* MULTIPROCESSOR */
}
Index: alpha/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/trap.c,v
retrieving revision 1.97
diff -u -p -r1.97 trap.c
--- alpha/trap.c 1 Jun 2005 16:09:01 -0000 1.97
+++ alpha/trap.c 26 Jul 2005 04:34:39 -0000
@@ -634,12 +634,18 @@ alpha_enable_fp(struct lwp *l, int check
KDASSERT(l->l_addr->u_pcb.pcb_fpcpu == NULL);
#endif
- FPCPU_LOCK(&l->l_addr->u_pcb, s);
+#if defined(MULTIPROCESSOR)
+ s = splhigh(); /* block IPIs */
+#endif
+ FPCPU_LOCK(&l->l_addr->u_pcb);
l->l_addr->u_pcb.pcb_fpcpu = ci;
ci->ci_fpcurlwp = l;
- FPCPU_UNLOCK(&l->l_addr->u_pcb, s);
+ FPCPU_UNLOCK(&l->l_addr->u_pcb);
+#if defined(MULTIPROCESSOR)
+ splx(s);
+#endif
/*
* Instrument FP usage -- if a process had not previously
Index: include/pcb.h
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/include/pcb.h,v
retrieving revision 1.12
diff -u -p -r1.12 pcb.h
--- include/pcb.h 29 Jun 2003 22:28:05 -0000 1.12
+++ include/pcb.h 26 Jul 2005 04:34:39 -0000
@@ -64,25 +64,13 @@ struct pcb {
struct simplelock pcb_fpcpu_slock; /* simple lock on fpcpu [SW] */
};
-#if defined(MULTIPROCESSOR)
/*
- * Need to block IPIs while holding the fpcpu_slock.
+ * MULTIPROCESSOR:
+ * Need to block IPIs while holding the fpcpu_slock. That is the
+ * responsibility of the CALLER!
*/
-#define FPCPU_LOCK(pcb, s) \
-do { \
- (s) = splhigh(); \
- simple_lock(&(pcb)->pcb_fpcpu_slock); \
-} while (/*CONSTCOND*/0)
-
-#define FPCPU_UNLOCK(pcb, s) \
-do { \
- simple_unlock(&(pcb)->pcb_fpcpu_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/0)
-#else
-#define FPCPU_LOCK(pcb, s) simple_lock(&(pcb)->pcb_fpcpu_slock)
-#define FPCPU_UNLOCK(pcb, s) simple_unlock(&(pcb)->pcb_fpcpu_slock)
-#endif /* MULTIPROCESSOR */
+#define FPCPU_LOCK(pcb) simple_lock(&(pcb)->pcb_fpcpu_slock)
+#define FPCPU_UNLOCK(pcb) simple_unlock(&(pcb)->pcb_fpcpu_slock)
/*
* The pcb is augmented with machine-dependent additional data for
--Apple-Mail-5-164008267
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
--Apple-Mail-5-164008267--