Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Nov 2011 09:46:36 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r227964 - in stable/8/sys: kern sys
Message-ID:  <201111250946.pAP9kaRX036809@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Nov 25 09:46:36 2011
New Revision: 227964
URL: http://svn.freebsd.org/changeset/base/227964

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.

Modified:
  stable/8/sys/kern/kern_thread.c
  stable/8/sys/sys/proc.h
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/kern/kern_thread.c
==============================================================================
--- stable/8/sys/kern/kern_thread.c	Fri Nov 25 07:11:02 2011	(r227963)
+++ stable/8/sys/kern/kern_thread.c	Fri Nov 25 09:46:36 2011	(r227964)
@@ -518,6 +518,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)
@@ -767,8 +769,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: stable/8/sys/sys/proc.h
==============================================================================
--- stable/8/sys/sys/proc.h	Fri Nov 25 07:11:02 2011	(r227963)
+++ stable/8/sys/sys/proc.h	Fri Nov 25 09:46:36 2011	(r227964)
@@ -527,7 +527,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. */
 /* End area that is zeroed on creation. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111250946.pAP9kaRX036809>