diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-06-10 18:05:32 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-06-10 18:05:32 +0000 |
commit | c97f584948035e1a4ccf9be653268e794f1cc4a7 (patch) | |
tree | 56eeccaecff52fce2182bbffb06eb500c1ee370c | |
parent | 679b7378ed7ee80740ab0733174fffb7f28738e4 (diff) |
Switch sgi to per-process AST, and move ast() from interrupt.c to trap.c
where it can use userret() instead of duplicating it.
-rw-r--r-- | sys/arch/mips64/include/cpu.h | 28 | ||||
-rw-r--r-- | sys/arch/mips64/include/proc.h | 3 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/exception.S | 16 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/interrupt.c | 30 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 54 | ||||
-rw-r--r-- | sys/arch/sgi/include/intr.h | 3 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/genassym.cf | 5 |
7 files changed, 67 insertions, 72 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h index 73d559c8589..f16edec4b76 100644 --- a/sys/arch/mips64/include/cpu.h +++ b/sys/arch/mips64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.32 2009/06/02 17:55:37 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.33 2009/06/10 18:05:30 miod Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -358,10 +358,13 @@ extern vaddr_t uncached_base; #include <sys/sched.h> struct cpu_info { - struct schedstate_percpu ci_schedstate; + struct proc *ci_curproc; - struct proc *ci_curproc; - u_int32_t ci_randseed; + struct schedstate_percpu + ci_schedstate; + int ci_want_resched; /* need_resched() invoked */ + + u_int32_t ci_randseed; /* per cpu random seed */ }; extern struct cpu_info cpu_info_primary; @@ -401,25 +404,28 @@ extern int int_nest_cntr; * Preempt the current process if in interrupt from user mode, * or after the current trap/syscall if in system mode. */ -#define need_resched(info) { want_resched = 1; aston(); } -#define clear_resched(ci) want_resched = 0 +#define need_resched(ci) \ + do { \ + (ci)->ci_want_resched = 1; \ + if ((ci)->ci_curproc != NULL) \ + aston((ci)->ci_curproc); \ + } while(0) +#define clear_resched(ci) (ci)->ci_want_resched = 0 /* * Give a profiling tick to the current process when the user profiling * buffer pages are invalid. On the PICA, request an ast to send us * through trap, marking the proc as needing a profiling tick. */ -#define need_proftick(p) aston() +#define need_proftick(p) aston(p) /* * Notify the current process (p) that it has a signal pending, * process as soon as possible. */ -#define signotify(p) aston() - -#define aston() (astpending = 1) +#define signotify(p) aston(p) -extern int want_resched; /* resched() was called */ +#define aston(p) p->p_md.md_astpending = 1 #endif /* !_LOCORE */ #endif /* _KERNEL */ diff --git a/sys/arch/mips64/include/proc.h b/sys/arch/mips64/include/proc.h index eb7c88ab1ad..bbdd8f4a1af 100644 --- a/sys/arch/mips64/include/proc.h +++ b/sys/arch/mips64/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.2 2005/08/07 07:29:44 miod Exp $ */ +/* $OpenBSD: proc.h,v 1.3 2009/06/10 18:05:30 miod Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,6 +42,7 @@ */ struct mdproc { struct trap_frame *md_regs; /* registers on current frame */ + volatile int md_astpending; /* AST pending for this process */ int md_flags; /* machine-dependent flags */ long md_ss_addr; /* single step address for ptrace */ int md_ss_instr; /* single step instruction for ptrace */ diff --git a/sys/arch/mips64/mips64/exception.S b/sys/arch/mips64/mips64/exception.S index df4dafdbcd6..9f59cef068b 100644 --- a/sys/arch/mips64/mips64/exception.S +++ b/sys/arch/mips64/mips64/exception.S @@ -1,4 +1,4 @@ -/* $OpenBSD: exception.S,v 1.19 2009/05/27 18:58:15 miod Exp $ */ +/* $OpenBSD: exception.S,v 1.20 2009/06/10 18:05:31 miod Exp $ */ /* * Copyright (c) 2002-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -47,6 +47,8 @@ #include "assym.h" +#define curproc (cpu_info_primary + CI_CURPROC) + .set mips3 .data @@ -246,11 +248,12 @@ NNON_LEAF(u_intr, FRAMESZ(CF_SZ), ra) ITLBNOPFIX 0: - lw v0, astpending # any pending interrupts? + PTR_L t0, curproc + lw v0, P_ASTPENDING(t0) # any pending AST? beq v0, zero, 4f nop - PTR_L t0, curprocpaddr + PTR_L t0, P_ADDR(t0) # curprocpaddr SAVE_CPU_SREG(t0, 0) #ifdef PERFCNTRS @@ -431,11 +434,12 @@ NNON_LEAF(u_general, FRAMESZ(CF_SZ), ra) PTR_S a3, CF_RA_OFFS(sp) # for debugging 0: - lw v0, astpending - beqz v0, 4f + PTR_L t0, curproc + lw v0, P_ASTPENDING(t0) # any pending AST? + beq v0, zero, 4f nop - PTR_L t0, curprocpaddr + PTR_L t0, P_ADDR(t0) # curprocpaddr SAVE_CPU_SREG(t0, 0) jal ast diff --git a/sys/arch/mips64/mips64/interrupt.c b/sys/arch/mips64/mips64/interrupt.c index e431f2f9a6f..16e5c79ce89 100644 --- a/sys/arch/mips64/mips64/interrupt.c +++ b/sys/arch/mips64/mips64/interrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interrupt.c,v 1.39 2009/05/27 18:58:15 miod Exp $ */ +/* $OpenBSD: interrupt.c,v 1.40 2009/06/10 18:05:31 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -59,7 +59,7 @@ static struct evcount soft_count; static int soft_irq = 0; volatile intrmask_t cpl; -volatile intrmask_t ipending, astpending; +volatile intrmask_t ipending; intrmask_t imask[NIPLS]; @@ -121,7 +121,6 @@ int_f *pending_hand = &dummy_do_pending_int; */ void interrupt(struct trap_frame *); -void ast(void); /* * Handle an interrupt. Both kernel and user mode is handled here. @@ -232,31 +231,6 @@ set_intr(int pri, intrmask_t mask, idle_mask |= mask | SOFT_INT_MASK; } -/* - * This is called from MipsUserIntr() if astpending is set. - */ -void -ast() -{ - struct proc *p = curproc; - int sig; - - uvmexp.softs++; - - astpending = 0; - if (p->p_flag & P_OWEUPC) { - ADDUPROF(p); - } - if (want_resched) - preempt(NULL); - - /* inline userret(p) */ - - while ((sig = CURSIG(p)) != 0) /* take pending signals */ - postsig(sig); - p->p_cpu->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri; -} - struct intrhand *intrhand[INTMASKSIZE]; void diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index b7b0947fbbb..3cb3ce5b097 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.42 2009/05/22 20:37:53 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.43 2009/06/10 18:05:31 miod Exp $ */ /* tracked to 1.23 */ /* @@ -92,10 +92,9 @@ #define USERMODE(ps) (((ps) & SR_KSU_MASK) == SR_KSU_USER) -int want_resched; /* resched() was called */ struct proc *machFPCurProcPtr; /* pointer to last proc to use FP */ -char *trap_type[] = { +const char *trap_type[] = { "external interrupt", "TLB modification", "TLB miss (load or instr. fetch)", @@ -127,33 +126,30 @@ char *trap_type[] = { "reserved 28", "reserved 29", "reserved 30", - "virtual coherency data", + "virtual coherency data" }; #if defined(DDB) || defined(DEBUG) -extern register_t *tlbtrcptr; struct trapdebug trapdebug[TRAPSIZE], *trp = trapdebug; -void stacktrace(struct trap_frame *); -void logstacktrace(struct trap_frame *); -int kdbpeek(void *); -/* extern functions printed by name in stack backtraces */ -extern void idle(void); +void stacktrace(struct trap_frame *); +int kdbpeek(void *); #endif /* DDB || DEBUG */ #if defined(DDB) -int kdb_trap(int, db_regs_t *); +extern int kdb_trap(int, db_regs_t *); #endif extern void MipsSwitchFPState(struct proc *, struct trap_frame *); extern void MipsSwitchFPState16(struct proc *, struct trap_frame *); extern void MipsFPTrap(u_int, u_int, u_int, union sigval); -void trap(struct trap_frame *); +void ast(void); +void trap(struct trap_frame *); #ifdef PTRACE -int cpu_singlestep(struct proc *); +int cpu_singlestep(struct proc *); #endif -u_long MipsEmulateBranch(struct trap_frame *, long, int, u_int); +u_long MipsEmulateBranch(struct trap_frame *, long, int, u_int); static __inline__ void userret(struct proc *p) @@ -168,6 +164,29 @@ userret(struct proc *p) } /* + * Handle an AST for the current process. + */ +void +ast() +{ + struct cpu_info *ci = curcpu(); + struct proc *p = ci->ci_curproc; + + uvmexp.softs++; + +if (p->p_md.md_astpending == 0) +panic("unexpected ast p %p astpending %p\n", p, &p->p_md.md_astpending); + p->p_md.md_astpending = 0; + if (p->p_flag & P_OWEUPC) { + ADDUPROF(p); + } + if (ci->ci_want_resched) + preempt(NULL); + + userret(p); +} + +/* * Handle an exception. * In the case of a kernel trap, we return the pc where to resume if * pcb_onfault is set, otherwise, return old pc. @@ -1117,13 +1136,6 @@ stacktrace(regs) } void -logstacktrace(regs) - struct trap_frame *regs; -{ - stacktrace_subr(regs, addlog); -} - -void stacktrace_subr(regs, printfn) struct trap_frame *regs; int (*printfn)(const char*, ...); diff --git a/sys/arch/sgi/include/intr.h b/sys/arch/sgi/include/intr.h index dbb721bab9c..3ce4385c50b 100644 --- a/sys/arch/sgi/include/intr.h +++ b/sys/arch/sgi/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.24 2009/05/22 20:37:53 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.25 2009/06/10 18:05:31 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -156,7 +156,6 @@ typedef u_int32_t intrmask_t; /* Type of var holding interrupt mask */ extern volatile intrmask_t cpl; extern volatile intrmask_t ipending; -extern volatile intrmask_t astpending; extern intrmask_t imask[NIPLS]; diff --git a/sys/arch/sgi/sgi/genassym.cf b/sys/arch/sgi/sgi/genassym.cf index d4a0404e4c6..8c68800f0dd 100644 --- a/sys/arch/sgi/sgi/genassym.cf +++ b/sys/arch/sgi/sgi/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.12 2008/04/07 22:30:49 miod Exp $ +# $OpenBSD: genassym.cf,v 1.13 2009/06/10 18:05:31 miod Exp $ # # Copyright (c) 1997 Per Fogelstrom / Opsycon AB # @@ -38,11 +38,10 @@ include <machine/cpu.h> export SONPROC struct proc -#member p_priority member p_stat member p_addr member p_vmspace -#member P_UPTE p_md.md_upte +member P_ASTPENDING p_md.md_astpending member P_PC_CTRL p_md.md_pc_ctrl member P_PC_COUNT p_md.md_pc_count member P_WATCH_1 p_md.md_watch_1 |