Module Name: src Committed By: ad Date: Mon Jan 27 21:58:16 UTC 2020
Modified Files: src/sys/kern: kern_lwp.c Log Message: - lwp_wait(): if the process is exiting and no progress is being made, wake every clock tick and kick all the LWPs again. - lwp_create(): copy the LW_WEXIT etc flags while holding the parent's p_lock. Copy only LW_WREBOOT in the case of fork(), since a pending coredump or exit() in the parent process isn't for the child. To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/sys/kern/kern_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.221 src/sys/kern/kern_lwp.c:1.222 --- src/sys/kern/kern_lwp.c:1.221 Sun Jan 26 19:06:24 2020 +++ src/sys/kern/kern_lwp.c Mon Jan 27 21:58:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.221 2020/01/26 19:06:24 ad Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.222 2020/01/27 21:58:16 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020 @@ -211,7 +211,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.221 2020/01/26 19:06:24 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.222 2020/01/27 21:58:16 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -653,8 +653,7 @@ lwp_wait(struct lwp *l, lwpid_t lid, lwp */ if (exiting) { KASSERT(p->p_nlwps > 1); - cv_wait(&p->p_lwpcv, p->p_lock); - error = EAGAIN; + error = cv_timedwait(&p->p_lwpcv, p->p_lock, 1); break; } @@ -662,9 +661,6 @@ lwp_wait(struct lwp *l, lwpid_t lid, lwp * If all other LWPs are waiting for exits or suspends * and the supply of zombies and potential zombies is * exhausted, then we are about to deadlock. - * - * If the process is exiting (and this LWP is not the one - * that is coordinating the exit) then bail out now. */ if ((p->p_sflag & PS_WEXIT) != 0 || p->p_nrlwps + p->p_nzlwps - p->p_ndlwps <= p->p_nlwpwait) { @@ -839,7 +835,7 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_ l2->l_inheritedprio = -1; l2->l_protectprio = -1; l2->l_auxprio = -1; - l2->l_flag = (l1->l_flag & (LW_WEXIT | LW_WREBOOT | LW_WCORE)); + l2->l_flag = 0; l2->l_pflag = LP_MPSAFE; TAILQ_INIT(&l2->l_ld_locks); l2->l_psrefs = 0; @@ -921,6 +917,11 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_ } else l2->l_prflag = 0; + if (l1->l_proc == p2) + l2->l_flag |= (l1->l_flag & (LW_WEXIT | LW_WREBOOT | LW_WCORE)); + else + l2->l_flag |= (l1->l_flag & LW_WREBOOT); + l2->l_sigstk = *sigstk; l2->l_sigmask = *sigmask; TAILQ_INIT(&l2->l_sigpend.sp_info);