Re: PATCH(?): linux-2.4.4-pre2: fork should run child first

From: John Fremlin (chief@bandits.org)
Date: Fri Apr 13 2001 - 20:54:08 EST


"Adam J. Richter" <adam@yggdrasil.com> writes:

> "John Fremlin" <chief@bandits.org> writes:
> > "Adam J. Richter" <adam@yggdrasil.com> writes:
> >> Guess why you're seeing this email. That's right. Linux-2.4.3's
> >> fork() does not run the child first.
>
> >[...] If an app wants to fork and exec, it
> >should use *vfork* and exec, which is a performance win across many
> >OSs because the COW mappings don't even have to be set up, IIRC.
>
> Even in that case, you want to run the child first because

The parent is not allowed to run until the child execs, if I
understand correctly. Read up on CLONE_VFORK.
 
[...]

> Of course, in the vfork case, this change is probably only a very
> small win. The real advantage is with regular fork() followed by an
> exec, which happens quite a lot. For example, I do not see vfork
> anywhere in the bash sources.

If it is a real advantage you can get a bigger advantage by changing
the app to use vfork, i.e. you can solve the problem (if it exists)
better without hacking the kernel. Further, your change will hurt
those apps which expect the parent to be given a fair chance, so
you'll need to add a fairfork(2) syscall to comply with Californian
anti age discrimmination legislation (humour). In fact, if you think
fork+exec is such a big performance hit why not go for spawn(2) and
have Linus and Al jump on you? ;-)

[...]

-- 

http://www.penguinpowered.com/~vii - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 15 2001 - 21:00:22 EST