mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mike Galbraith <efault@gmx.de>
Subject: Re: [GIT PULL] sched/core for v2.6.32
Date: Fri, 11 Sep 2009 15:58:34 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0909111546050.3654@localhost.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.00.0909120032270.31018@swampdragon.chaosbits.net>



On Sat, 12 Sep 2009, Jesper Juhl wrote:
> [...]
> > Highlights:
> > 
> >  - Child-runs-first is now off - i.e. we run parent first.
> >    [ Warning: this might trigger races in user-space. ]
> [...]
> 
> Ouch. Do we dare do that?

We would want to at least try.

There are various reasons why we'd like to run the child first, ranging 
from just pure latency (quite often, the child is the one that is 
critical) to getting rid of page sharing for COW early thanks to execve 
etc.

But similarly, there are various reasons to run the parent first, like 
just the fact that we already have the state active in the TLB's and 
caches.

Finally, we've never made any guarantees, because the timeslice for the 
parent might be just about to end, so child-first vs parent-first is never 
a guarantee, it's always just a preference.

[ And we _have_ had that preference expose user-level bugs. Long long ago 
  we hit some problem with child-runs-first and 'bash' being unhappy about 
  a really low-cost and quick child process exiting even _before_ bash 
  itself had had time to fill in the process tables, and then when the 
  SIGCHLD handler ran bash said "I got a SIGCHLD for something I don't 
  even know about". 

  That was very much a bash bug, but it was a bash bug that forced us to 
  do 'parent-runs-first' for a while. So the heuristic can show problems ]

> vfork() is supposed to always run the child first.

vfork() has always run the child first, since the parent won't even be 
runnable. The parent will get stuck in

	wait_for_completion(&vfork);

so the "child-runs-first" is just an issue for regular fork or clone, not 
vfork. For vfork there is never any question about it.

> Most people I've talked to over the years assume that using fork(), the 
> child runs first (yes, I know, that's not guaranteed, but people have come 
> to believe that it is so and some may even depend on it).

It really hasn't been that way in Linux. We've done it both ways. 

			Linus

  reply	other threads:[~2009-09-11 22:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11 19:25 Ingo Molnar
2009-09-11 22:40 ` Jesper Juhl
2009-09-11 22:58   ` Linus Torvalds [this message]
2009-09-11 23:34     ` Jesper Juhl
2009-09-12  2:24       ` Tony Luck
2009-09-12  5:49         ` Ingo Molnar
2009-09-12 22:07           ` Jesper Juhl
2009-09-13  6:41             ` Mike Galbraith
2009-09-13 22:03               ` Jesper Juhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0909111546050.3654@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=efault@gmx.de \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®