summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2004-07-22 11:15:01 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2004-07-22 11:15:01 +0000
commit765eac1cb7e7880b381b2d03e2a03219fd279ea2 (patch)
treeb257ab1d1b234c84d611a0466bc42c26e08ff062 /sys
parent52d80369a9a9adf6703d14018736a0ffc1e15f28 (diff)
mutex instead of SIMPLELOCK for mp ddb.
"reads good" niklas@ "looks good" andreas@ "works" tedu@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/db_interface.c53
-rw-r--r--sys/arch/amd64/include/db_machdep.h5
2 files changed, 20 insertions, 38 deletions
diff --git a/sys/arch/amd64/amd64/db_interface.c b/sys/arch/amd64/amd64/db_interface.c
index 787d1b88d50..2a5332f50b7 100644
--- a/sys/arch/amd64/amd64/db_interface.c
+++ b/sys/arch/amd64/amd64/db_interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_interface.c,v 1.2 2004/06/25 17:27:01 andreas Exp $ */
+/* $OpenBSD: db_interface.c,v 1.3 2004/07/22 11:15:00 art Exp $ */
/* $NetBSD: db_interface.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */
/*
@@ -62,7 +62,7 @@ extern int trap_types;
extern boolean_t db_cmd_loop_done;
#ifdef MULTIPROCESSOR
-struct SIMPLELOCK ddb_mp_slock;
+struct mutex ddb_mp_mutex = MUTEX_INITIALIZER(IPL_HIGH);
volatile int ddb_state = DDB_STATE_NOT_RUNNING;
volatile cpuid_t ddb_active_cpu;
extern volatile int ddb_state;
@@ -125,12 +125,10 @@ kdb_trap(type, code, regs)
}
#ifdef MULTIPROCESSOR
- s = splhigh();
- SIMPLE_LOCK(&ddb_mp_slock);
+ mtx_enter(&ddb_mp_mutex);
if (ddb_state == DDB_STATE_EXITING)
ddb_state = DDB_STATE_NOT_RUNNING;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
while (db_enter_ddb()) {
#endif
@@ -276,18 +274,16 @@ db_ddbproc_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
int
db_enter_ddb()
{
- int s, i;
+ int i;
- s = splhigh();
- SIMPLE_LOCK(&ddb_mp_slock);
+ mtx_enter(&ddb_mp_mutex);
/* If we are first in, grab ddb and stop all other CPUs */
if (ddb_state == DDB_STATE_NOT_RUNNING) {
ddb_active_cpu = cpu_number();
ddb_state = DDB_STATE_RUNNING;
curcpu()->ci_ddb_paused = CI_DDB_INDDB;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
for (i = 0; i < X86_MAXPROCS; i++) {
if (cpu_info[i] != NULL && i != cpu_number() &&
cpu_info[i]->ci_ddb_paused != CI_DDB_STOPPED) {
@@ -305,8 +301,7 @@ db_enter_ddb()
cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING;
}
}
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
return (0);
}
@@ -324,27 +319,23 @@ db_enter_ddb()
curcpu()->ci_ddb_paused != CI_DDB_RUNNING) {
if (curcpu()->ci_ddb_paused == CI_DDB_SHOULDSTOP)
curcpu()->ci_ddb_paused = CI_DDB_STOPPED;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
/* Busy wait without locking, we'll confirm with lock later */
while (ddb_active_cpu != cpu_number() &&
curcpu()->ci_ddb_paused != CI_DDB_RUNNING)
; /* Do nothing */
- s = splhigh();
- SIMPLE_LOCK(&ddb_mp_slock);
+ mtx_enter(&ddb_mp_mutex);
}
/* Either enter ddb or exit */
if (ddb_active_cpu == cpu_number() && ddb_state == DDB_STATE_RUNNING) {
curcpu()->ci_ddb_paused = CI_DDB_INDDB;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
return (1);
} else {
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
return (0);
}
}
@@ -352,33 +343,24 @@ db_enter_ddb()
void
db_startcpu(int cpu)
{
- int s;
-
if (cpu != cpu_number() && cpu_info[cpu] != NULL) {
- s = splhigh();
- SIMPLE_LOCK(&ddb_mp_slock);
+ mtx_enter(&ddb_mp_mutex);
cpu_info[cpu]->ci_ddb_paused = CI_DDB_RUNNING;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
}
}
void
db_stopcpu(int cpu)
{
- int s;
-
- s = splhigh();
- SIMPLE_LOCK(&ddb_mp_slock);
+ mtx_enter(&ddb_mp_mutex);
if (cpu != cpu_number() && cpu_info[cpu] != NULL &&
cpu_info[cpu]->ci_ddb_paused != CI_DDB_STOPPED) {
cpu_info[cpu]->ci_ddb_paused = CI_DDB_SHOULDSTOP;
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
x86_send_ipi(cpu_info[cpu], X86_IPI_DDB);
} else {
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
}
}
@@ -412,7 +394,6 @@ db_machine_init()
if (cpu_info[i] != NULL)
cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING;
}
- SIMPLE_LOCK_INIT(&ddb_mp_slock);
#endif
}
diff --git a/sys/arch/amd64/include/db_machdep.h b/sys/arch/amd64/include/db_machdep.h
index 9b61b0bed70..600e1e95557 100644
--- a/sys/arch/amd64/include/db_machdep.h
+++ b/sys/arch/amd64/include/db_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.h,v 1.2 2004/06/25 17:27:01 andreas Exp $ */
+/* $OpenBSD: db_machdep.h,v 1.3 2004/07/22 11:15:00 art Exp $ */
/* $NetBSD: db_machdep.h,v 1.2 2003/04/29 17:06:04 scw Exp $ */
/*
@@ -37,6 +37,7 @@
#include <sys/param.h>
#include <uvm/uvm_extern.h>
#include <machine/trap.h>
+#include <sys/mutex.h>
typedef vaddr_t db_addr_t; /* address - unsigned */
typedef long db_expr_t; /* expression - signed */
@@ -127,7 +128,7 @@ void db_startcpu(int cpu);
void db_stopcpu(int cpu);
void x86_ipi_db(struct cpu_info *);
-extern struct SIMPLELOCK ddb_mp_slock;
+extern struct mutex ddb_mp_mutex;
#define DDB_STATE_NOT_RUNNING 0
#define DDB_STATE_RUNNING 1