Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Nov 2016 18:21:48 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309111 - head/sys/kern
Message-ID:  <201611241821.uAOILmlF070485@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Nov 24 18:21:48 2016
New Revision: 309111
URL: https://svnweb.freebsd.org/changeset/base/309111

Log:
  wait: avoid relocking the child if proc_to_reap returns 1
  
  proc_to_reap would always unlock. However, if it returned 1, kern_wait6
  would immediately lock it again. Save the dance.
  
  Reviewed by:	kib

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Thu Nov 24 17:07:15 2016	(r309110)
+++ head/sys/kern/kern_exit.c	Thu Nov 24 18:21:48 2016	(r309111)
@@ -1061,7 +1061,6 @@ proc_to_reap(struct thread *td, struct p
 		proc_reap(td, p, status, options);
 		return (-1);
 	}
-	PROC_UNLOCK(p);
 	return (1);
 }
 
@@ -1162,7 +1161,7 @@ loop:
 			return (0);
 		}
 
-		PROC_LOCK(p);
+		PROC_LOCK_ASSERT(p, MA_OWNED);
 		PROC_SLOCK(p);
 
 		if ((options & WTRAPPED) != 0 &&
@@ -1263,6 +1262,7 @@ loop:
 			if (ret != 0) {
 				KASSERT(ret != -1, ("reaped an orphan (pid %d)",
 				    (int)td->td_retval[0]));
+				PROC_UNLOCK(p);
 				nfound++;
 				break;
 			}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611241821.uAOILmlF070485>