summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorfsmp <fsmp@FreeBSD.org>1997-07-18 21:27:53 +0000
committerfsmp <fsmp@FreeBSD.org>1997-07-18 21:27:53 +0000
commitee22260a440c99c7f84e51e6c7baabad641f9d9b (patch)
treebd0d6b01bc1125ca84a7c7dc8a4398f8e6148344 /sys
parent6c57ae296c86a1387b2a8bf05ccd6e17dfb792b2 (diff)
downloadFreeBSD-src-ee22260a440c99c7f84e51e6c7baabad641f9d9b.zip
FreeBSD-src-ee22260a440c99c7f84e51e6c7baabad641f9d9b.tar.gz
Split TEST_CPUSTOP code into CPUSTOP_ON_DDBBREAK and mainline code.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/apic_vector.S30
-rw-r--r--sys/amd64/amd64/db_interface.c44
-rw-r--r--sys/amd64/amd64/mp_machdep.c37
-rw-r--r--sys/amd64/amd64/mptable.c37
-rw-r--r--sys/amd64/include/apicreg.h5
-rw-r--r--sys/amd64/include/mptable.h37
-rw-r--r--sys/amd64/isa/intr_machdep.h20
-rw-r--r--sys/i386/i386/apic_vector.s30
-rw-r--r--sys/i386/i386/db_interface.c44
-rw-r--r--sys/i386/i386/mp_machdep.c37
-rw-r--r--sys/i386/i386/mpapic.c4
-rw-r--r--sys/i386/i386/mplock.s83
-rw-r--r--sys/i386/i386/mptable.c37
-rw-r--r--sys/i386/include/apic.h5
-rw-r--r--sys/i386/include/apicreg.h5
-rw-r--r--sys/i386/include/mptable.h37
-rw-r--r--sys/i386/include/smptests.h21
-rw-r--r--sys/i386/isa/apic_vector.s30
-rw-r--r--sys/i386/isa/intr_machdep.h20
-rw-r--r--sys/kern/subr_smp.c37
20 files changed, 192 insertions, 408 deletions
diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S
index 807223b..9ea96ca 100644
--- a/sys/amd64/amd64/apic_vector.S
+++ b/sys/amd64/amd64/apic_vector.S
@@ -1,10 +1,11 @@
/*
* from: vector.s, 386BSD 0.1 unknown origin
- * $Id: apic_vector.s,v 1.7 1997/07/15 02:49:21 fsmp Exp $
+ * $Id: apic_vector.s,v 1.12 1997/07/18 19:47:13 smp Exp smp $
*/
-#include <machine/smptests.h> /** TEST_CPUSTOP */
+#include <machine/smptests.h> /** various counters */
+#include "i386/isa/intr_machdep.h"
/* convert an absolute IRQ# into a bitmask */
#define IRQ_BIT(irq_num) (1 << (irq_num))
@@ -212,10 +213,6 @@ _Xinvltlb:
iret
-#ifdef TEST_CPUSTOP
-
-#include "i386/isa/intr_machdep.h"
-
/*
* Executed by a CPU when it receives an Xcpustop IPI from another CPU,
*
@@ -263,8 +260,6 @@ _Xcpustop:
popl %eax
iret
-#endif /* TEST_CPUSTOP */
-
MCOUNT_LABEL(bintr)
FAST_INTR(0,fastintr0)
@@ -359,33 +354,22 @@ _sihits:
#ifdef COUNT_XINVLTLB_HITS
.globl _xhits
_xhits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_XINVLTLB_HITS */
-#ifdef TEST_CPUSTOP
-
- .globl _stopped_cpus
+/* variables used by stop_cpus()/restart_cpus()/Xcpustop */
+ .globl _stopped_cpus, _started_cpus
_stopped_cpus:
.long 0
-
- .globl _started_cpus
_started_cpus:
.long 0
#ifdef COUNT_CSHITS
.globl _cshits
_cshits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_CSHITS */
-#endif /* TEST_CPUSTOP */
-
/*
* Interrupt counters and names. The format of these and the label names
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c
index 62957b8..b8aeb63 100644
--- a/sys/amd64/amd64/db_interface.c
+++ b/sys/amd64/amd64/db_interface.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_interface.c,v 1.9 1997/07/13 00:48:28 smp Exp smp $
+ * $Id: db_interface.c,v 1.10 1997/07/18 19:45:41 smp Exp smp $
*/
/*
@@ -40,7 +40,7 @@
#include <machine/segments.h>
#ifdef SMP
#include <machine/smp.h>
-#include <machine/smptests.h> /** TEST_CPUSTOP */
+#include <machine/smptests.h> /** CPUSTOP_ON_DDBBREAK */
#endif
#include <vm/vm.h>
@@ -138,10 +138,22 @@ kdb_trap(type, code, regs)
cnpollc(TRUE);
-#if defined(SMP) && defined(TEST_CPUSTOP)
- /* XXX FIXME: we stop all CPUs except ourselves (obviously) */
+#ifdef SMP
+#ifdef CPUSTOP_ON_DDBBREAK
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, other_cpus);
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+ /* We stop all CPUs except ourselves (obviously) */
stop_cpus(other_cpus);
-#endif /** SMP && TEST_CPUSTOP */
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf(" stopped\n");
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+#endif /* CPUSTOP_ON_DDBBREAK */
+#endif /* SMP */
(void) setjmp(db_global_jmpbuf);
db_global_jmpbuf_valid = TRUE;
@@ -151,15 +163,27 @@ kdb_trap(type, code, regs)
gdb_handle_exception(&ddb_regs, type, code);
db_global_jmpbuf_valid = FALSE;
-#if defined(SMP) && defined(TEST_CPUSTOP)
- /* XXX FIXME: restart all the CPUs we previously stopped */
+#ifdef SMP
+#ifdef CPUSTOP_ON_DDBBREAK
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf("\nCPU%d restarting CPUs: 0x%08x\n", cpuid, stopped_cpus);
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+ /* Restart all the CPUs we previously stopped */
if (stopped_cpus != other_cpus) {
db_printf("whoa, other_cpus: 0x%08x, stopped_cpus: 0x%08x\n",
- other_cpus, stopped_cpus);
- cngetc();
+ other_cpus, stopped_cpus);
+ panic("stop_cpus() failed");
}
restart_cpus(stopped_cpus);
-#endif /** SMP && TEST_CPUSTOP */
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf(" restarted\n");
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+#endif /* CPUSTOP_ON_DDBBREAK */
+#endif /* SMP */
cnpollc(FALSE);
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index f1cd1a2..de10f8c 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c
index f1cd1a2..de10f8c 100644
--- a/sys/amd64/amd64/mptable.c
+++ b/sys/amd64/amd64/mptable.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/amd64/include/apicreg.h b/sys/amd64/include/apicreg.h
index f587184..170eb78 100644
--- a/sys/amd64/include/apicreg.h
+++ b/sys/amd64/include/apicreg.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: apic.h,v 1.7 1997/07/15 02:47:52 fsmp Exp $
+ * $Id: apic.h,v 1.5 1997/07/18 19:47:48 smp Exp smp $
*/
#ifndef _MACHINE_APIC_H_
@@ -220,7 +220,10 @@ typedef struct IOAPIC ioapic_t;
* various code 'logical' values
*/
+#ifdef TEST_LOPRIO
#define LOPRIO_LEVEL 0x00000010 /* TPR of CPUs accepting INT */
+#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
+#endif /** TEST_LOPRIO */
/* XXX these 2 don't really belong here... */
#define COUNT_FIELD 0x00ffffff /* count portion of the lock */
diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h
index f1cd1a2..de10f8c 100644
--- a/sys/amd64/include/mptable.h
+++ b/sys/amd64/include/mptable.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/amd64/isa/intr_machdep.h b/sys/amd64/isa/intr_machdep.h
index 27e14af..e9c0e84 100644
--- a/sys/amd64/isa/intr_machdep.h
+++ b/sys/amd64/isa/intr_machdep.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
- * $Id: intr_machdep.h,v 1.6 1997/07/13 00:18:33 smp Exp smp $
+ * $Id: intr_machdep.h,v 1.7 1997/07/18 19:47:13 smp Exp smp $
*/
#ifndef _I386_ISA_INTR_MACHDEP_H_
@@ -99,15 +99,13 @@
/* TLB shootdowns */
#define XINVLTLB_OFFSET (ICU_OFFSET + 32)
-#if defined(TEST_CPUSTOP)
/* IPI to signal CPUs to stop and wait for another CPU to restart them */
#define XCPUSTOP_OFFSET (ICU_OFFSET + 48)
-#endif /** TEST_CPUSTOP */
-#if defined(TEST_TEST1)
+#ifdef TEST_TEST1
/* put a 'fake' HWI in top of APIC prio 0x3x, 32 + 31 = 63 = 0x3f */
#define XTEST1_OFFSET (ICU_OFFSET + 31)
-#endif /** TEST_TEST1 */
+#endif /** TEST_TEST1 */
#ifndef LOCORE
@@ -152,18 +150,14 @@ inthand_t
IDTVEC(intr20), IDTVEC(intr21), IDTVEC(intr22), IDTVEC(intr23);
inthand_t
- Xinvltlb,
- Xspuriousint;
-
-#if defined(TEST_CPUSTOP)
-inthand_t
+ Xinvltlb, /* TLB shootdowns */
+ Xspuriousint, /* handle APIC "spurious INTs" */
Xcpustop; /* stop & wait for another CPU to restart it */
-#endif /** TEST_CPUSTOP */
-#if defined(TEST_CPUSTOP)
+#ifdef TEST_TEST1
inthand_t
Xtest1; /* 'fake' HWI in top of APIC prio 0x3x, 32+31 = 0x3f */
-#endif /** TEST_TEST1 */
+#endif /** TEST_TEST1 */
struct isa_device;
diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s
index 807223b..9ea96ca 100644
--- a/sys/i386/i386/apic_vector.s
+++ b/sys/i386/i386/apic_vector.s
@@ -1,10 +1,11 @@
/*
* from: vector.s, 386BSD 0.1 unknown origin
- * $Id: apic_vector.s,v 1.7 1997/07/15 02:49:21 fsmp Exp $
+ * $Id: apic_vector.s,v 1.12 1997/07/18 19:47:13 smp Exp smp $
*/
-#include <machine/smptests.h> /** TEST_CPUSTOP */
+#include <machine/smptests.h> /** various counters */
+#include "i386/isa/intr_machdep.h"
/* convert an absolute IRQ# into a bitmask */
#define IRQ_BIT(irq_num) (1 << (irq_num))
@@ -212,10 +213,6 @@ _Xinvltlb:
iret
-#ifdef TEST_CPUSTOP
-
-#include "i386/isa/intr_machdep.h"
-
/*
* Executed by a CPU when it receives an Xcpustop IPI from another CPU,
*
@@ -263,8 +260,6 @@ _Xcpustop:
popl %eax
iret
-#endif /* TEST_CPUSTOP */
-
MCOUNT_LABEL(bintr)
FAST_INTR(0,fastintr0)
@@ -359,33 +354,22 @@ _sihits:
#ifdef COUNT_XINVLTLB_HITS
.globl _xhits
_xhits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_XINVLTLB_HITS */
-#ifdef TEST_CPUSTOP
-
- .globl _stopped_cpus
+/* variables used by stop_cpus()/restart_cpus()/Xcpustop */
+ .globl _stopped_cpus, _started_cpus
_stopped_cpus:
.long 0
-
- .globl _started_cpus
_started_cpus:
.long 0
#ifdef COUNT_CSHITS
.globl _cshits
_cshits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_CSHITS */
-#endif /* TEST_CPUSTOP */
-
/*
* Interrupt counters and names. The format of these and the label names
diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c
index 62957b8..b8aeb63 100644
--- a/sys/i386/i386/db_interface.c
+++ b/sys/i386/i386/db_interface.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_interface.c,v 1.9 1997/07/13 00:48:28 smp Exp smp $
+ * $Id: db_interface.c,v 1.10 1997/07/18 19:45:41 smp Exp smp $
*/
/*
@@ -40,7 +40,7 @@
#include <machine/segments.h>
#ifdef SMP
#include <machine/smp.h>
-#include <machine/smptests.h> /** TEST_CPUSTOP */
+#include <machine/smptests.h> /** CPUSTOP_ON_DDBBREAK */
#endif
#include <vm/vm.h>
@@ -138,10 +138,22 @@ kdb_trap(type, code, regs)
cnpollc(TRUE);
-#if defined(SMP) && defined(TEST_CPUSTOP)
- /* XXX FIXME: we stop all CPUs except ourselves (obviously) */
+#ifdef SMP
+#ifdef CPUSTOP_ON_DDBBREAK
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, other_cpus);
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+ /* We stop all CPUs except ourselves (obviously) */
stop_cpus(other_cpus);
-#endif /** SMP && TEST_CPUSTOP */
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf(" stopped\n");
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+#endif /* CPUSTOP_ON_DDBBREAK */
+#endif /* SMP */
(void) setjmp(db_global_jmpbuf);
db_global_jmpbuf_valid = TRUE;
@@ -151,15 +163,27 @@ kdb_trap(type, code, regs)
gdb_handle_exception(&ddb_regs, type, code);
db_global_jmpbuf_valid = FALSE;
-#if defined(SMP) && defined(TEST_CPUSTOP)
- /* XXX FIXME: restart all the CPUs we previously stopped */
+#ifdef SMP
+#ifdef CPUSTOP_ON_DDBBREAK
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf("\nCPU%d restarting CPUs: 0x%08x\n", cpuid, stopped_cpus);
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+ /* Restart all the CPUs we previously stopped */
if (stopped_cpus != other_cpus) {
db_printf("whoa, other_cpus: 0x%08x, stopped_cpus: 0x%08x\n",
- other_cpus, stopped_cpus);
- cngetc();
+ other_cpus, stopped_cpus);
+ panic("stop_cpus() failed");
}
restart_cpus(stopped_cpus);
-#endif /** SMP && TEST_CPUSTOP */
+
+#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
+ db_printf(" restarted\n");
+#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
+
+#endif /* CPUSTOP_ON_DDBBREAK */
+#endif /* SMP */
cnpollc(FALSE);
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index f1cd1a2..de10f8c 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/i386/i386/mpapic.c b/sys/i386/i386/mpapic.c
index 95bcd7e..ce34478 100644
--- a/sys/i386/i386/mpapic.c
+++ b/sys/i386/i386/mpapic.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mpapic.c,v 1.12 1997/07/15 02:51:19 fsmp Exp $
+ * $Id: mpapic.c,v 1.13 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -31,9 +31,9 @@
#include <sys/sysproto.h>
#include <sys/systm.h>
+#include <machine/smptests.h> /** TEST_LOPRIO, TEST_IPI, TEST_ALTTIMER */
#include <machine/smp.h>
#include <machine/mpapic.h>
-#include <machine/smptests.h> /** TEST_LOPRIO, TEST_IPI, TEST_CPUSTOP, TEST_ALTTIMER */
#include <machine/cpufunc.h>
#include <machine/segments.h>
diff --git a/sys/i386/i386/mplock.s b/sys/i386/i386/mplock.s
index 3762fdb..ef6dd53 100644
--- a/sys/i386/i386/mplock.s
+++ b/sys/i386/i386/mplock.s
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: mplock.s,v 1.8 1997/07/15 00:09:53 smp Exp smp $
+ * $Id: mplock.s,v 1.9 1997/07/18 19:45:41 smp Exp smp $
*
* Functions for locking between CPUs in a SMP system.
*
@@ -26,37 +26,53 @@
#include "assym.s" /* system definitions */
#include <machine/specialreg.h> /* x86 special registers */
#include <machine/asmacros.h> /* miscellaneous asm macros */
-#include <machine/smptests.h> /** TEST_LOPRIO, TEST_CPUSTOP */
-#ifdef TEST_CPUSTOP
-#include <i386/isa/intr_machdep.h>
-#endif
+#include <machine/smptests.h> /** TEST_LOPRIO */
#include <machine/apic.h>
+#include <i386/isa/intr_machdep.h>
+
+
/*
* claim LOW PRIO, ie. accept ALL INTerrupts
*/
#ifdef TEST_LOPRIO
-#ifdef TEST_CPUSTOP
+/* location of saved TPR on stack */
#define TPR_TARGET 20(%esp)
-#else
-#define TPR_TARGET lapic_tpr
-#endif /** TEST_CPUSTOP */
+/* we assumme that the 'reserved bits' can be written with zeros */
#ifdef CHEAP_TPR
-#define ACCEPT_INTS \
- movl $0, TPR_TARGET /* clear TPR */
-#else
-#define ACCEPT_INTS \
- andl $~APIC_TPR_PRIO, TPR_TARGET /* clear TPR */
+
+/* after 1st acquire of lock we attempt to grab all hardware INTs */
+#define GRAB_HWI \
+ movl $ALLHWI_LEVEL, TPR_TARGET /* task prio to 'all HWI' */
+
+/* after last release of lock give up LOW PRIO (ie, arbitrate INTerrupts) */
+#define ARB_HWI \
+ movl $LOPRIO_LEVEL, lapic_tpr /* task prio to 'arbitrate' */
+
+#else /** CHEAP_TPR */
+
+#define GRAB_HWI \
+ andl $~APIC_TPR_PRIO, TPR_TARGET /* task prio to 'all HWI' */
+
+#define ARB_HWI \
+ movl lapic_tpr, %eax ; /* TPR */ \
+ andl $~APIC_TPR_PRIO, %eax ; /* clear TPR field */ \
+ orl $LOPRIO_LEVEL, %eax ; /* prio to arbitrate */ \
+ movl %eax, lapic_tpr ; /* set it */ \
+ movl (%edx), %eax /* reload %eax with lock */
+
#endif /** CHEAP_TPR */
-#else
+#else /** TEST_LOPRIO */
-#define ACCEPT_INTS
+#define GRAB_HWI /* nop */
+#define ARB_HWI /* nop */
#endif /** TEST_LOPRIO */
+
.text
/***********************************************************************
* void MPgetlock(unsigned int *lock)
@@ -82,7 +98,7 @@ NON_GPROF_ENTRY(MPgetlock)
lock
cmpxchg %ecx, (%edx) /* - try it atomically */
jne 3f /* ...do not collect $200 */
- ACCEPT_INTS /* 1st acquire, accept INTs */
+ GRAB_HWI /* 1st acquire, grab hw INTs */
ret
3: cmpl $FREE_LOCK, (%edx) /* Wait for it to become free */
jne 3b
@@ -114,7 +130,7 @@ NON_GPROF_ENTRY(MPtrylock)
lock
cmpxchg %ecx, (%edx) /* - try it atomically */
jne 3f /* ...do not collect $200 */
- ACCEPT_INTS /* 1st acquire, accept INTs */
+ GRAB_HWI /* 1st acquire, grab hw INTs */
movl $1, %eax
ret
3: movl $0, %eax
@@ -133,18 +149,7 @@ NON_GPROF_ENTRY(MPrellock)
decl %ecx /* - new count is one less */
testl $COUNT_FIELD, %ecx /* - Unless it's zero... */
jnz 2f
-#if defined(TEST_LOPRIO)
- /* last release, give up LOW PRIO (ie, arbitrate INTerrupts) */
-#ifdef CHEAP_TPR
- movl $LOPRIO_LEVEL, lapic_tpr /* task prio to 'arbitrate' */
-#else
- movl lapic_tpr, %eax /* Task Priority Register */
- andl $~APIC_TPR_PRIO, %eax /* clear task priority field */
- orl $LOPRIO_LEVEL, %eax /* set task priority to 'arbitrate' */
- movl %eax, lapic_tpr /* set it */
- movl (%edx), %eax /* - get the value AGAIN */
-#endif /* CHEAP_TPR */
-#endif /** TEST_LOPRIO */
+ ARB_HWI /* last release, arbitrate hw INTs */
movl $FREE_LOCK, %ecx /* - In which case we release it */
2: lock
cmpxchg %ecx, (%edx) /* - try it atomically */
@@ -169,13 +174,13 @@ NON_GPROF_ENTRY(MPrellock)
NON_GPROF_ENTRY(get_mplock)
pushl %eax
-#ifdef TEST_CPUSTOP
+ /* block all HW INTs via Task Priority Register */
#ifdef CHEAP_TPR
pushl lapic_tpr /* save current TPR */
pushfl /* save current EFLAGS */
btl $9, (%esp) /* test EI bit */
jc 1f /* INTs currently enabled */
- movl $TPR_BLOCK_HWI, lapic_tpr /* set it */
+ movl $TPR_BLOCK_HWI, lapic_tpr
#else
movl lapic_tpr, %eax /* get current TPR */
pushl %eax /* save current TPR */
@@ -183,12 +188,11 @@ NON_GPROF_ENTRY(get_mplock)
btl $9, (%esp) /* test EI bit */
jc 1f /* INTs currently enabled */
andl $~APIC_TPR_PRIO, %eax /* clear task priority field */
- orl $TPR_BLOCK_HWI, %eax /* only allow IPIs
- movl %eax, lapic_tpr /* set it */
-#endif /* CHEAP_TPR */
- sti /* allow IPI (and only IPI) INTS */
+ orl $TPR_BLOCK_HWI, %eax /* only allow IPIs */
+ movl %eax, lapic_tpr
+#endif /** CHEAP_TPR */
+ sti /* allow (IPI and only IPI) INTs */
1:
-#endif /* TEST_CPUSTOP */
pushl %ecx
pushl %edx
@@ -198,11 +202,8 @@ NON_GPROF_ENTRY(get_mplock)
popl %edx
popl %ecx
-#ifdef TEST_CPUSTOP
popfl /* restore original EFLAGS */
popl lapic_tpr /* restore TPR */
-#endif /* TEST_CPUSTOP */
-
popl %eax /* restore scratch */
ret
@@ -245,5 +246,5 @@ NON_GPROF_ENTRY(rel_mplock)
.data
.globl _mp_lock
- .align 2 /* mp_lock SHALL be aligned on i386 */
+ .align 4 /* mp_lock aligned on int boundary */
_mp_lock: .long 0
diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c
index f1cd1a2..de10f8c 100644
--- a/sys/i386/i386/mptable.c
+++ b/sys/i386/i386/mptable.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/i386/include/apic.h b/sys/i386/include/apic.h
index f587184..170eb78 100644
--- a/sys/i386/include/apic.h
+++ b/sys/i386/include/apic.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: apic.h,v 1.7 1997/07/15 02:47:52 fsmp Exp $
+ * $Id: apic.h,v 1.5 1997/07/18 19:47:48 smp Exp smp $
*/
#ifndef _MACHINE_APIC_H_
@@ -220,7 +220,10 @@ typedef struct IOAPIC ioapic_t;
* various code 'logical' values
*/
+#ifdef TEST_LOPRIO
#define LOPRIO_LEVEL 0x00000010 /* TPR of CPUs accepting INT */
+#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
+#endif /** TEST_LOPRIO */
/* XXX these 2 don't really belong here... */
#define COUNT_FIELD 0x00ffffff /* count portion of the lock */
diff --git a/sys/i386/include/apicreg.h b/sys/i386/include/apicreg.h
index f587184..170eb78 100644
--- a/sys/i386/include/apicreg.h
+++ b/sys/i386/include/apicreg.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: apic.h,v 1.7 1997/07/15 02:47:52 fsmp Exp $
+ * $Id: apic.h,v 1.5 1997/07/18 19:47:48 smp Exp smp $
*/
#ifndef _MACHINE_APIC_H_
@@ -220,7 +220,10 @@ typedef struct IOAPIC ioapic_t;
* various code 'logical' values
*/
+#ifdef TEST_LOPRIO
#define LOPRIO_LEVEL 0x00000010 /* TPR of CPUs accepting INT */
+#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
+#endif /** TEST_LOPRIO */
/* XXX these 2 don't really belong here... */
#define COUNT_FIELD 0x00ffffff /* count portion of the lock */
diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h
index f1cd1a2..de10f8c 100644
--- a/sys/i386/include/mptable.h
+++ b/sys/i386/include/mptable.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
diff --git a/sys/i386/include/smptests.h b/sys/i386/include/smptests.h
index 07ccb1f..a01797b 100644
--- a/sys/i386/include/smptests.h
+++ b/sys/i386/include/smptests.h
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smptests.h,v 1.10 1997/07/15 03:27:12 fsmp Exp $
+ * $Id: smptests.h,v 1.15 1997/07/18 19:47:48 smp Exp smp $
*/
#ifndef _MACHINE_SMPTESTS_H_
@@ -35,7 +35,8 @@
/*
- * address of POST hardware port
+ * Address of POST hardware port.
+ * Defining this enables POSTCODE macros.
*
#define POST_ADDR 0x80
*/
@@ -50,19 +51,18 @@
#define TEST_ALTTIMER
/*
- * send 8254 timer INTs to all CPUs in LOPRIO mode
+ * Send 8254 timer INTs to all CPUs in LOPRIO mode.
*
*/
#define TIMER_ALL
/*
- * IPI for stop/restart of other CPUs
+ * Send CPUSTOP IPI for stop/restart of other CPUs on DDB break.
*
-#define COUNT_CSHITS
-#define DEBUG_CPUSTOP
*/
-#define TEST_CPUSTOP
+#define CPUSTOP_ON_DDBBREAK
+#define VERBOSE_CPUSTOP_ON_DDBBREAK
/*
@@ -93,6 +93,7 @@
*
#define COUNT_XINVLTLB_HITS
#define COUNT_SPURIOUS_INTS
+#define COUNT_CSHITS
*/
@@ -167,12 +168,14 @@
/*
- * these are all temps for debugging CPUSTOP code in mplock.s
- * they will (hopefully) go away soon...
+ * these are all temps for debugging...
*
#define GUARD_INTS
*/
+/*
+ * This macro traps unexpected INTs to a specific CPU, eg. GUARD_CPU.
+ */
#ifdef GUARD_INTS
#define GUARD_CPU 1
#define MAYBE_PANIC(irq_num) \
diff --git a/sys/i386/isa/apic_vector.s b/sys/i386/isa/apic_vector.s
index 807223b..9ea96ca 100644
--- a/sys/i386/isa/apic_vector.s
+++ b/sys/i386/isa/apic_vector.s
@@ -1,10 +1,11 @@
/*
* from: vector.s, 386BSD 0.1 unknown origin
- * $Id: apic_vector.s,v 1.7 1997/07/15 02:49:21 fsmp Exp $
+ * $Id: apic_vector.s,v 1.12 1997/07/18 19:47:13 smp Exp smp $
*/
-#include <machine/smptests.h> /** TEST_CPUSTOP */
+#include <machine/smptests.h> /** various counters */
+#include "i386/isa/intr_machdep.h"
/* convert an absolute IRQ# into a bitmask */
#define IRQ_BIT(irq_num) (1 << (irq_num))
@@ -212,10 +213,6 @@ _Xinvltlb:
iret
-#ifdef TEST_CPUSTOP
-
-#include "i386/isa/intr_machdep.h"
-
/*
* Executed by a CPU when it receives an Xcpustop IPI from another CPU,
*
@@ -263,8 +260,6 @@ _Xcpustop:
popl %eax
iret
-#endif /* TEST_CPUSTOP */
-
MCOUNT_LABEL(bintr)
FAST_INTR(0,fastintr0)
@@ -359,33 +354,22 @@ _sihits:
#ifdef COUNT_XINVLTLB_HITS
.globl _xhits
_xhits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_XINVLTLB_HITS */
-#ifdef TEST_CPUSTOP
-
- .globl _stopped_cpus
+/* variables used by stop_cpus()/restart_cpus()/Xcpustop */
+ .globl _stopped_cpus, _started_cpus
_stopped_cpus:
.long 0
-
- .globl _started_cpus
_started_cpus:
.long 0
#ifdef COUNT_CSHITS
.globl _cshits
_cshits:
- .long 0
- .long 0
- .long 0
- .long 0
+ .space (NCPU * 4), 0
#endif /* COUNT_CSHITS */
-#endif /* TEST_CPUSTOP */
-
/*
* Interrupt counters and names. The format of these and the label names
diff --git a/sys/i386/isa/intr_machdep.h b/sys/i386/isa/intr_machdep.h
index 27e14af..e9c0e84 100644
--- a/sys/i386/isa/intr_machdep.h
+++ b/sys/i386/isa/intr_machdep.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
- * $Id: intr_machdep.h,v 1.6 1997/07/13 00:18:33 smp Exp smp $
+ * $Id: intr_machdep.h,v 1.7 1997/07/18 19:47:13 smp Exp smp $
*/
#ifndef _I386_ISA_INTR_MACHDEP_H_
@@ -99,15 +99,13 @@
/* TLB shootdowns */
#define XINVLTLB_OFFSET (ICU_OFFSET + 32)
-#if defined(TEST_CPUSTOP)
/* IPI to signal CPUs to stop and wait for another CPU to restart them */
#define XCPUSTOP_OFFSET (ICU_OFFSET + 48)
-#endif /** TEST_CPUSTOP */
-#if defined(TEST_TEST1)
+#ifdef TEST_TEST1
/* put a 'fake' HWI in top of APIC prio 0x3x, 32 + 31 = 63 = 0x3f */
#define XTEST1_OFFSET (ICU_OFFSET + 31)
-#endif /** TEST_TEST1 */
+#endif /** TEST_TEST1 */
#ifndef LOCORE
@@ -152,18 +150,14 @@ inthand_t
IDTVEC(intr20), IDTVEC(intr21), IDTVEC(intr22), IDTVEC(intr23);
inthand_t
- Xinvltlb,
- Xspuriousint;
-
-#if defined(TEST_CPUSTOP)
-inthand_t
+ Xinvltlb, /* TLB shootdowns */
+ Xspuriousint, /* handle APIC "spurious INTs" */
Xcpustop; /* stop & wait for another CPU to restart it */
-#endif /** TEST_CPUSTOP */
-#if defined(TEST_CPUSTOP)
+#ifdef TEST_TEST1
inthand_t
Xtest1; /* 'fake' HWI in top of APIC prio 0x3x, 32+31 = 0x3f */
-#endif /** TEST_TEST1 */
+#endif /** TEST_TEST1 */
struct isa_device;
diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c
index f1cd1a2..de10f8c 100644
--- a/sys/kern/subr_smp.c
+++ b/sys/kern/subr_smp.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp_machdep.c,v 1.28 1997/07/17 19:44:56 dyson Exp $
+ * $Id: mp_machdep.c,v 1.16 1997/07/18 19:45:41 smp Exp smp $
*/
#include "opt_smp.h"
@@ -45,7 +45,7 @@
#include <machine/mpapic.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_CPUSTOP _TEST1 */
+#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
#include <machine/tss.h>
#include <machine/specialreg.h>
@@ -491,14 +491,12 @@ mp_enable(u_int boot_addr)
setidt(XINVLTLB_OFFSET, Xinvltlb,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#if defined(TEST_CPUSTOP)
/* install an inter-CPU IPI for CPU stop/restart */
setidt(XCPUSTOP_OFFSET, Xcpustop,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_CPUSTOP */
#if defined(TEST_TEST1)
- /* install a 'Spurious INTerrupt' vector */
+ /* install a "fake hardware INTerrupt" vector */
setidt(XTEST1_OFFSET, Xtest1,
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#endif /** TEST_TEST1 */
@@ -1741,12 +1739,6 @@ invltlb(void)
}
-#if defined(TEST_CPUSTOP)
-
-#if defined(DEBUG_CPUSTOP)
-void db_printf __P((const char *fmt, ...));
-#endif /* DEBUG_CPUSTOP */
-
/*
* When called the executing CPU will send an IPI to all other CPUs
* requesting that they halt execution.
@@ -1771,26 +1763,14 @@ stop_cpus( u_int map )
return 0;
/* send IPI to all CPUs in map */
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, map);
-#endif /* DEBUG_CPUSTOP */
-
stopped_cpus = 0;
/* send the Xcpustop IPI to all CPUs in map */
selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spin\n");
-#endif /* DEBUG_CPUSTOP */
-
while (stopped_cpus != map)
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" spun\nstopped\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
@@ -1814,21 +1794,10 @@ restart_cpus( u_int map )
if (!smp_active)
return 0;
-#if defined(DEBUG_CPUSTOP)
- db_printf("\nCPU%d restarting CPUs: 0x%08x (0x%08x)\n",
- cpuid, map, stopped_cpus);
-#endif /* DEBUG_CPUSTOP */
-
started_cpus = map; /* signal other cpus to restart */
while (started_cpus) /* wait for each to clear its bit */
/* spin */ ;
-#if defined(DEBUG_CPUSTOP)
- db_printf(" restarted\n");
-#endif /* DEBUG_CPUSTOP */
-
return 1;
}
-
-#endif /** TEST_CPUSTOP */
OpenPOWER on IntegriCloud