increment p_nrlwps in lwp_create rather than letting callers do so

as it's always decremented by lwp_exit.  this fixes error recovery of
eg. aio_procinit.
This commit is contained in:
yamt 2010-06-13 04:13:31 +00:00
parent 136da85472
commit d5dec378f9
7 changed files with 18 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_thread.c,v 1.49 2009/10/21 21:12:05 rmind Exp $ */
/* $NetBSD: mach_thread.c,v 1.50 2010/06/13 04:13:31 yamt Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.49 2009/10/21 21:12:05 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.50 2010/06/13 04:13:31 yamt Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -210,7 +210,6 @@ mach_thread_create_running(struct mach_trap_args *args)
mctc.mctc_lwp->l_private = 0;
mctc.mctc_lwp->l_stat = LSRUN;
sched_enqueue(mctc.mctc_lwp, false);
p->p_nrlwps++;
lwp_unlock(mctc.mctc_lwp);
mutex_exit(p->p_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_sa.c,v 1.12 2009/10/21 21:12:05 rmind Exp $ */
/* $NetBSD: compat_sa.c,v 1.13 2010/06/13 04:13:31 yamt Exp $ */
/*-
* Copyright (c) 2001, 2004, 2005, 2006 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
#include "opt_ktrace.h"
#include "opt_multiprocessor.h"
#include "opt_sa.h"
__KERNEL_RCSID(0, "$NetBSD: compat_sa.c,v 1.12 2009/10/21 21:12:05 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: compat_sa.c,v 1.13 2010/06/13 04:13:31 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1837,9 +1837,6 @@ sa_newcachelwp(struct lwp *l, struct sadata_vp *targ_vp)
* newlwp helpfully puts it there. Unclear if newlwp should
* be tweaked.
*/
mutex_enter(p->p_lock);
p->p_nrlwps++;
mutex_exit(p->p_lock);
vp = (targ_vp) ? targ_vp : l->l_savp;
mutex_enter(&vp->savp_mutex);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.176 2010/03/01 21:10:16 darran Exp $ */
/* $NetBSD: kern_fork.c,v 1.177 2010/06/13 04:13:31 yamt Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.176 2010/03/01 21:10:16 darran Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.177 2010/06/13 04:13:31 yamt Exp $");
#include "opt_ktrace.h"
@ -502,6 +502,7 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
getmicrotime(&p2->p_stats->p_start);
p2->p_acflag = AFORK;
lwp_lock(l2);
KASSERT(p2->p_nrlwps == 1);
if (p2->p_sflag & PS_STOPFORK) {
p2->p_nrlwps = 0;
p2->p_stat = SSTOP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_kthread.c,v 1.29 2010/05/12 15:53:20 haad Exp $ */
/* $NetBSD: kern_kthread.c,v 1.30 2010/06/13 04:13:31 yamt Exp $ */
/*-
* Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.29 2010/05/12 15:53:20 haad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.30 2010/06/13 04:13:31 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -149,12 +149,6 @@ kthread_create(pri_t pri, int flag, struct cpu_info *ci,
lwp_unlock(l);
} else
lwp_unlock_to(l, ci->ci_schedstate.spc_lwplock);
/*
* The LWP is not created suspended or stopped and cannot be set
* into those states later, so must be considered runnable.
*/
proc0.p_nrlwps++;
mutex_exit(proc0.p_lock);
/* All done! */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.148 2010/06/11 07:32:32 pooka Exp $ */
/* $NetBSD: kern_lwp.c,v 1.149 2010/06/13 04:13:31 yamt Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -209,7 +209,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.148 2010/06/11 07:32:32 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.149 2010/06/13 04:13:31 yamt Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@ -745,6 +745,7 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
l2->l_lid = p2->p_nlwpid;
LIST_INSERT_HEAD(&p2->p_lwps, l2, l_sibling);
p2->p_nlwps++;
p2->p_nrlwps++;
if ((p2->p_flag & PK_SYSTEM) == 0) {
/* Inherit an affinity */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_aio.c,v 1.31 2010/01/30 21:23:46 rmind Exp $ */
/* $NetBSD: sys_aio.c,v 1.32 2010/06/13 04:13:31 yamt Exp $ */
/*
* Copyright (c) 2007 Mindaugas Rasiukevicius <rmind at NetBSD org>
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.31 2010/01/30 21:23:46 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.32 2010/06/13 04:13:31 yamt Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@ -216,7 +216,6 @@ aio_procinit(struct proc *p)
/* Complete the initialization of thread, and run it */
aio->aio_worker = l;
p->p_nrlwps++;
lwp_lock(l);
l->l_stat = LSRUN;
l->l_priority = MAXPRI_USER;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_lwp.c,v 1.50 2010/06/06 07:46:17 skrll Exp $ */
/* $NetBSD: sys_lwp.c,v 1.51 2010/06/13 04:13:32 yamt Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.50 2010/06/06 07:46:17 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.51 2010/06/13 04:13:32 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -140,16 +140,17 @@ sys__lwp_create(struct lwp *l, const struct sys__lwp_create_args *uap,
if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) {
KASSERT(l2->l_wchan == NULL);
l2->l_stat = LSSTOP;
p->p_nrlwps--;
lwp_unlock_to(l2, spc->spc_lwplock);
} else {
KASSERT(lwp_locked(l2, spc->spc_mutex));
p->p_nrlwps++;
l2->l_stat = LSRUN;
sched_enqueue(l2, false);
lwp_unlock(l2);
}
} else {
l2->l_stat = LSSUSPENDED;
p->p_nrlwps--;
lwp_unlock_to(l2, spc->spc_lwplock);
}
mutex_exit(p->p_lock);