All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Adam J. Richter" <adam@freya.yggdrasil.com>
To: chief@bandits.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: PATCH(?): linux-2.4.4-pre2: fork should run child first
Date: Fri, 13 Apr 2001 19:45:28 -0700	[thread overview]
Message-ID: <200104140245.TAA05482@freya.yggdrasil.com> (raw)

"John Fremlin" <chief@bandits.org> writes:
>"Adam J. Richter" <adam@yggdrasil.com> writes:
>> "John Fremlin" <chief@bandits.org> writes:
>> > "Adam J. Richter" <adam@yggdrasil.com> writes:

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

	I thought that I had checked this a few months ago and
discovered that Linux let the vfork parent run, but I wrote a
test program just now, and you're apparently right about that,
at least with respect to 2.4.3, although that's all the more
reason to give the short term CPU priority to the process that
can use it (the child), thereby slightly increasing the average
runtime available in a timeslice, which in term slightly decreases
the percentage of time spent in context switch overhead.  This will
usually be a really tiny amount, but my point is that since there
is probably a tiny advantage to giving the remaining time slices
to the child even here, there is no need to complicate my patch.

>> 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.

	It is impractical to change every application, including
ones that you don't have access to, and many of them have reaons for
using fork instead of vfork, and you don't even have access to them.
For example, the setup that the child does between the fork and the
exec is complex enough so that it might mess up the parent's memory or,
more commonly, its error handling code for exec failure is.

	Even if you could show that vfork was the right choice in all
cases (and it isn't), that would still be no reason for making do_fork
unnecessary slow and complex.  My change simplifies do_fork(), makes
it runs a few cycles faster, and, I believe, makes it behave like more
fork on most other systems.  If you want to argue against this change,
please justify the real benefits of the performance cost, the
complexity and nonstandard behavior you are advocating.  (Admittedly
the last two are really small, but I believe they are positive).

	Note that I've dropped Linus's email address for this thread,
as it does not appear to be arguing a real technical advantage to the
old do_fork() behavior.  So, while it may be interesting and informative
and on topic for lkml, it is not seem to be an argument to Linus that
he should reject or modify my patch.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."

             reply	other threads:[~2001-04-14  2:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-14  2:45 Adam J. Richter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-04-14 16:11 PATCH(?): linux-2.4.4-pre2: fork should run child first Adam J. Richter
2001-04-14  7:58 Adam J. Richter
2001-04-14  8:42 ` Michael O'Reilly
2001-04-14  9:00 ` Linus Torvalds
2001-04-14 15:06   ` Rik van Riel
2001-04-13 23:51 Adam J. Richter
2001-04-14  1:54 ` John Fremlin
2001-04-14  2:29   ` Linus Torvalds
2001-04-14  2:51     ` Alexander Viro
2001-04-14  2:52     ` Ulrich Drepper
2001-04-13 16:28 Hubertus Franke
2001-04-12 19:45 Adam J. Richter
2001-04-12 19:15 Adam J. Richter
2001-04-12 13:44 Hubertus Franke
2001-04-12  8:55 Adam J. Richter
2001-04-12 12:38 ` Horst von Brand
2001-04-17  9:15   ` Éric Brunet
2001-04-17 14:26     ` Jesse Pollard
2001-04-17 15:32       ` Éric Brunet
2001-04-13 21:08 ` John Fremlin
2001-04-14  3:53 ` Rik van Riel
2001-04-14  4:40   ` Linus Torvalds
2001-04-14 13:35     ` Rik van Riel

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=200104140245.TAA05482@freya.yggdrasil.com \
    --to=adam@freya.yggdrasil.com \
    --cc=chief@bandits.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.