Home | History | Annotate | Line # | Download | only in kern
kern_fork.c revision 1.126.4.4
      1 /*	$NetBSD: kern_fork.c,v 1.126.4.4 2006/11/17 16:34:36 ad Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999, 2001, 2004 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  * This code is derived from software contributed to The NetBSD Foundation
     11  * by Charles M. Hannum.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. All advertising materials mentioning features or use of this software
     22  *    must display the following acknowledgement:
     23  *	This product includes software developed by the NetBSD
     24  *	Foundation, Inc. and its contributors.
     25  * 4. Neither the name of The NetBSD Foundation nor the names of its
     26  *    contributors may be used to endorse or promote products derived
     27  *    from this software without specific prior written permission.
     28  *
     29  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     30  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     31  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     32  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     33  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     34  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     35  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     36  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     37  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     39  * POSSIBILITY OF SUCH DAMAGE.
     40  */
     41 
     42 /*
     43  * Copyright (c) 1982, 1986, 1989, 1991, 1993
     44  *	The Regents of the University of California.  All rights reserved.
     45  * (c) UNIX System Laboratories, Inc.
     46  * All or some portions of this file are derived from material licensed
     47  * to the University of California by American Telephone and Telegraph
     48  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     49  * the permission of UNIX System Laboratories, Inc.
     50  *
     51  * Redistribution and use in source and binary forms, with or without
     52  * modification, are permitted provided that the following conditions
     53  * are met:
     54  * 1. Redistributions of source code must retain the above copyright
     55  *    notice, this list of conditions and the following disclaimer.
     56  * 2. Redistributions in binary form must reproduce the above copyright
     57  *    notice, this list of conditions and the following disclaimer in the
     58  *    documentation and/or other materials provided with the distribution.
     59  * 3. Neither the name of the University nor the names of its contributors
     60  *    may be used to endorse or promote products derived from this software
     61  *    without specific prior written permission.
     62  *
     63  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     73  * SUCH DAMAGE.
     74  *
     75  *	@(#)kern_fork.c	8.8 (Berkeley) 2/14/95
     76  */
     77 
     78 #include <sys/cdefs.h>
     79 __KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.126.4.4 2006/11/17 16:34:36 ad Exp $");
     80 
     81 #include "opt_ktrace.h"
     82 #include "opt_systrace.h"
     83 #include "opt_multiprocessor.h"
     84 
     85 #include <sys/param.h>
     86 #include <sys/systm.h>
     87 #include <sys/filedesc.h>
     88 #include <sys/kernel.h>
     89 #include <sys/malloc.h>
     90 #include <sys/pool.h>
     91 #include <sys/mount.h>
     92 #include <sys/proc.h>
     93 #include <sys/ras.h>
     94 #include <sys/resourcevar.h>
     95 #include <sys/vnode.h>
     96 #include <sys/file.h>
     97 #include <sys/acct.h>
     98 #include <sys/ktrace.h>
     99 #include <sys/vmmeter.h>
    100 #include <sys/sched.h>
    101 #include <sys/signalvar.h>
    102 #include <sys/systrace.h>
    103 #include <sys/kauth.h>
    104 
    105 #include <sys/sa.h>
    106 #include <sys/syscallargs.h>
    107 
    108 #include <uvm/uvm_extern.h>
    109 
    110 
    111 int	nprocs = 1;		/* process 0 */
    112 
    113 /*
    114  * Number of ticks to sleep if fork() would fail due to process hitting
    115  * limits. Exported in miliseconds to userland via sysctl.
    116  */
    117 int	forkfsleep = 0;
    118 
    119 /*ARGSUSED*/
    120 int
    121 sys_fork(struct lwp *l, void *v, register_t *retval)
    122 {
    123 
    124 	return (fork1(l, 0, SIGCHLD, NULL, 0, NULL, NULL, retval, NULL));
    125 }
    126 
    127 /*
    128  * vfork(2) system call compatible with 4.4BSD (i.e. BSD with Mach VM).
    129  * Address space is not shared, but parent is blocked until child exit.
    130  */
    131 /*ARGSUSED*/
    132 int
    133 sys_vfork(struct lwp *l, void *v, register_t *retval)
    134 {
    135 
    136 	return (fork1(l, FORK_PPWAIT, SIGCHLD, NULL, 0, NULL, NULL,
    137 	    retval, NULL));
    138 }
    139 
    140 /*
    141  * New vfork(2) system call for NetBSD, which implements original 3BSD vfork(2)
    142  * semantics.  Address space is shared, and parent is blocked until child exit.
    143  */
    144 /*ARGSUSED*/
    145 int
    146 sys___vfork14(struct lwp *l, void *v, register_t *retval)
    147 {
    148 
    149 	return (fork1(l, FORK_PPWAIT|FORK_SHAREVM, SIGCHLD, NULL, 0,
    150 	    NULL, NULL, retval, NULL));
    151 }
    152 
    153 /*
    154  * Linux-compatible __clone(2) system call.
    155  */
    156 int
    157 sys___clone(struct lwp *l, void *v, register_t *retval)
    158 {
    159 	struct sys___clone_args /* {
    160 		syscallarg(int) flags;
    161 		syscallarg(void *) stack;
    162 	} */ *uap = v;
    163 	int flags, sig;
    164 
    165 	/*
    166 	 * We don't support the CLONE_PID or CLONE_PTRACE flags.
    167 	 */
    168 	if (SCARG(uap, flags) & (CLONE_PID|CLONE_PTRACE))
    169 		return (EINVAL);
    170 
    171 	/*
    172 	 * Linux enforces CLONE_VM with CLONE_SIGHAND, do same.
    173 	 */
    174 	if (SCARG(uap, flags) & CLONE_SIGHAND
    175 	    && (SCARG(uap, flags) & CLONE_VM) == 0)
    176 		return (EINVAL);
    177 
    178 	flags = 0;
    179 
    180 	if (SCARG(uap, flags) & CLONE_VM)
    181 		flags |= FORK_SHAREVM;
    182 	if (SCARG(uap, flags) & CLONE_FS)
    183 		flags |= FORK_SHARECWD;
    184 	if (SCARG(uap, flags) & CLONE_FILES)
    185 		flags |= FORK_SHAREFILES;
    186 	if (SCARG(uap, flags) & CLONE_SIGHAND)
    187 		flags |= FORK_SHARESIGS;
    188 	if (SCARG(uap, flags) & CLONE_VFORK)
    189 		flags |= FORK_PPWAIT;
    190 
    191 	sig = SCARG(uap, flags) & CLONE_CSIGNAL;
    192 	if (sig < 0 || sig >= _NSIG)
    193 		return (EINVAL);
    194 
    195 	/*
    196 	 * Note that the Linux API does not provide a portable way of
    197 	 * specifying the stack area; the caller must know if the stack
    198 	 * grows up or down.  So, we pass a stack size of 0, so that the
    199 	 * code that makes this adjustment is a noop.
    200 	 */
    201 	return (fork1(l, flags, sig, SCARG(uap, stack), 0,
    202 	    NULL, NULL, retval, NULL));
    203 }
    204 
    205 /* print the 'table full' message once per 10 seconds */
    206 struct timeval fork_tfmrate = { 10, 0 };
    207 
    208 /*
    209  * General fork call.  Note that another LWP in the process may call exec()
    210  * or exit() while we are forking.  It's safe to continue here, because
    211  * neither operation will complete until all LWPs have exited the process.
    212  */
    213 int
    214 fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
    215     void (*func)(void *), void *arg, register_t *retval,
    216     struct proc **rnewprocp)
    217 {
    218 	struct proc	*p1, *p2, *parent;
    219 	uid_t		uid;
    220 	struct lwp	*l2;
    221 	int		count;
    222 	vaddr_t		uaddr;
    223 	boolean_t	inmem;
    224 
    225 	/*
    226 	 * Although process entries are dynamically created, we still keep
    227 	 * a global limit on the maximum number we will create.  Don't allow
    228 	 * a nonprivileged user to use the last few processes; don't let root
    229 	 * exceed the limit. The variable nprocs is the current number of
    230 	 * processes, maxproc is the limit.
    231 	 */
    232 	p1 = l1->l_proc;
    233 	mutex_enter(&p1->p_mutex);
    234 	uid = kauth_cred_getuid(p1->p_cred);
    235 	mutex_exit(&p1->p_mutex);
    236 	if (__predict_false((nprocs >= maxproc - 5 && uid != 0) ||
    237 			    nprocs >= maxproc)) {
    238 		static struct timeval lasttfm;
    239 
    240 		if (ratecheck(&lasttfm, &fork_tfmrate))
    241 			tablefull("proc", "increase kern.maxproc or NPROC");
    242 		if (forkfsleep)
    243 			(void)tsleep(&nprocs, PUSER, "forkmx", forkfsleep);
    244 		return (EAGAIN);
    245 	}
    246 	nprocs++;
    247 
    248 	/*
    249 	 * Increment the count of procs running with this uid. Don't allow
    250 	 * a nonprivileged user to exceed their current limit.
    251 	 */
    252 	count = chgproccnt(uid, 1);
    253 	if (__predict_false(uid != 0 && count >
    254 			    p1->p_rlimit[RLIMIT_NPROC].rlim_cur)) {
    255 		(void)chgproccnt(uid, -1);
    256 		nprocs--;
    257 		if (forkfsleep)
    258 			(void)tsleep(&nprocs, PUSER, "forkulim", forkfsleep);
    259 		return (EAGAIN);
    260 	}
    261 
    262 	/*
    263 	 * Allocate virtual address space for the U-area now, while it
    264 	 * is still easy to abort the fork operation if we're out of
    265 	 * kernel virtual address space.  The actual U-area pages will
    266 	 * be allocated and wired in uvm_fork() if needed.
    267 	 */
    268 
    269 	inmem = uvm_uarea_alloc(&uaddr);
    270 	if (__predict_false(uaddr == 0)) {
    271 		(void)chgproccnt(uid, -1);
    272 		nprocs--;
    273 		return (ENOMEM);
    274 	}
    275 
    276 	/*
    277 	 * We are now committed to the fork.  From here on, we may
    278 	 * block on resources, but resource allocation may NOT fail.
    279 	 */
    280 
    281 	/* Allocate new proc. */
    282 	p2 = proc_alloc();
    283 
    284 	/*
    285 	 * Make a proc table entry for the new process.
    286 	 * Start by zeroing the section of proc that is zero-initialized,
    287 	 * then copy the section that is copied directly from the parent.
    288 	 */
    289 	memset(&p2->p_startzero, 0,
    290 	    (unsigned) ((caddr_t)&p2->p_endzero - (caddr_t)&p2->p_startzero));
    291 	memcpy(&p2->p_startcopy, &p1->p_startcopy,
    292 	    (unsigned) ((caddr_t)&p2->p_endcopy - (caddr_t)&p2->p_startcopy));
    293 
    294 	CIRCLEQ_INIT(&p2->p_sigpend.sp_info);
    295 
    296 	LIST_INIT(&p2->p_lwps);
    297 	LIST_INIT(&p2->p_sigwaiters);
    298 
    299 	/*
    300 	 * Duplicate sub-structures as needed.
    301 	 * Increase reference counts on shared objects.
    302 	 * The p_stats and p_sigacts substructs are set in uvm_fork().
    303 	 * Inherit flags we want to keep.  The flags related to SIGCHLD
    304 	 * handling are important in order to keep a consistent behaviour
    305 	 * for the child after the fork.
    306 	 */
    307 	p2->p_flag = p1->p_flag & (P_SUGID | P_NOCLDWAIT | P_CLDSIGIGN);
    308 	p2->p_emul = p1->p_emul;
    309 	p2->p_execsw = p1->p_execsw;
    310 
    311 	if (flags & FORK_SYSTEM) {
    312 		/*
    313 		 * Mark it as a system process.  Set P_NOCLDWAIT so that
    314 		 * children are reparented to init(8) when they exit.
    315 		 * init(8) can easily wait them out for us.
    316 		 */
    317 		p2->p_flag |= (P_SYSTEM | P_NOCLDWAIT);
    318 	}
    319 
    320 	mutex_init(&p2->p_smutex, MUTEX_SPIN, IPL_SCHED);
    321 	mutex_init(&p2->p_rasmutex, MUTEX_SPIN, IPL_NONE);
    322 	mutex_init(&p2->p_mutex, MUTEX_DEFAULT, IPL_NONE);
    323 	cv_init(&p2->p_refcv, "drainref");
    324 	cv_init(&p2->p_waitcv, "wait");
    325 
    326 	p2->p_refcnt = 1;
    327 
    328 	mutex_enter(&p1->p_mutex);
    329 	kauth_cred_hold(p1->p_cred);
    330 	p2->p_cred = p1->p_cred;
    331 	mutex_exit(&p1->p_mutex);
    332 
    333 	LIST_INIT(&p2->p_raslist);
    334 #if defined(__HAVE_RAS)
    335 	ras_fork(p1, p2);
    336 #endif
    337 
    338 	/* bump references to the text vnode (for procfs) */
    339 	p2->p_textvp = p1->p_textvp;
    340 	if (p2->p_textvp)
    341 		VREF(p2->p_textvp);
    342 
    343 	if (flags & FORK_SHAREFILES)
    344 		fdshare(p1, p2);
    345 	else if (flags & FORK_CLEANFILES)
    346 		p2->p_fd = fdinit(p1);
    347 	else
    348 		p2->p_fd = fdcopy(p1);
    349 
    350 	if (flags & FORK_SHARECWD)
    351 		cwdshare(p1, p2);
    352 	else
    353 		p2->p_cwdi = cwdinit(p1);
    354 
    355 	/*
    356 	 * If p_limit is still copy-on-write, bump refcnt,
    357 	 * otherwise get a copy that won't be modified.
    358 	 * (If PL_SHAREMOD is clear, the structure is shared
    359 	 * copy-on-write.)
    360 	 */
    361 	if (p1->p_limit->p_lflags & PL_SHAREMOD)
    362 		p2->p_limit = limcopy(p1->p_limit);
    363 	else {
    364 		simple_lock(&p1->p_limit->p_slock);
    365 		p1->p_limit->p_refcnt++;
    366 		simple_unlock(&p1->p_limit->p_slock);
    367 		p2->p_limit = p1->p_limit;
    368 	}
    369 
    370 	p2->p_sflag = ((flags & FORK_PPWAIT) ? PS_PPWAIT : 0);
    371 	p2->p_lflag = 0;
    372 	p2->p_slflag = 0;
    373 	parent = (flags & FORK_NOWAIT) ? initproc : p1;
    374 	p2->p_pptr = parent;
    375 	LIST_INIT(&p2->p_children);
    376 
    377 
    378 #ifdef KTRACE
    379 	/*
    380 	 * Copy traceflag and tracefile if enabled.
    381 	 * If not inherited, these were zeroed above.
    382 	 */
    383 	if (p1->p_traceflag & KTRFAC_INHERIT) {
    384 		p2->p_traceflag = p1->p_traceflag;
    385 		if ((p2->p_tracep = p1->p_tracep) != NULL)
    386 			ktradref(p2);
    387 	}
    388 #endif
    389 
    390 	/*
    391 	 * Create signal actions for the child process.
    392 	 */
    393 	mutex_enter(&p1->p_smutex);
    394 	p2->p_sigacts = sigactsinit(p1, flags & FORK_SHARESIGS);
    395 	p2->p_sflag |= (p1->p_sflag &
    396 	    (PS_PROFIL | PS_STOPFORK | PS_STOPEXEC | PS_NOCLDSTOP));
    397 	scheduler_fork_hook(p1, p2);
    398 	mutex_exit(&p1->p_smutex);
    399 
    400 	/*
    401 	 * p_stats.
    402 	 * Copy parts of p_stats, and zero out the rest.
    403 	 */
    404 	p2->p_stats = pstatscopy(p1->p_stats);
    405 
    406 	/*
    407 	 * If emulation has process fork hook, call it now.
    408 	 */
    409 	if (p2->p_emul->e_proc_fork)
    410 		(*p2->p_emul->e_proc_fork)(p2, p1, flags);
    411 
    412 	/*
    413 	 * ...and finally, any other random fork hooks that subsystems
    414 	 * might have registered.
    415 	 */
    416 	doforkhooks(p2, p1);
    417 
    418 	/*
    419 	 * This begins the section where we must prevent the parent
    420 	 * from being swapped.
    421 	 */
    422 	PHOLD(l1);
    423 
    424 	uvm_proc_fork(p1, p2, (flags & FORK_SHAREVM) ? TRUE : FALSE);
    425 
    426 	/*
    427 	 * Finish creating the child process.
    428 	 * It will return through a different path later.
    429 	 */
    430 	newlwp(l1, p2, uaddr, inmem, 0, stack, stacksize,
    431 	    (func != NULL) ? func : child_return,
    432 	    arg, &l2);
    433 
    434 	/*
    435 	 * It's now safe for the scheduler and other processes to see the
    436 	 * child process.
    437 	 */
    438 	rw_enter(&proclist_lock, RW_WRITER);
    439 
    440 	if (p1->p_session->s_ttyvp != NULL && p1->p_lflag & PL_CONTROLT)
    441 		p2->p_lflag |= PL_CONTROLT;
    442 
    443 	LIST_INSERT_HEAD(&parent->p_children, p2, p_sibling);
    444 	p2->p_exitsig = exitsig;		/* signal for parent on exit */
    445 
    446 	mutex_enter(&proclist_mutex);
    447 	LIST_INSERT_AFTER(p1, p2, p_pglist);
    448 	LIST_INSERT_HEAD(&allproc, p2, p_list);
    449 	mutex_exit(&proclist_mutex);
    450 
    451 	rw_exit(&proclist_lock);
    452 
    453 #ifdef SYSTRACE
    454 	/* Tell systrace what's happening. */
    455 	if (ISSET(p1->p_flag, P_SYSTRACE))
    456 		systrace_sys_fork(p1, p2);
    457 #endif
    458 
    459 #ifdef __HAVE_SYSCALL_INTERN
    460 	(*p2->p_emul->e_syscall_intern)(p2);
    461 #endif
    462 
    463 	/*
    464 	 * Now can be swapped.
    465 	 */
    466 	PRELE(l1);
    467 
    468 	/*
    469 	 * Notify any interested parties about the new process.
    470 	 */
    471 	KNOTE(&p1->p_klist, NOTE_FORK | p2->p_pid);
    472 
    473 	/*
    474 	 * Update stats now that we know the fork was successful.
    475 	 */
    476 	uvmexp.forks++;
    477 	if (flags & FORK_PPWAIT)
    478 		uvmexp.forks_ppwait++;
    479 	if (flags & FORK_SHAREVM)
    480 		uvmexp.forks_sharevm++;
    481 
    482 	/*
    483 	 * Pass a pointer to the new process to the caller.
    484 	 */
    485 	if (rnewprocp != NULL)
    486 		*rnewprocp = p2;
    487 
    488 #ifdef KTRACE
    489 	if (KTRPOINT(p2, KTR_EMUL))
    490 		p2->p_traceflag |= KTRFAC_TRC_EMUL;
    491 #endif
    492 
    493 	/*
    494 	 * Make child runnable, set start time, and add to run queue except
    495 	 * if the parent requested the child to start in SSTOP state.
    496 	 */
    497 	mutex_enter(&p2->p_smutex);
    498 
    499 	getmicrotime(&p2->p_stats->p_start);
    500 	if (p2->p_sflag & PS_PROFIL)
    501 		startprofclock(p2);
    502 	p2->p_acflag = AFORK;
    503 	if (p2->p_sflag & PS_STOPFORK) {
    504 		lwp_lock(l2);
    505 		p2->p_nrlwps = 0;
    506 		p2->p_stat = SSTOP;
    507 		mutex_enter(&proc_stop_mutex);
    508 		p1->p_nstopchild++;
    509 		mutex_exit(&proc_stop_mutex);
    510 		l2->l_stat = LSSTOP;
    511 		lwp_unlock(l2);
    512 	} else {
    513 		p2->p_nrlwps = 1;
    514 		p2->p_stat = SACTIVE;
    515 		lwp_lock(l2);
    516 		lwp_relock(l2, &sched_mutex);
    517 		l2->l_stat = LSRUN;
    518 		setrunqueue(l2);
    519 		lwp_unlock(l2);
    520 	}
    521 
    522 	/*
    523 	 * Preserve synchronization semantics of vfork.  If waiting for
    524 	 * child to exec or exit, set PS_PPWAIT on child, and sleep on our
    525 	 * proc (in case of exit).
    526 	 */
    527 	if (flags & FORK_PPWAIT)
    528 		while (p2->p_sflag & PS_PPWAIT)
    529 			cv_wait(&p1->p_waitcv, &p2->p_smutex);
    530 
    531 	mutex_exit(&p2->p_smutex);
    532 
    533 	/*
    534 	 * Return child pid to parent process,
    535 	 * marking us as parent via retval[1].
    536 	 */
    537 	if (retval != NULL) {
    538 		retval[0] = p2->p_pid;
    539 		retval[1] = 0;
    540 	}
    541 
    542 	return (0);
    543 }
    544 
    545 #if defined(MULTIPROCESSOR)
    546 /*
    547  * XXX This is a slight hack to get newly-formed processes to
    548  * XXX acquire the kernel lock as soon as they run.
    549  */
    550 void
    551 proc_trampoline_mp(void)
    552 {
    553 	struct lwp *l;
    554 
    555 	l = curlwp;
    556 
    557 	KERNEL_LOCK(1, l);
    558 }
    559 #endif
    560