svn commit: r329420 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Sat Feb 17 00:23:29 UTC 2018


Author: mjg
Date: Sat Feb 17 00:23:28 2018
New Revision: 329420
URL: https://svnweb.freebsd.org/changeset/base/329420

Log:
  Postpone sx_sunlock(&proctree_lock) on fork until after allproc is dropped.
  
  There is a significant contention on the lock during -j 128 package build.
  This change drops total wait time on this lock by 60%.

Modified:
  head/sys/kern/kern_fork.c

Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c	Sat Feb 17 00:21:50 2018	(r329419)
+++ head/sys/kern/kern_fork.c	Sat Feb 17 00:23:28 2018	(r329420)
@@ -401,8 +401,6 @@ do_fork(struct thread *td, struct fork_req *fr, struct
 
 	trypid = fork_findpid(fr->fr_flags);
 
-	sx_sunlock(&proctree_lock);
-
 	p2->p_state = PRS_NEW;		/* protect against others */
 	p2->p_pid = trypid;
 	AUDIT_ARG_PID(p2->p_pid);
@@ -414,6 +412,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct
 	PROC_LOCK(p1);
 
 	sx_xunlock(&allproc_lock);
+	sx_sunlock(&proctree_lock);
 
 	bcopy(&p1->p_startcopy, &p2->p_startcopy,
 	    __rangeof(struct proc, p_startcopy, p_endcopy));
@@ -977,8 +976,8 @@ fork1(struct thread *td, struct fork_req *fr)
 	}
 
 	error = EAGAIN;
-	sx_sunlock(&proctree_lock);
 	sx_xunlock(&allproc_lock);
+	sx_sunlock(&proctree_lock);
 #ifdef MAC
 	mac_proc_destroy(newproc);
 #endif


More information about the svn-src-all mailing list