summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>2005-05-25 23:17:48 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>2005-05-25 23:17:48 +0000
commitd6ec0bc1862a4fed11c7f4ac537413b2c7e89de4 (patch)
tree6c1ed544e4a8e11ea3e107d10a95bad1273dc5a4 /sys/arch
parentfee642f79221488ebcacbd0ca219a563c8607281 (diff)
This patch is mortly art's work and was done *a year* ago. Art wants to thank
everyone for the prompt review and ok of this work ;-) Yeah, that includes me too, or maybe especially me. I am sorry. Change the sched_lock to a mutex. This fixes, among other things, the infamous "telnet localhost &" problem. The real bug in that case was that the sched_lock which is by design a non-recursive lock, was recursively acquired, and not enough releases made us hold the lock in the idle loop, blocking scheduling on the other processors. Some of the other processors would hold the biglock though, which made it impossible for cpu 0 to enter the kernel... A nice deadlock. Let me just say debugging this for days just to realize that it was all fixed in an old diff noone ever ok'd was somewhat of an anti-climax. This diff also changes splsched to be correct for all our architectures.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/ioapic.c8
-rw-r--r--sys/arch/amd64/amd64/locore.S5
-rw-r--r--sys/arch/amd64/amd64/trap.c6
-rw-r--r--sys/arch/amd64/include/pic.h4
-rw-r--r--sys/arch/hppa64/include/cpu.h4
-rw-r--r--sys/arch/i386/i386/locore.s3
-rw-r--r--sys/arch/i386/i386/trap.c11
-rw-r--r--sys/arch/i386/include/intrdefs.h4
-rw-r--r--sys/arch/mips64/mips64/interrupt.c17
-rw-r--r--sys/arch/sparc64/include/psl.h4
10 files changed, 20 insertions, 46 deletions
diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index 93a53155c65..21c4b38ddab 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.3 2004/06/27 16:17:50 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.4 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: ioapic.c,v 1.6 2003/05/15 13:30:31 fvdl Exp $ */
/*-
@@ -127,14 +127,14 @@ ioapic_lock(struct ioapic_softc *sc)
flags = read_psl();
disable_intr();
- SIMPLE_LOCK(&sc->sc_pic.pic_lock);
+ mtx_enter(&sc->sc_pic.pic_mutex);
return flags;
}
static __inline void
ioapic_unlock(struct ioapic_softc *sc, u_long flags)
{
- SIMPLE_UNLOCK(&sc->sc_pic.pic_lock);
+ mtx_leave(&sc->sc_pic.pic_mutex);
write_psl(flags);
}
@@ -294,7 +294,7 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
sc->sc_data = (volatile u_int32_t *)(bh + IOAPIC_DATA);
sc->sc_pic.pic_type = PIC_IOAPIC;
- SIMPLE_LOCK_INIT(&sc->sc_pic.pic_lock);
+ mtx_init(&sc->sc_pic.pic_mutex, IPL_NONE);
sc->sc_pic.pic_hwmask = ioapic_hwmask;
sc->sc_pic.pic_hwunmask = ioapic_hwunmask;
sc->sc_pic.pic_addroute = ioapic_addroute;
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index 0518a692380..5b7aefe62ac 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.16 2005/01/06 20:15:47 martin Exp $ */
+/* $OpenBSD: locore.S,v 1.17 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -846,9 +846,8 @@ idle_start:
cmpl $0,_C_LABEL(whichqs)(%rip)
jz idle_loop
idle_exit:
- movl $IPL_HIGH,CPUVAR(ILEVEL)
sti
-#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
+#if defined(MULTIPROCESSOR)
call _C_LABEL(sched_lock_idle)
#endif
switch_search:
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index 79c5f7c0869..0bc830b1c7b 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.4 2004/12/06 20:12:23 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.5 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
@@ -386,10 +386,6 @@ copyfault:
case T_PAGEFLT: /* allow page faults in kernel mode */
if (p == NULL)
goto we_re_toast;
-#ifdef LOCKDEBUG
- if (simple_lock_held(&sched_lock))
- goto we_re_toast;
-#endif
#ifdef MULTIPROCESSOR
if ((p->p_flag & P_BIGLOCK) == 0)
goto we_re_toast;
diff --git a/sys/arch/amd64/include/pic.h b/sys/arch/amd64/include/pic.h
index b6a222b2780..0ef3a8fa4ca 100644
--- a/sys/arch/amd64/include/pic.h
+++ b/sys/arch/amd64/include/pic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pic.h,v 1.2 2004/06/25 11:03:28 art Exp $ */
+/* $OpenBSD: pic.h,v 1.3 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: pic.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */
#ifndef _X86_PIC_H
@@ -20,7 +20,7 @@ struct pic {
struct device pic_dev;
int pic_type;
#ifdef MULTIPROCESSOR
- struct SIMPLE_LOCK pic_lock;
+ struct mutex pic_mutex;
#endif
void (*pic_hwmask)(struct pic *, int);
void (*pic_hwunmask)(struct pic *, int);
diff --git a/sys/arch/hppa64/include/cpu.h b/sys/arch/hppa64/include/cpu.h
index 8de00e76eb8..e4054861dab 100644
--- a/sys/arch/hppa64/include/cpu.h
+++ b/sys/arch/hppa64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.2 2005/04/19 15:29:48 mickey Exp $ */
+/* $OpenBSD: cpu.h,v 1.3 2005/05/25 23:17:47 niklas Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -83,8 +83,8 @@
#define IPL_VM 7
#define IPL_AUDIO 8
#define IPL_CLOCK 9
-#define IPL_SCHED 9
#define IPL_STATCLOCK 10
+#define IPL_SCHED IPL_STATCLOCK
#define IPL_HIGH 11
#define NIPL 12
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s
index a067a9b3ca9..df652a97c19 100644
--- a/sys/arch/i386/i386/locore.s
+++ b/sys/arch/i386/i386/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.87 2005/05/25 22:50:25 beck Exp $ */
+/* $OpenBSD: locore.s,v 1.88 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */
/*-
@@ -1616,7 +1616,6 @@ ENTRY(idle_loop)
jmp _C_LABEL(idle_loop)
ENTRY(idle_exit)
- movl $IPL_HIGH,CPL # splhigh
sti
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
call _C_LABEL(sched_lock_idle)
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index e0aeb203bfb..98d21021725 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.67 2004/12/06 20:12:24 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.68 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -451,15 +451,6 @@ trap(frame)
case T_PAGEFLT: /* allow page faults in kernel mode */
if (p == 0 || p->p_addr == 0)
goto we_re_toast;
-#ifdef LOCKDEBUG
- /* If we page-fault while in scheduler, we're doomed. */
-#ifdef notyet
- if (simple_lock_held(&sched_lock))
-#else
- if (__mp_lock_held(&sched_lock))
-#endif
- goto we_re_toast;
-#endif
pcb = &p->p_addr->u_pcb;
#if 0
diff --git a/sys/arch/i386/include/intrdefs.h b/sys/arch/i386/include/intrdefs.h
index c2c998b76b3..2cf218fc765 100644
--- a/sys/arch/i386/include/intrdefs.h
+++ b/sys/arch/i386/include/intrdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intrdefs.h,v 1.2 2004/06/13 21:49:16 niklas Exp $ */
+/* $OpenBSD: intrdefs.h,v 1.3 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
#ifndef _i386_INTRDEFS_H
@@ -66,8 +66,8 @@
#define IPL_IMP IPL_VM /* XXX - should not be here. */
#define IPL_AUDIO MAKEIPL(7) /* audio */
#define IPL_CLOCK MAKEIPL(8) /* clock */
-#define IPL_SCHED IPL_CLOCK
#define IPL_STATCLOCK MAKEIPL(9) /* statclock */
+#define IPL_SCHED IPL_STATCLOCK
#define IPL_HIGH MAKEIPL(9) /* everything */
#define IPL_IPI MAKEIPL(10) /* interprocessor interrupt */
diff --git a/sys/arch/mips64/mips64/interrupt.c b/sys/arch/mips64/mips64/interrupt.c
index 391c6ea26ce..95ea6c0ef8f 100644
--- a/sys/arch/mips64/mips64/interrupt.c
+++ b/sys/arch/mips64/mips64/interrupt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interrupt.c,v 1.11 2005/01/31 21:35:50 grange Exp $ */
+/* $OpenBSD: interrupt.c,v 1.12 2005/05/25 23:17:47 niklas Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -282,21 +282,10 @@ softintr()
ADDUPROF(p);
}
if (want_resched) {
- int s;
-
/*
- * Since we are curproc, clock will normally just change
- * our priority without moving us from one queue to another
- * (since the running process is not on a queue.)
- * If that happened after we put ourselves on the run queue
- * but before we switched, we might not be on the queue
- * indicated by our priority.
+ * We're being preempted.
*/
- s = splstatclock();
- setrunqueue(p);
- p->p_stats->p_ru.ru_nivcsw++;
- mi_switch();
- splx(s);
+ preempt(NULL);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
diff --git a/sys/arch/sparc64/include/psl.h b/sys/arch/sparc64/include/psl.h
index 32a36b71ec2..633a97467a9 100644
--- a/sys/arch/sparc64/include/psl.h
+++ b/sys/arch/sparc64/include/psl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: psl.h,v 1.13 2005/04/19 15:29:48 mickey Exp $ */
+/* $OpenBSD: psl.h,v 1.14 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: psl.h,v 1.20 2001/04/13 23:30:05 thorpej Exp $ */
/*
@@ -90,7 +90,7 @@
#define PIL_SER 12
#define PIL_STATCLOCK 14
#define PIL_HIGH 15
-#define PIL_SCHED PIL_CLOCK
+#define PIL_SCHED PIL_STATCLOCK
#define PIL_LOCK PIL_HIGH
/*