summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2004-07-20 20:18:54 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2004-07-20 20:18:54 +0000
commit3007bd7d121c38b72cd0b72b8f749bfc55180df8 (patch)
tree3de5efa1d62c2db691af4ac97805b33a397b0f65 /sys/arch
parent68589e5f2f9ead70b37b7aeb6bcd9e296ce26f23 (diff)
Use mutex instead of SIMPLELOCK for protecting ddb on mp systems.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/db_interface.c10
-rw-r--r--sys/arch/i386/i386/db_mp.c51
-rw-r--r--sys/arch/i386/include/db_machdep.h4
3 files changed, 24 insertions, 41 deletions
diff --git a/sys/arch/i386/i386/db_interface.c b/sys/arch/i386/i386/db_interface.c
index bbf7a09c6bc..5c8786489bc 100644
--- a/sys/arch/i386/i386/db_interface.c
+++ b/sys/arch/i386/i386/db_interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_interface.c,v 1.15 2004/07/02 16:29:55 niklas Exp $ */
+/* $OpenBSD: db_interface.c,v 1.16 2004/07/20 20:18:53 art Exp $ */
/* $NetBSD: db_interface.c,v 1.22 1996/05/03 19:42:00 christos Exp $ */
/*
@@ -36,6 +36,7 @@
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/systm.h>
+#include <sys/mutex.h>
#include <uvm/uvm_extern.h>
@@ -116,12 +117,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 /* MULTIPROCESSOR */
@@ -347,7 +346,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 /* MULTIPROCESSOR */
}
diff --git a/sys/arch/i386/i386/db_mp.c b/sys/arch/i386/i386/db_mp.c
index 3c1b184a927..9fd899d1f69 100644
--- a/sys/arch/i386/i386/db_mp.c
+++ b/sys/arch/i386/i386/db_mp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_mp.c,v 1.3 2004/06/21 22:41:11 andreas Exp $ */
+/* $OpenBSD: db_mp.c,v 1.4 2004/07/20 20:18:53 art Exp $ */
/*
* Copyright (c) 2003, 2004 Andreas Gunnarsson <andreas@openbsd.org>
@@ -20,13 +20,14 @@
#include <sys/simplelock.h>
#include <machine/db_machdep.h>
+#include <sys/mutex.h>
#include <ddb/db_output.h>
-struct SIMPLELOCK ddb_mp_slock;
+struct mutex ddb_mp_mutex = MUTEX_INITIALIZER(IPL_HIGH);
-volatile int ddb_state = DDB_STATE_NOT_RUNNING; /* protected by ddb_mp_slock */
-volatile cpuid_t ddb_active_cpu; /* protected by ddb_mp_slock */
+volatile int ddb_state = DDB_STATE_NOT_RUNNING; /* protected by ddb_mp_mutex */
+volatile cpuid_t ddb_active_cpu; /* protected by ddb_mp_mutex */
extern volatile boolean_t db_switch_cpu;
extern volatile long db_switch_to_cpu;
@@ -43,17 +44,16 @@ extern volatile long db_switch_to_cpu;
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);
+ mtx_leave(&ddb_mp_mutex);
for (i = 0; i < I386_MAXPROCS; i++) {
if (cpu_info[i] != NULL && i != cpu_number() &&
cpu_info[i]->ci_ddb_paused != CI_DDB_STOPPED) {
@@ -61,7 +61,6 @@ db_enter_ddb()
i386_send_ipi(cpu_info[i], I386_IPI_DDB);
}
}
- splx(s);
return (1);
}
@@ -72,8 +71,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);
}
@@ -91,27 +89,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);
}
}
@@ -119,33 +113,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);
i386_send_ipi(cpu_info[cpu], I386_IPI_DDB);
} else {
- SIMPLE_UNLOCK(&ddb_mp_slock);
- splx(s);
+ mtx_leave(&ddb_mp_mutex);
}
}
diff --git a/sys/arch/i386/include/db_machdep.h b/sys/arch/i386/include/db_machdep.h
index d39c95fd135..ef3996305a1 100644
--- a/sys/arch/i386/include/db_machdep.h
+++ b/sys/arch/i386/include/db_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.h,v 1.12 2004/07/02 16:29:55 niklas Exp $ */
+/* $OpenBSD: db_machdep.h,v 1.13 2004/07/20 20:18:53 art Exp $ */
/* $NetBSD: db_machdep.h,v 1.9 1996/05/03 19:23:59 christos Exp $ */
/*
@@ -125,7 +125,7 @@ void db_startcpu(int cpu);
void db_stopcpu(int cpu);
void i386_ipi_db(struct cpu_info *);
-extern struct SIMPLELOCK ddb_mp_slock;
+extern struct mutex ddb_mp_mutex;
/* For ddb_state */
#define DDB_STATE_NOT_RUNNING 0