Subject: Re: SMP problems in fork()?
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 12/08/2002 21:19:29
On Mon, Dec 09, 2002 at 07:56:45AM +1100, Daniel Carosone wrote:
> On Sun, Dec 08, 2002 at 09:42:58PM +0100, Emmanuel Dreyfus wrote:
> > In fork1(), we set the child as runnable, and we use a pointer to its
> > proc structure after this. 
> > 
> > On a SMP system, the child could be scheduled for running on another
> > CPU, and it could even die before we get out of fork1(), thus making us
> > using a stale pointer on its struct proc.
> > 
> > It seems to me that we need to cleanup the end of fork1(), but I'm not
> > sure of what should be done.
> 
> I think biglock prevents this at the moment, but this will eventually
> go away.

Consider also the case of fork with both FORK_PPWAIT and FORK_NOWAIT
set (ie vfork with the parent set to initproc).

The process priorities could be such that:
	if (flags & FORK_PPWAIT)
		while (p2->p_flag & P_PPWAIT)
			tsleep(p1, PWAIT, "ppwait", 0);

accesses p2->p_flag after the child has been reaped - even on
a single cpu system.

I THINK everything else can safely be done before the setrunqueue().

	David

-- 
David Laight: david@l8s.co.uk