From owner-svn-src-head@freebsd.org Sat Feb 17 00:23:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70746F20D50; Sat, 17 Feb 2018 00:23:29 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2129C7ABE7; Sat, 17 Feb 2018 00:23:29 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C13114FFC; Sat, 17 Feb 2018 00:23:29 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1H0NSfW030382; Sat, 17 Feb 2018 00:23:28 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1H0NSH0030381; Sat, 17 Feb 2018 00:23:28 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201802170023.w1H0NSH0030381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 17 Feb 2018 00:23:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329420 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 329420 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Feb 2018 00:23:29 -0000 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