From fd825b0f1e20d0276a516e301030cddc4a4e8e6a Mon Sep 17 00:00:00 2001 From: chs Date: Sun, 24 Aug 2003 16:36:10 +0000 Subject: [PATCH] avoid taking the kernel lock for MPSAFE syscalls. add missing unlock in fancy case. --- sys/arch/alpha/alpha/syscall.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/arch/alpha/alpha/syscall.c b/sys/arch/alpha/alpha/syscall.c index 823754971586..1ffe9342d28c 100644 --- a/sys/arch/alpha/alpha/syscall.c +++ b/sys/arch/alpha/alpha/syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.9 2003/06/29 22:28:04 fvdl Exp $ */ +/* $NetBSD: syscall.c,v 1.10 2003/08/24 16:36:10 chs Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.9 2003/06/29 22:28:04 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.10 2003/08/24 16:36:10 chs Exp $"); #include #include @@ -168,10 +168,8 @@ syscall_plain(struct lwp *l, u_int64_t code, struct trapframe *framep) u_int64_t *args, copyargs[10]; /* XXX */ u_int hidden, nargs; struct proc *p = l->l_proc; + boolean_t needlock; - KERNEL_PROC_LOCK(l); - - uvmexp.syscalls++; l->l_md.md_tf = framep; callp = p->p_emul->e_sysent; @@ -227,7 +225,15 @@ syscall_plain(struct lwp *l, u_int64_t code, struct trapframe *framep) rval[0] = 0; rval[1] = 0; + + needlock = (callp->sy_flags & SYCALL_MPSAFE) == 0; + if (needlock) { + KERNEL_PROC_LOCK(l); + } error = (*callp->sy_call)(l, args, rval); + if (needlock) { + KERNEL_PROC_UNLOCK(l); + } switch (error) { case 0: @@ -250,7 +256,6 @@ syscall_plain(struct lwp *l, u_int64_t code, struct trapframe *framep) #ifdef SYSCALL_DEBUG scdebug_ret(l, code, error, rval); #endif - KERNEL_PROC_UNLOCK(l); userret(l); } @@ -322,6 +327,7 @@ syscall_fancy(struct lwp *l, u_int64_t code, struct trapframe *framep) rval[0] = 0; rval[1] = 0; error = (*callp->sy_call)(l, args, rval); + KERNEL_PROC_UNLOCK(l); switch (error) { case 0: