From: "Robert Święcki" <robert@swiecki.net>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GLIBC Devel <libc-alpha@sourceware.org>
Subject: Re: Caching of PID/TID after fork
Date: Thu, 06 Oct 2016 21:35:00 -0000 [thread overview]
Message-ID: <CAP145pgU=Ph1UHntkZoEFwneEGCVzzb8YhyzjJBt69wxPemRkg@mail.gmail.com> (raw)
In-Reply-To: <CAP145phG3DL2nFmA32Lu2J_aQEahKT1CoZrNJaGDn76Mov32Ww@mail.gmail.com>
> Also, providing a glibc own symbol to update the tid/pid is messy:
> it would be an internal implementation detail which in theory
> application should not have access to, it might add some
> synchronization issues (what happens if you try to force update
> after a mutex operation with default wrong value?), and it also
> might be tricky to add a compatibility symbol in case of change
> how tid/pid internally works.
Thanks, this is good analysis.
> Another possibility is to use another thread unique identifier
> as the owner instead of tid (maybe a hash of pthread_t
> to fit on a int). By removing this requirement I think it is
> feasible to get rid of caching.
Another dev told me that chromium developers implemented ForkWithFlags
- https://codereview.chromium.org/800183004/ - to deal exactly with
the problem is caching PID/TID. They used the setjmp/longjmp approach
suggested by Rich.
My point is that a lot of projects which use the clone syscall will be
hit by this problem, and getting to (or finding in glibc mail
archives) the working solution might take a lot of time. It's because
of the rise of namespaces, more and more projects will be using the
syscall for various forms of containerization.
Maybe providing something like fork_with_flags(int flags) would work
here? Seems that most (all?) the projects that I've seen, which use
clone() directly and had problems with caching of TID/PID, basically
need fork with some flags (mainly of the CLONE_NEW* type). Such
function would deal with tid/gid/locks/pthread_atfork as fork does,
but would also OR the provided flags with the canonical ones?
--
Robert Święcki
next prev parent reply other threads:[~2016-10-06 21:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 16:13 Robert Święcki
2016-10-06 16:34 ` Paul Pluzhnikov
2016-10-06 17:03 ` Robert Święcki
2016-10-06 18:32 ` Adhemerval Zanella
2016-10-06 17:26 ` Rich Felker
2016-10-06 17:42 ` Robert Święcki
2016-10-06 18:05 ` Rich Felker
2016-10-06 18:26 ` Robert Święcki
2016-10-06 21:35 ` Robert Święcki [this message]
2016-10-07 0:42 ` Zack Weinberg
2016-10-07 0:43 ` Zack Weinberg
2016-10-07 14:44 ` Robert Święcki
2016-10-07 18:20 ` Adhemerval Zanella
2016-10-07 18:30 ` Adhemerval Zanella
2016-10-07 19:38 ` Florian Weimer
2016-10-07 21:23 ` Robert Święcki
2016-10-09 10:05 ` Florian Weimer
2016-10-09 14:19 ` Robert Święcki
2016-10-10 18:03 ` Adhemerval Zanella
2016-11-04 15:14 ` Florian Weimer
2016-11-04 16:03 ` Adhemerval Zanella
2016-11-07 16:04 ` Florian Weimer
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='CAP145pgU=Ph1UHntkZoEFwneEGCVzzb8YhyzjJBt69wxPemRkg@mail.gmail.com' \
--to=robert@swiecki.net \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).