summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-11-28 22:21:17 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-11-28 22:21:17 +0000
commit9407a589e754c164aa72b047d01fb5e153c17425 (patch)
treed3da1224369b1d10190c82a3eb85dea65d1c4788 /sys/arch
parent9ae0cfd2137b39e09286f9be25b44548e121e4ad (diff)
Switch to per-process AST flags and clean AST-related codepaths; speeds up
forks as a bonus. Tested on luna88k and mvme88k by aoyama@ martin@ and I.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c3
-rw-r--r--sys/arch/m88k/include/cpu.h26
-rw-r--r--sys/arch/m88k/include/proc.h3
-rw-r--r--sys/arch/m88k/m88k/eh_common.S85
-rw-r--r--sys/arch/m88k/m88k/genassym.cf5
-rw-r--r--sys/arch/m88k/m88k/trap.c6
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c3
7 files changed, 68 insertions, 63 deletions
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index 195f97e3cfe..af60b1837d6 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.24 2005/10/13 19:48:32 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.25 2005/11/28 22:21:12 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -200,7 +200,6 @@ struct nvram_t {
vaddr_t obiova;
int ssir;
-int want_ast;
int want_resched;
int physmem; /* available physical memory, in pages */
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h
index 948bb00fe56..fc3a85cfba1 100644
--- a/sys/arch/m88k/include/cpu.h
+++ b/sys/arch/m88k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.7 2005/10/13 19:48:32 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.8 2005/11/28 22:21:15 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -95,8 +95,8 @@ struct clockframe {
struct trapframe tf;
};
-#define CLKF_USERMODE(framep) ((((struct trapframe *)(framep))->tf_epsr & PSR_MODE) == 0)
-#define CLKF_PC(framep) (((struct trapframe *)(framep))->tf_sxip & XIP_ADDR)
+#define CLKF_USERMODE(framep) (((framep)->tf.tf_epsr & PSR_MODE) == 0)
+#define CLKF_PC(framep) ((framep)->tf.tf_sxip & XIP_ADDR)
#define CLKF_INTR(framep) (0) /* XXX temporary */
/*
@@ -108,33 +108,39 @@ struct clockframe {
#define SIR_CLOCK 2
#define setsoftint(x) (ssir |= (x))
-#define setsoftnet() (ssir |= SIR_NET)
-#define setsoftclock() (ssir |= SIR_CLOCK)
+#define setsoftnet() setsoftint(SIR_NET)
+#define setsoftclock() setsoftint(SIR_CLOCK)
-#define siroff(x) (ssir &= ~x)
+#define siroff(x) (ssir &= ~(x))
extern int ssir;
-extern int want_ast;
+
+#define aston(p) ((p)->p_md.md_astpending = 1)
/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
extern int want_resched; /* resched() was called */
-#define need_resched(ci) (want_resched = 1, want_ast = 1)
+#define need_resched(ci) \
+do { \
+ want_resched = 1; \
+ if (curproc != NULL) \
+ aston(curproc); \
+} while (0)
/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the sparc, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
*/
-#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
+#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, aston(p))
/*
* Notify the current process (p) that it has a signal pending,
* process as soon as possible.
*/
-#define signotify(p) (want_ast = 1)
+#define signotify(p) aston(p)
/*
* switchframe - should be double word aligned.
diff --git a/sys/arch/m88k/include/proc.h b/sys/arch/m88k/include/proc.h
index cd51bdb3fee..dd71a085a1c 100644
--- a/sys/arch/m88k/include/proc.h
+++ b/sys/arch/m88k/include/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.3 2005/10/12 19:05:43 miod Exp $ */
+/* $OpenBSD: proc.h,v 1.4 2005/11/28 22:21:15 miod Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -51,6 +51,7 @@ struct trapframe;
*/
struct mdproc {
struct trapframe *md_tf; /* trap/syscall registers */
+ volatile int md_astpending; /* AST pending for this process */
/*
* Single stepping is done by moving two breakpoints in the
diff --git a/sys/arch/m88k/m88k/eh_common.S b/sys/arch/m88k/m88k/eh_common.S
index e9d69126496..c85d9172c2b 100644
--- a/sys/arch/m88k/m88k/eh_common.S
+++ b/sys/arch/m88k/m88k/eh_common.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: eh_common.S,v 1.12 2005/10/12 19:05:44 miod Exp $ */
+/* $OpenBSD: eh_common.S,v 1.13 2005/11/28 22:21:15 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -1587,12 +1587,13 @@ ASLOCAL(m88100_fpu_enable)
#endif /* M88100 */
/*
- * proc_trampoline.
- * When a process setup by cpu_set_kpc() resumes, it will find itself in
+ * void proc_trampoline(void (*func)(void *), void *proc)
+ *
+ * When a process setup by cpu_fork() resumes, it will find itself in
* proc_trampoline, with r31 pointing to a ksigframe. proc_trampoline will
* load func and proc values from ksigframe, call the function, and on return
* pop off the ksigframe. Then, it will load pc from the switchframe and
- * jump there.
+ * jump there (the pc will usually be proc_do_uret).
*/
ENTRY(proc_trampoline)
@@ -1605,26 +1606,22 @@ ENTRY(proc_trampoline)
jsr.n r1
addu r31, r31, 8
+#define FPTR r14
+
/*
- * proc_do_uret
- * this is called as proc_do_uret(proc) from proc_trampoline(). This function
- * loads r31 with a pointer to the trap frame for the given proc and calls
- * return_code which loads all the registers and does an RTE.
+ * void proc_do_uret(struct proc *p)
+ *
+ * This is called as proc_do_uret(proc) from proc_trampoline(). This function
+ * loads FPTR with a pointer to the trap frame for the given proc and continues
+ * near the end of return_code, bypassing soft interrupts and AST checks, to
+ * load all the registers and do an RTE.
*/
ENTRY(proc_do_uret)
- ld r3,r2,P_ADDR /* p->p_addr */
- addu r3,r3,PCB_USER_STATE /* p->p_addr.u_pcb.user_state */
- st r3,r31,0 /* put it on the stack */
-#if defined(M88100) && defined(M88110)
-#ifdef M88110
- or.u r2, r0, hi16(_C_LABEL(cputyp))
- ld r3, r2, lo16(_C_LABEL(cputyp))
- cmp r2, r3, CPU_88110
- bb1 eq, r2, _ASM_LABEL(m88110_return_code)
- /* br _ASM_LABEL(m88100_return_code) */
-#endif
-#endif
+ ld FPTR, r2, P_ADDR /* p->p_addr */
+ br.n _ASM_LABEL(no_ast)
+ addu FPTR, FPTR, PCB_USER_STATE /* p->p_addr.u_pcb.user_state */
+
/*
* Regs r1-r30 are free. r31 is pointing at the word
@@ -1648,7 +1645,6 @@ ASLOCAL(m88100_return_code)
* go off and service that...
*/
-#define FPTR r14
ld FPTR, r31, 0 /* grab exception frame pointer */
ld r3, FPTR, REG_OFF(EF_DMT0)
bb0 DMT_VALID_BIT, r3, _ASM_LABEL(check_ast)
@@ -1689,37 +1685,40 @@ ASLOCAL(m88110_return_code)
/*
* If the saved ipl is 0, then call dosoftint() to process soft
* interrupts.
- * If returning to user land, look for ASTs
+ * If returning to userland, look for ASTs.
*/
ASLOCAL(check_ast)
- ld r2, FPTR, REG_OFF(EF_EPSR) /* get pre-exception PSR */
- bb1 PSR_INTERRUPT_DISABLE_BIT, r2, 1f /* skip if ints off */
- ld r2, FPTR, REG_OFF(EF_MASK) /* get pre-exception ipl */
- bcnd ne0, r2, 1f /* can't do softint's */
-
+ /* do not service soft interrupts if interrupts were disabled... */
+ ld r2, FPTR, REG_OFF(EF_EPSR)
+ bb1 PSR_INTERRUPT_DISABLE_BIT, r2, _ASM_LABEL(no_softint)
+ /* ...or we were not at spl0 */
+ ld r2, FPTR, REG_OFF(EF_MASK)
+ bcnd ne0, r2, _ASM_LABEL(no_softint)
+
+ /* do an inline spl0() */
bsr.n _C_LABEL(setipl)
or r2, r0, IPL_SOFTCLOCK
- /* at ipl 1 now */
bsr _C_LABEL(dosoftint)
- /* is this needed? we are going to restore the ipl below XXX nivas */
bsr.n _C_LABEL(setipl)
- or r2, r0, IPL_NONE /* ints are enabled */
- /* at ipl 0 now */
-1:
- ld r2, FPTR, REG_OFF(EF_EPSR) /* get pre-exception PSR */
- bb1 PSR_SUPERVISOR_MODE_BIT, r2, no_ast /*skip if system mode */
-
- /* should assert here - not in user mode with ints off XXX nivas */
- /* get and check want_ast */
- or.u r2, r0, hi16(_C_LABEL(want_ast))
- ld r3, r2, lo16(_C_LABEL(want_ast))
- bcnd eq0, r3, no_ast
-
+ or r2, r0, IPL_NONE
+
+ASLOCAL(no_softint)
+ /* do not service AST if not returning to user mode */
+ ld r2, FPTR, REG_OFF(EF_EPSR)
+ bb1 PSR_SUPERVISOR_MODE_BIT, r2, _ASM_LABEL(no_ast)
+
+ or.u r2, r0, hi16(_C_LABEL(curproc))
+ ld r3, r2, lo16(_C_LABEL(curproc))
+ bcnd.n eq0, r3, _ASM_LABEL(no_ast) /* no AST if no process! */
+ ld r2, r3, P_ASTPENDING
+ bcnd.n eq0, r3, _ASM_LABEL(no_ast) /* .n safe since the first
+ instruction of CALL() is
+ safe in a delay slot. */
/*
* trap(AST,...) will service ast's.
*/
#if defined(M88110) && defined(M88100)
- or.u r2, r0, hi16(_C_LABEL(cputyp))
+ or.u r2, r0, hi16(_C_LABEL(cputyp))
ld r3, r2, lo16(_C_LABEL(cputyp))
cmp r2, r3, CPU_88110
bb0 eq, r2, 2f
@@ -1728,7 +1727,7 @@ ASLOCAL(check_ast)
CALL(m88110_trap, T_ASTFLT, FPTR)
#endif
#if defined(M88110) && defined(M88100)
- br no_ast
+ br _ASM_LABEL(no_ast)
2:
#endif
#ifdef M88100
diff --git a/sys/arch/m88k/m88k/genassym.cf b/sys/arch/m88k/m88k/genassym.cf
index 1f533586cd7..41ef2f83384 100644
--- a/sys/arch/m88k/m88k/genassym.cf
+++ b/sys/arch/m88k/m88k/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.2 2004/06/13 21:49:17 niklas Exp $
+# $OpenBSD: genassym.cf,v 1.3 2005/11/28 22:21:15 miod Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -28,7 +28,7 @@
# SUCH DAMAGE.
#
# @(#)genassym.c 7.8 (Berkeley) 5/7/91
-# $Id: genassym.cf,v 1.2 2004/06/13 21:49:17 niklas Exp $
+# $Id: genassym.cf,v 1.3 2005/11/28 22:21:15 miod Exp $
#
include <sys/param.h>
@@ -51,6 +51,7 @@ member p_back
member p_addr
member p_stat
member p_wchan
+member P_ASTPENDING p_md.md_astpending
export SRUN
export SONPROC
diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c
index 1ec8c5d0973..2491feb36b6 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.21 2005/09/15 21:14:27 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.22 2005/11/28 22:21:15 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -558,7 +558,7 @@ user_fault:
case T_ASTFLT+T_USER:
uvmexp.softs++;
- want_ast = 0;
+ p->p_md.md_astpending = 0;
if (p->p_flag & P_OWEUPC) {
p->p_flag &= ~P_OWEUPC;
ADDUPROF(p);
@@ -1049,7 +1049,7 @@ m88110_user_fault:
case T_ASTFLT+T_USER:
uvmexp.softs++;
- want_ast = 0;
+ p->p_md.md_astpending = 0;
if (p->p_flag & P_OWEUPC) {
p->p_flag &= ~P_OWEUPC;
ADDUPROF(p);
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index 72f35e9336c..3cfc4e5798f 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.169 2005/10/13 19:48:37 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.170 2005/11/28 22:21:16 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -141,7 +141,6 @@ volatile u_int8_t *ivec[8];
#endif
int ssir;
-int want_ast;
int want_resched;
int physmem; /* available physical memory, in pages */