linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Mark Grosberg <mark@nolab.conman.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFD] Combined fork-exec syscall.
Date: Mon, 28 Apr 2003 10:19:25 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.50.0304280954000.1629-100000@blue1.dev.mcafeelabs.com> (raw)
In-Reply-To: <Pine.BSO.4.44.0304281219420.22115-100000@kwalitee.nolab.conman.org>

On Mon, 28 Apr 2003, Mark Grosberg wrote:

> The point of my system call is:
>
>   (1) Save the extra overhead of vfork() and exec(). A single system
>       call would still be faster.
>
>   (2) Avoid the resulting file descriptor manipulations for setting
>       up pipelines (dup's and closes).
>
>   (3) Avoid having to do any execution of the child. vfork() shares the
>       address space but there is still overhead in doing the setup of
>       vfork().

You still have to do a fork inside the kernel. For sure you don't want to
call do_execve() in the parent task context ;) So there's no save there.
Saving a few syscalls gives you almost nothing compared to the cost of
spawning a new process and to the machine resource consumption of the task
itself. The only place where this might have a measurable impact is when
you have the parent process with 100K fds open and still you have to have
a pretty short lived child process to have a measurable impact. Supposed
that this will be considered as worth, for sure you don't want to
introduce another syscall not respecting the POSIX one. That, if I did
read it correctly, sucks from that point of view. It suck because it is my
understanding that you have to explicitly drop close actions inside the
file actions list. So, suppose you have N fds and you want to close N-2
fds and dup 2 of them, you need N-2 close actions and 2 dup actions. So
you'll end up having an O(N) in user space to build the action list, and
at least an O(N) in kernel space to walk through it again. Actually, since
it is my understanding that the posix_spawn() interface assume an
all-fds-open by default, you have a few options to setup the child file
list :

1) You have an std clone() to copy all files to the new task struct
	( at *least* O(N) ) and you walk through the POSIX file action
	list to apply close/dup ( O(N) )

2) You have a special clone that starts with a brand new file table ( cost == 0 )
	and you walk though the old files array ( O(N) ) by seeking if the
	current file has actions passed by the caller. This is very bad
	since the action list is not indexed, so going in this direction
	w/out building some kind of index might be as O(N^2). Suppose you
	build an index that it'll give you an O(1), you still have to
	spend *at least* O(N) to build the index itself.

3) Other ways are possible but the minimum cost is at least O(2*N).


What would give the POSIX interface a boost would be to have a
default-all-closed option. In this case, in our example, we will have the
new process created with a blank file table ( cost == 0 ) plus 2 dups done
on the parent file table.




- Davide


  reply	other threads:[~2003-04-28 17:06 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-28  0:57 [RFD] Combined fork-exec syscall Mark Grosberg
2003-04-28  0:59 ` Larry McVoy
2003-04-28  1:16   ` Mark Grosberg
2003-04-28  1:36     ` Måns Rullgård
2003-04-28  1:45       ` Mark Grosberg
2003-04-28  1:49       ` dean gaudet
2003-04-28  1:59         ` Mark Grosberg
2003-04-28  2:27           ` Miles Bader
2003-04-28 19:07           ` dean gaudet
2003-05-01 13:14       ` Jakob Oestergaard
2003-04-28  1:17 ` Davide Libenzi
2003-04-28  1:28   ` Mark Grosberg
2003-04-29  2:01     ` Rafael Costa dos Santos
2003-04-28  1:41   ` Ulrich Drepper
2003-04-28  1:49     ` Mark Grosberg
2003-04-28  2:19       ` Ulrich Drepper
2003-04-28  6:59       ` Kai Henningsen
2003-04-28  1:35 ` dean gaudet
2003-04-28  1:43   ` Mark Grosberg
2003-04-28  3:44     ` Mark Mielke
2003-04-28  5:16       ` Jamie Lokier
2003-04-28  2:38   ` Davide Libenzi
2003-04-28  2:09 ` Richard B. Johnson
2003-04-28  2:12   ` Mark Grosberg
2003-04-28  2:42     ` Werner Almesberger
2003-04-28  6:35       ` Mark Grosberg
2003-04-29  2:47       ` Rafael Santos
2003-04-28  3:20         ` Werner Almesberger
2003-04-28 13:00     ` Richard B. Johnson
2003-04-28 13:22       ` Andreas Schwab
2003-04-28 13:57         ` Richard B. Johnson
2003-04-28 13:57           ` Andreas Schwab
2003-04-28 14:16             ` Richard B. Johnson
2003-04-28 14:38               ` Valdis.Kletnieks
2003-04-28 14:56                 ` Richard B. Johnson
2003-04-28 14:42               ` Andreas Schwab
2003-04-28 16:36       ` Mark Grosberg
2003-04-28 17:19         ` Davide Libenzi [this message]
2003-04-28 18:28         ` Craig Ruff
2003-05-06  2:48         ` Miles Bader
2003-04-29 18:50       ` Timothy Miller
2003-04-28  2:32   ` Werner Almesberger
2003-04-28  7:40 ` Mirar
2003-04-28 12:45 ` Matthias Andree
2003-04-29  1:05 ` Rafael Costa dos Santos
2003-04-28  1:19   ` Mark Grosberg
2003-04-29  1:29     ` Rafael Costa dos Santos
2003-04-28  3:03 Davide Libenzi

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=Pine.LNX.4.50.0304280954000.1629-100000@blue1.dev.mcafeelabs.com \
    --to=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@nolab.conman.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).