Author: mjg
Date: Sun Oct  5 07:21:41 2014
New Revision: 272560
URL: https://svnweb.freebsd.org/changeset/base/272560

Log:
  Avoid unnecessary ppeers_lock acquisition in exit1.
  
  MFC after:    1 week

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c   Sun Oct  5 06:28:53 2014        (r272559)
+++ head/sys/kern/kern_exit.c   Sun Oct  5 07:21:41 2014        (r272560)
@@ -265,8 +265,8 @@ exit1(struct thread *td, int rv)
        AUDIT_SYSCALL_EXIT(0, td);
 #endif
 
-       /* Are we a task leader? */
-       if (p == p->p_leader) {
+       /* Are we a task leader with peers? */
+       if (p->p_peers != NULL && p == p->p_leader) {
                mtx_lock(&ppeers_lock);
                q = p->p_peers;
                while (q != NULL) {
@@ -337,15 +337,17 @@ exit1(struct thread *td, int rv)
        /*
         * Remove ourself from our leader's peer list and wake our leader.
         */
-       mtx_lock(&ppeers_lock);
-       if (p->p_leader->p_peers) {
-               q = p->p_leader;
-               while (q->p_peers != p)
-                       q = q->p_peers;
-               q->p_peers = p->p_peers;
-               wakeup(p->p_leader);
+       if (p->p_leader->p_peers != NULL) {
+               mtx_lock(&ppeers_lock);
+               if (p->p_leader->p_peers != NULL) {
+                       q = p->p_leader;
+                       while (q->p_peers != p)
+                               q = q->p_peers;
+                       q->p_peers = p->p_peers;
+                       wakeup(p->p_leader);
+               }
+               mtx_unlock(&ppeers_lock);
        }
-       mtx_unlock(&ppeers_lock);
 
        vmspace_exit(td);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to