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;
                        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to