Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Add KERNEL_LOCK (et al.) to run MULTIPROCESSOR kern...
details: https://anonhg.NetBSD.org/src/rev/f5ba92673dee
branches: trunk
changeset: 499641:f5ba92673dee
user: tsubai <tsubai%NetBSD.org@localhost>
date: Sat Nov 25 15:49:43 2000 +0000
description:
Add KERNEL_LOCK (et al.) to run MULTIPROCESSOR kernel on a single cpu system.
diffstat:
sys/arch/macppc/macppc/locore.S | 15 +++--
sys/arch/powerpc/powerpc/trap.c | 102 +++++++++++++++++++++++----------------
2 files changed, 68 insertions(+), 49 deletions(-)
diffs (292 lines):
diff -r 44701bb3528d -r f5ba92673dee sys/arch/macppc/macppc/locore.S
--- a/sys/arch/macppc/macppc/locore.S Sat Nov 25 13:32:51 2000 +0000
+++ b/sys/arch/macppc/macppc/locore.S Sat Nov 25 15:49:43 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.28 2000/11/16 05:34:03 thorpej Exp $ */
+/* $NetBSD: locore.S,v 1.29 2000/11/25 15:49:43 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -182,7 +182,7 @@
mr 4,1 /* end of mem reserved for kernel */
xor 0,0,0
stwu 0,-16(1) /* end of stack chain */
-
+
lis 8,openfirmware_entry@ha
stw 5,openfirmware_entry@l(8) /* save client interface handler */
lis 3,__start@ha
@@ -315,7 +315,7 @@
new stack */
stw 6,-4(7) /* setup return pointer */
stwu 1,-8(7)
-
+
stw 7,-8(4)
addi 3,1,8
@@ -329,7 +329,7 @@
lwz 0,4(1) /* get saved msr from abused slot */
mtmsr 0
-
+
lwz 1,0(1) /* return */
lwz 0,4(1)
mtlr 0
@@ -347,7 +347,7 @@
or. 9,9,9
bne- .Lsw1 /* at least one queue non-empty */
-
+
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
bl _C_LABEL(sched_unlock_idle)
#endif
@@ -464,7 +464,7 @@
addi 4,4,_C_LABEL(sched_qs)@l
slwi 3,10,3
add 3,3,4 /* select queue */
-
+
lwz 31,P_FORW(3) /* unlink first proc from queue */
lwz 4,P_FORW(31)
stw 4,P_FORW(3)
@@ -599,6 +599,9 @@
*/
.globl _C_LABEL(fork_trampoline)
_C_LABEL(fork_trampoline):
+#if defined(MULTIPROCESSOR)
+ bl _C_LABEL(proc_trampoline_mp)
+#endif
xor 3,3,3
bl _C_LABEL(lcsplx)
mtlr 31
diff -r 44701bb3528d -r f5ba92673dee sys/arch/powerpc/powerpc/trap.c
--- a/sys/arch/powerpc/powerpc/trap.c Sat Nov 25 13:32:51 2000 +0000
+++ b/sys/arch/powerpc/powerpc/trap.c Sat Nov 25 15:49:43 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.31 2000/11/25 03:00:48 matt Exp $ */
+/* $NetBSD: trap.c,v 1.32 2000/11/25 15:49:43 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -31,9 +31,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "opt_altivec.h"
#include "opt_ddb.h"
#include "opt_ktrace.h"
-#include "opt_altivec.h"
#include <sys/param.h>
#include <sys/proc.h>
@@ -52,7 +52,7 @@
#include <machine/psl.h>
#include <machine/trap.h>
-/* These definitions should probably be somewhere else XXX */
+/* These definitions should probably be somewhere else XXX */
#define FIRSTARG 3 /* first argument is in reg 3 */
#define NARGREG 8 /* 8 args are in registers */
#define MOREARGS(sp) ((caddr_t)((int)(sp) + 8)) /* more args go here */
@@ -69,6 +69,7 @@
struct proc *p = curproc;
int type = frame->exc;
u_quad_t sticks;
+ int ftype, rv;
if (frame->srr1 & PSL_PR) {
type |= EXC_USER;
@@ -77,21 +78,23 @@
switch (type) {
case EXC_TRC|EXC_USER:
+ KERNEL_PROC_LOCK(p);
frame->srr1 &= ~PSL_SE;
trapsignal(p, SIGTRAP, EXC_TRC);
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_DSI:
{
vm_map_t map;
vaddr_t va;
- int ftype;
faultbuf *fb;
-
+
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
map = kernel_map;
va = frame->dar;
if ((va >> ADDR_SR_SHFT) == USER_SR) {
sr_t user_sr;
-
+
asm ("mfsr %0, %1"
: "=r"(user_sr) : "K"(USER_SR));
va &= ADDR_PIDX | ADDR_POFF;
@@ -102,8 +105,9 @@
ftype = VM_PROT_READ | VM_PROT_WRITE;
else
ftype = VM_PROT_READ;
- if (uvm_fault(map, trunc_page(va), 0, ftype)
- == KERN_SUCCESS)
+ rv = uvm_fault(map, trunc_page(va), 0, ftype);
+ KERNEL_UNLOCK();
+ if (rv == KERN_SUCCESS)
return;
if (fb = p->p_addr->u_pcb.pcb_onfault) {
frame->srr0 = (*fb)[0];
@@ -118,40 +122,40 @@
}
goto brain_damage;
case EXC_DSI|EXC_USER:
- {
- int ftype, rv;
-
- if (frame->dsisr & DSISR_STORE)
- ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
- if ((rv = uvm_fault(&p->p_vmspace->vm_map,
- trunc_page(frame->dar), 0, ftype))
- == KERN_SUCCESS)
- break;
- if (rv == KERN_RESOURCE_SHORTAGE) {
- printf("UVM: pid %d (%s), uid %d killed: "
- "out of swap\n",
- p->p_pid, p->p_comm,
- p->p_cred && p->p_ucred ?
- p->p_ucred->cr_uid : -1);
- trapsignal(p, SIGKILL, EXC_DSI);
- } else {
- trapsignal(p, SIGSEGV, EXC_DSI);
- }
+ KERNEL_PROC_LOCK(p);
+ if (frame->dsisr & DSISR_STORE)
+ ftype = VM_PROT_READ | VM_PROT_WRITE;
+ else
+ ftype = VM_PROT_READ;
+ if ((rv = uvm_fault(&p->p_vmspace->vm_map,
+ trunc_page(frame->dar), 0, ftype))
+ == KERN_SUCCESS) {
+ KERNEL_PROC_UNLOCK(p);
+ break;
}
+ if (rv == KERN_RESOURCE_SHORTAGE) {
+ printf("UVM: pid %d (%s), uid %d killed: "
+ "out of swap\n",
+ p->p_pid, p->p_comm,
+ p->p_cred && p->p_ucred ?
+ p->p_ucred->cr_uid : -1);
+ trapsignal(p, SIGKILL, EXC_DSI);
+ } else {
+ trapsignal(p, SIGSEGV, EXC_DSI);
+ }
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_ISI|EXC_USER:
- {
- int ftype;
-
- ftype = VM_PROT_READ | VM_PROT_EXECUTE;
- if (uvm_fault(&p->p_vmspace->vm_map,
- trunc_page(frame->srr0), 0, ftype)
- == KERN_SUCCESS)
- break;
+ KERNEL_PROC_LOCK(p);
+ ftype = VM_PROT_READ | VM_PROT_EXECUTE;
+ if (uvm_fault(&p->p_vmspace->vm_map,
+ trunc_page(frame->srr0), 0, ftype)
+ == KERN_SUCCESS) {
+ KERNEL_PROC_UNLOCK(p);
+ break;
}
trapsignal(p, SIGSEGV, EXC_ISI);
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_SC|EXC_USER:
{
@@ -161,15 +165,17 @@
register_t *params, rval[2];
int nsys, n;
register_t args[10];
-
+
+ KERNEL_PROC_LOCK(p);
+
uvmexp.syscalls++;
-
+
nsys = p->p_emul->e_nsysent;
callp = p->p_emul->e_sysent;
-
+
code = frame->fixreg[0];
params = frame->fixreg + FIRSTARG;
-
+
switch (code) {
case SYS_syscall:
/*
@@ -219,7 +225,7 @@
#endif
rval[0] = 0;
rval[1] = frame->fixreg[FIRSTARG + 1];
-
+
switch (error = (*callp->sy_call)(p, params, rval)) {
case 0:
frame->fixreg[FIRSTARG] = rval[0];
@@ -248,6 +254,7 @@
ktrsysret(p, code, error, rval[0]);
#endif
}
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_FPU|EXC_USER:
@@ -271,18 +278,22 @@
break;
case EXC_ALI|EXC_USER:
+ KERNEL_PROC_LOCK(p);
if (fix_unaligned(p, frame) != 0)
trapsignal(p, SIGBUS, EXC_ALI);
else
frame->srr0 += 4;
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_PGM|EXC_USER:
/* XXX temporarily */
+ KERNEL_PROC_LOCK(p);
if (frame->srr1 & 0x0002000)
trapsignal(p, SIGTRAP, EXC_PGM);
else
trapsignal(p, SIGILL, EXC_PGM);
+ KERNEL_PROC_UNLOCK(p);
break;
case EXC_MCHK:
@@ -372,13 +383,18 @@
struct proc *p = arg;
struct trapframe *tf = trapframe(p);
+ KERNEL_PROC_UNLOCK(p);
+
tf->fixreg[FIRSTARG] = 0;
tf->fixreg[FIRSTARG + 1] = 1;
tf->cr &= ~0x10000000;
tf->srr1 &= ~(PSL_FP|PSL_VEC); /* Disable FP & AltiVec, as we can't be them */
#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
+ if (KTRPOINT(p, KTR_SYSRET)) {
+ KERNEL_PROC_LOCK(p);
ktrsysret(p, SYS_fork, 0, 0);
+ KERNEL_PROC_UNLOCK(p);
+ }
#endif
/* Profiling? XXX */
curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
Home |
Main Index |
Thread Index |
Old Index