From owner-svn-src-all@FreeBSD.ORG Wed Nov 23 15:16:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40458106566B; Wed, 23 Nov 2011 15:16:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1695E8FC15; Wed, 23 Nov 2011 15:16:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pANFG5xA051099; Wed, 23 Nov 2011 15:16:05 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pANFG5DS051096; Wed, 23 Nov 2011 15:16:05 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201111231516.pANFG5DS051096@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 23 Nov 2011 15:16:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227886 - in releng/9.0/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2011 15:16:06 -0000 Author: kib Date: Wed Nov 23 15:16:05 2011 New Revision: 227886 URL: http://svn.freebsd.org/changeset/base/227886 Log: MFC r227657: Consistently use process spin lock for protection of the p->p_boundary_count. Race could cause the execve(2) from the threaded process to hung since thread boundary counter was incorrect and single-threading never finished. Approved by: re (bz) Modified: releng/9.0/sys/kern/kern_thread.c releng/9.0/sys/sys/proc.h Directory Properties: releng/9.0/sys/ (props changed) Modified: releng/9.0/sys/kern/kern_thread.c ============================================================================== --- releng/9.0/sys/kern/kern_thread.c Wed Nov 23 15:10:15 2011 (r227885) +++ releng/9.0/sys/kern/kern_thread.c Wed Nov 23 15:16:05 2011 (r227886) @@ -566,6 +566,8 @@ calc_remaining(struct proc *p, int mode) { int remaining; + PROC_LOCK_ASSERT(p, MA_OWNED); + PROC_SLOCK_ASSERT(p, MA_OWNED); if (mode == SINGLE_EXIT) remaining = p->p_numthreads; else if (mode == SINGLE_BOUNDARY) @@ -819,8 +821,11 @@ thread_suspend_check(int return_instead) td->td_flags &= ~TDF_BOUNDARY; thread_unlock(td); PROC_LOCK(p); - if (return_instead == 0) + if (return_instead == 0) { + PROC_SLOCK(p); p->p_boundary_count--; + PROC_SUNLOCK(p); + } } return (0); } Modified: releng/9.0/sys/sys/proc.h ============================================================================== --- releng/9.0/sys/sys/proc.h Wed Nov 23 15:10:15 2011 (r227885) +++ releng/9.0/sys/sys/proc.h Wed Nov 23 15:16:05 2011 (r227886) @@ -532,7 +532,7 @@ struct proc { struct thread *p_singlethread;/* (c + j) If single threading this is it */ int p_suspcount; /* (j) Num threads in suspended mode. */ struct thread *p_xthread; /* (c) Trap thread */ - int p_boundary_count;/* (c) Num threads at user boundary */ + int p_boundary_count;/* (j) Num threads at user boundary */ int p_pendingcnt; /* how many signals are pending */ struct itimers *p_itimers; /* (c) POSIX interval timers. */ struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */