From owner-p4-projects@FreeBSD.ORG Thu May 10 15:28:23 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A209216A406; Thu, 10 May 2007 15:28:23 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3B62416A405 for ; Thu, 10 May 2007 15:28:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 2BEC713C455 for ; Thu, 10 May 2007 15:28:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l4AFSNgZ016565 for ; Thu, 10 May 2007 15:28:23 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l4AFSM8A016562 for perforce@freebsd.org; Thu, 10 May 2007 15:28:23 GMT (envelope-from jhb@freebsd.org) Date: Thu, 10 May 2007 15:28:23 GMT Message-Id: <200705101528.l4AFSM8A016562@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 119631 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2007 15:28:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=119631 Change 119631 by jhb@jhb_mutex on 2007/05/10 15:28:19 Move cpu_exit() sooner. There's no need to make this happen this late (most of them are nops, the others all deal with stuff that only affects userland). Moving it allows us to avoid dropping the proc lock and parent proc lock after notifying other processes of our exit via kevent(2) or SIGCHLD but before setting PRS_ZOMBIE. As a result, if the other process tried to do a waitpid(W_NOHANG) during that window, it wouldn't see the process as a zombie yet and would fail. Affected files ... .. //depot/projects/smpng/sys/kern/kern_exit.c#122 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_exit.c#122 (text+ko) ==== @@ -406,6 +406,16 @@ sx_xunlock(&allproc_lock); /* + * Call machine-dependent code to release any + * machine-dependent resources other than the address space. + * The address space is released by "vmspace_exitfree(p)" in + * vm_waitproc(). + */ + cpu_exit(td); + + WITNESS_WARN(WARN_PANIC, NULL, "process (pid %d) exiting", p->p_pid); + + /* * Reparent all of our children to init. */ sx_xlock(&proctree_lock); @@ -484,22 +494,6 @@ else /* LINUX thread */ psignal(p->p_pptr, p->p_sigparent); } - PROC_UNLOCK(p->p_pptr); - PROC_UNLOCK(p); - - /* - * Finally, call machine-dependent code to release the remaining - * resources including address space. - * The address space is released by "vmspace_exitfree(p)" in - * vm_waitproc(). - */ - cpu_exit(td); - - WITNESS_WARN(WARN_PANIC, &proctree_lock.lock_object, - "process (pid %d) exiting", p->p_pid); - - PROC_LOCK(p); - PROC_LOCK(p->p_pptr); sx_xunlock(&proctree_lock); /*