svn commit: r227884 - in stable/9/sys: kern sys
Konstantin Belousov
kib at FreeBSD.org
Wed Nov 23 15:03:16 UTC 2011
Author: kib
Date: Wed Nov 23 15:03:15 2011
New Revision: 227884
URL: http://svn.freebsd.org/changeset/base/227884
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:
stable/9/sys/kern/kern_thread.c
stable/9/sys/sys/proc.h
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/kern/kern_thread.c
==============================================================================
--- stable/9/sys/kern/kern_thread.c Wed Nov 23 13:50:14 2011 (r227883)
+++ stable/9/sys/kern/kern_thread.c Wed Nov 23 15:03:15 2011 (r227884)
@@ -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: stable/9/sys/sys/proc.h
==============================================================================
--- stable/9/sys/sys/proc.h Wed Nov 23 13:50:14 2011 (r227883)
+++ stable/9/sys/sys/proc.h Wed Nov 23 15:03:15 2011 (r227884)
@@ -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. */
More information about the svn-src-stable-9
mailing list