diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-04-07 16:21:27 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-04-07 16:21:27 +0000 |
commit | d669f660c17e3b1e0bbc59863f00f3edd1e759dd (patch) | |
tree | c2cba2348d099ec48901077e837ec84afae72736 | |
parent | e5a4ed34b18b5fbcdd66badb15e34a94dd84f102 (diff) |
Don't grab the kernel biglock for syscalls marked SY_NOLOCK;
make the amd64 code a bit nicer and make the sparc64 match that.
tested by a few;
OK toby@, dlg@, kettenis@ (for the sparc64 part).
-rw-r--r-- | sys/arch/amd64/amd64/syscall.c | 35 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/trap.c | 23 |
2 files changed, 31 insertions, 27 deletions
diff --git a/sys/arch/amd64/amd64/syscall.c b/sys/arch/amd64/amd64/syscall.c index 0d4f036bc5e..f1e09c83bba 100644 --- a/sys/arch/amd64/amd64/syscall.c +++ b/sys/arch/amd64/amd64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.11 2007/12/01 16:20:07 art Exp $ */ +/* $OpenBSD: syscall.c,v 1.12 2008/04/07 16:21:26 thib Exp $ */ /* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -74,7 +74,7 @@ syscall(struct trapframe frame) int nsys; size_t argsize, argoff; register_t code, args[9], rval[2], *argp; - int nolock; + int lock; uvmexp.syscalls++; p = curproc; @@ -133,41 +133,36 @@ syscall(struct trapframe frame) } } - nolock = (callp->sy_flags & SY_NOLOCK); + lock = !(callp->sy_flags & SY_NOLOCK); - if (!nolock) - KERNEL_PROC_LOCK(p); #ifdef SYSCALL_DEBUG - if (nolock) - KERNEL_PROC_LOCK(p); + KERNEL_PROC_LOCK(p); scdebug_call(p, code, argp); - if (nolock) - KERNEL_PROC_UNLOCK(p); + KERNEL_PROC_UNLOCK(p); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - if (nolock) - KERNEL_PROC_LOCK(p); + KERNEL_PROC_LOCK(p); ktrsyscall(p, code, callp->sy_argsize, argp); - if (nolock) - KERNEL_PROC_UNLOCK(p); + KERNEL_PROC_UNLOCK(p); } #endif - rval[0] = 0; rval[1] = frame.tf_rdx; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - if (nolock) - KERNEL_PROC_LOCK(p); + KERNEL_PROC_LOCK(p); error = systrace_redirect(code, p, argp, rval); - if (nolock) - KERNEL_PROC_UNLOCK(p); + KERNEL_PROC_UNLOCK(p); } else #endif + { + if (lock) + KERNEL_PROC_LOCK(p); error = (*callp->sy_call)(p, argp, rval); - if (!nolock) - KERNEL_PROC_UNLOCK(p); + if (lock) + KERNEL_PROC_UNLOCK(p); + } switch (error) { case 0: frame.tf_rax = rval[0]; diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index ff81f1b4535..55fc52eb12b 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.61 2008/03/26 22:07:23 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.62 2008/04/07 16:21:26 thib Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -1261,7 +1261,7 @@ syscall(tf, code, pc) int64_t *ap; const struct sysent *callp; struct proc *p; - int error = 0, new; + int error = 0, new, lock; register_t args[8]; register_t rval[2]; @@ -1282,6 +1282,8 @@ syscall(tf, code, pc) callp = p->p_emul->e_sysent; nsys = p->p_emul->e_nsysent; + lock = !(callp->sy_flags & SY_NOLOCK); + /* * The first six system call arguments are in the six %o registers. * Any arguments beyond that are in the `argument extension' area @@ -1352,20 +1354,27 @@ syscall(tf, code, pc) goto bad; } - KERNEL_PROC_LOCK(p); #ifdef SYSCALL_DEBUG + KERNEL_PROC_LOCK(p); scdebug_call(p, code, args); + KERNEL_PROC_UNLOCK(p); #endif rval[0] = 0; rval[1] = tf->tf_out[1]; #if NSYSTRACE > 0 - if (ISSET(p->p_flag, P_SYSTRACE)) + if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_PROC_LOCK(p); error = systrace_redirect(code, p, args, rval); - else + KERNEL_PROC_UNLOCK(p); + } else #endif + { + if (lock) + KERNEL_PROC_LOCK(p); error = (*callp->sy_call)(p, args, rval); - KERNEL_PROC_UNLOCK(p); - + if (lock) + KERNEL_PROC_UNLOCK(p); + } switch (error) { vaddr_t dest; case 0: |