From: Brandon Williams <bmwill@google.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Wong <e@80x24.org>, Jeff King <peff@peff.net>,
Jonathan Nieder <jrnieder@gmail.com>,
Eric Rannaud <eric.rannaud@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Jeremy Serror <jeremy.serror@gmail.com>
Subject: Re: [TANGENT] run-command: use vfork instead of fork
Date: Tue, 16 May 2017 14:11:25 -0700 [thread overview]
Message-ID: <20170516211125.GA74302@google.com> (raw)
In-Reply-To: <CA+55aFygKMJH3BRitQftmtCTx6es93CTR4_y1ULGGE2rSsMyog@mail.gmail.com>
On 05/16, Linus Torvalds wrote:
> On Tue, May 16, 2017 at 12:35 PM, Eric Wong <e@80x24.org> wrote:
> >
> > Fwiw, most of the vfork preparation was already done by Brandon
> > and myself a few weeks ago, and cooking in pu.
>
> Oh, interesting. Was that done for vfork(), or is it for something
> else? Some of the changes seem almost overly careful. Is this for
> prep-work porting to some odd environment that doesn't really have a
> MMU at all? There's nothing fundamentally wrong with allocating memory
> after fork().
>
> But yes, it looks like it helps the vfork case.
>
> Linus
I started working on the run-command code when I ran into a deadlock in
'git grep --recurse-submodules'. When I added support for submodules to
grep I just assumed that launching a process (which atm is unfortunately
the only way to work on a submodule) would work in a multi-threaded
environment. I was naive and wrong!
The deadlock was due to a malloc lock being held by thread 'A' while
thread 'b' tried to launch a process. Since that lock was in a
locked-state at the time of forking, it remained in a locked-state with
no hope of ever being released. So when the child process that thread
'b' spawned tried to malloc a chunk of memory after forking, it
deadlocked.
I didn't catch this in initial testing because gclib registers
atfork_handelers in order to prevent this sort of thing, while libraries
like tcmalloc don't do this.
So to account for this, I worked to make run-command safe to use in the
presence of threads, which had the benefit of also preparing it to be
vfork() ready.
Ultimately I'd like to drop the requirement to spawn a child process to
work on a submodule, but that's going to take a lot more effort.
--
Brandon Williams
next prev parent reply other threads:[~2017-05-16 21:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 18:08 git rebase regression: cannot pass a shell expression directly to --exec Eric Rannaud
2017-05-16 3:25 ` Jeff King
2017-05-16 3:37 ` Jeff King
2017-05-16 16:41 ` Jonathan Nieder
2017-05-16 16:47 ` Jeff King
2017-05-16 17:11 ` Eric Rannaud
2017-05-16 17:15 ` Brandon Williams
2017-05-16 17:23 ` Jeff King
2017-05-16 17:30 ` Brandon Williams
2017-05-16 19:14 ` Linus Torvalds
2017-05-16 19:35 ` [TANGENT] run-command: use vfork instead of fork Eric Wong
2017-05-16 20:47 ` Linus Torvalds
2017-05-16 21:11 ` Brandon Williams [this message]
2017-05-16 20:12 ` git rebase regression: cannot pass a shell expression directly to --exec Johannes Schindelin
2017-05-16 20:27 ` Linus Torvalds
2017-05-16 17:37 ` Jonathan Nieder
2017-05-16 3:40 ` Junio C Hamano
2017-05-16 3:53 ` Jeff King
2017-05-16 4:08 ` Jeff King
2017-05-16 16:45 ` Eric Rannaud
2017-05-16 10:46 ` Johannes Schindelin
2017-05-16 10:23 ` Johannes Schindelin
2017-05-16 16:18 ` Jeff King
2017-05-16 16:59 ` Eric Rannaud
2017-05-16 17:14 ` Kevin Daudt
2017-05-16 17:29 ` Eric Rannaud
2017-05-16 17:41 ` Jeff King
2017-05-16 17:21 ` Eric Rannaud
2017-05-16 17:37 ` Jeff King
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=20170516211125.GA74302@google.com \
--to=bmwill@google.com \
--cc=e@80x24.org \
--cc=eric.rannaud@gmail.com \
--cc=git@vger.kernel.org \
--cc=jeremy.serror@gmail.com \
--cc=johannes.schindelin@gmx.de \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
--cc=torvalds@linux-foundation.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.