1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Completely remove the code for single threading the mainline fork code.

Put in a little comment explaining why it went away.
Re-enable it in the case there an exisiting process is just splitting
off its address space and file descriptors.
(I donpt think anything uses that code but it needs some sort of locking
and this does the job.

Reviewed by:	Davidxu, alc, others
MFC after:	3 days
This commit is contained in:
Julian Elischer 2007-11-02 19:40:36 +00:00
parent d30d220339
commit f4bb4fc8f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173290

View File

@ -208,7 +208,6 @@ fork1(td, flags, pages, procp)
* certain parts of a process from itself.
*/
if ((flags & RFPROC) == 0) {
#if 0 /* XXX no other OS tries to do this */
if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) &&
(flags & (RFCFDG | RFFDG))) {
PROC_LOCK(p1);
@ -218,7 +217,6 @@ fork1(td, flags, pages, procp)
}
PROC_UNLOCK(p1);
}
#endif
vm_forkproc(td, NULL, NULL, flags);
@ -238,49 +236,21 @@ fork1(td, flags, pages, procp)
if (flags & RFFDG)
fdunshare(p1, td);
#if 0 /* XXX no other OS tries to do this */
if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) &&
(flags & (RFCFDG | RFFDG))) {
PROC_LOCK(p1);
thread_single_end();
PROC_UNLOCK(p1);
}
#endif
*procp = NULL;
return (0);
}
#if 0 /* XXX no other OS tries to do this */
/*
* Note 1:1 allows for forking with one thread coming out on the
* other side with the expectation that the process is about to
* exec.
* XXX
* We did have single-threading code here
* however it proved un-needed and caused problems
*/
if ((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) {
/*
* Systems processes don't need this.
* Idle the other threads for a second.
* Since the user space is copied, it must remain stable.
* In addition, all threads (from the user perspective)
* need to either be suspended or in the kernel,
* where they will try restart in the parent and will
* be aborted in the child.
* keep threadds at the boundary there.
*/
PROC_LOCK(p1);
if (thread_single(SINGLE_BOUNDARY)) {
/* Abort. Someone else is single threading before us. */
PROC_UNLOCK(p1);
return (ERESTART);
}
PROC_UNLOCK(p1);
/*
* All other activity in this process
* is now suspended at the user boundary,
* (or other safe places if we think of any).
*/
}
#endif
/* Allocate new proc. */
newproc = uma_zalloc(proc_zone, M_WAITOK);
@ -729,17 +699,6 @@ fork1(td, flags, pages, procp)
msleep(p1, &p2->p_mtx, PWAIT, "ppwait", 0);
PROC_UNLOCK(p2);
#if 0 /* XXX no other OS tries to do this */
/*
* If other threads are waiting, let them continue now.
*/
if ((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) {
PROC_LOCK(p1);
thread_single_end();
PROC_UNLOCK(p1);
}
#endif
/*
* Return child proc pointer to parent.
*/
@ -755,11 +714,6 @@ fork1(td, flags, pages, procp)
mac_proc_destroy(newproc);
#endif
uma_zfree(proc_zone, newproc);
if (p1->p_flag & P_HADTHREADS) {
PROC_LOCK(p1);
thread_single_end();
PROC_UNLOCK(p1);
}
pause("fork", hz / 2);
return (error);
}