From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Ingo Molnar <mingo@elte.hu>, Ulrich Drepper <drepper@redhat.com>,
Luca Barbieri <ldb@ldb.ods.org>,
Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [patch] threading fix, tid-2.5.47-A3
Date: Mon, 18 Nov 2002 01:46:12 +0000 [thread overview]
Message-ID: <20021118014612.GA2483@bjl1.asuk.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0211171452480.13106-100000@home.transmeta.com>
Linus Torvalds wrote:
> - the async nature of CLONE_CHILD_SETTID is just bound to cause
> interesting-to-debug behaviour
Fun for debuggers and tracers, certainly. It could be made
synchronous by selecting the new tid value and storing it in the
SETTID address before the mm is cloned.
> Hmm.. I really ahve to say that I just prefer the current two flags,
Agreed, but for different reasons than you gave.
> - the the for is _not_ a CLONE_VM, the child is really an independent
> VM thing, and we should not even _allow_ the parent to change the VM of
> the child: the SETTID behaviour (where it changes the parent VM) makes
> sense and is good, but we should probably disallow CLEARTID altogether
> for that case (and if the independent child wants to clear its own
> memory space on exit, it should just do a set_tid_address() itself)
>
> In fact, from what I can tell, your new CLONE_CHILD_SETTID really is 100%
> semantically equivalent to the child just doing a "set_tid_address()" on
> its own.
Don't get this in a muddle. As far as I can tell, the only purpose of
set_tid_address() is to set the address for _CLEARTID_. (As a bonus,
it returns the tid so that the caller can save the value, but that's
just an optimisation).
So, CLONE_CHILD_SETTID is not at all similar to calling
set_tid_address() in the child.
That said, you're still right. There should be two flags, and these
are the simple, obvious semantics:
1. CLONE_SETTID sets the child's tid in the parent's memory.
In the child's memory, if CLONE_VM is not set, the tid word will
have whatever value was stored in it before the parent called
clone(). Unless I've misread the code, this is the behaviour we
have now.
2. CLONE_CLEARTID sets tid_address in the child (only the child).
It is equivalent to calling set_tid_address() first thing in the
child.
Note that these semantics make sense, and the implementation is very
simple. There is no problem with allowing CLEARTID always.
The race condition which Ulrich brought up, which requires
CLONE_CHILD_SETTID to be used without CLONE_PARENT_SETTID, only occurs
when using the same address to store the tid of the forked child as
the parent's tid address. In other words, it's a user space error.
(Please correct me if I'm mistaken, Ulrich).
Finally, it would be kinder to everyone if CLONE_SETTID stored the
child's tid in _both_ the parent and child address spaces, atomically
w.r.t. debuggers. The simplest way to do that is to store the child's
tid value in the parent's memory before cloning the mm. If thread
creation fails, that's fine because the parent knows.
-- Jamie
next prev parent reply other threads:[~2002-11-18 1:39 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3DD7E3E7.6040403@redhat.com>
2002-11-17 18:54 ` [patch] threading fix, tid-2.5.47-A3 Linus Torvalds
2002-11-17 20:18 ` Ingo Molnar
2002-11-17 20:37 ` Ingo Molnar
2002-11-17 19:54 ` Luca Barbieri
2002-11-17 21:17 ` Ingo Molnar
2002-11-17 20:16 ` Luca Barbieri
2002-11-17 21:45 ` Ingo Molnar
2002-11-17 20:35 ` Ulrich Drepper
2002-11-17 20:44 ` Jamie Lokier
2002-11-17 20:49 ` Luca Barbieri
2002-11-17 22:08 ` Ingo Molnar
2002-11-17 23:00 ` Linus Torvalds
2002-11-17 23:23 ` Ulrich Drepper
2002-11-18 1:33 ` Linus Torvalds
2002-11-18 3:33 ` Ulrich Drepper
2002-11-18 3:43 ` Linus Torvalds
2002-11-18 3:58 ` Ulrich Drepper
2002-11-18 4:11 ` Linus Torvalds
2002-11-18 4:31 ` Ulrich Drepper
2002-11-18 6:46 ` Ulrich Drepper
2002-11-18 16:00 ` Linus Torvalds
2002-11-18 8:07 ` Luca Barbieri
2002-11-18 8:21 ` Ulrich Drepper
2002-11-18 8:27 ` Luca Barbieri
2002-11-18 9:30 ` [patch] threading enhancements, tid-2.5.47-C0 Ingo Molnar
2002-11-18 8:29 ` Luca Barbieri
2002-11-18 12:12 ` Ingo Molnar
2002-11-18 12:11 ` Luca Barbieri
2002-11-20 1:40 ` Ulrich Drepper
2002-11-20 1:59 ` Linus Torvalds
2002-11-20 3:37 ` Jamie Lokier
2002-11-20 4:04 ` Ulrich Drepper
2002-11-20 21:55 ` Jamie Lokier
2002-11-20 22:11 ` Ulrich Drepper
2002-11-20 23:26 ` Jamie Lokier
2002-11-20 23:28 ` Ulrich Drepper
2002-11-21 0:18 ` Jamie Lokier
2002-11-21 9:13 ` Ingo Molnar
2002-11-21 12:07 ` Jamie Lokier
2002-11-21 0:37 ` Jamie Lokier
2002-11-20 8:50 ` Ingo Molnar
2002-11-20 9:51 ` [patch] threading enhancements, tid-2.5.48-A1 Ingo Molnar
2002-11-20 8:41 ` Ulrich Drepper
2002-11-20 20:20 ` Luca Barbieri
2002-11-21 18:03 ` [patch] threading enhancements, tid-2.5.48-C0 Ingo Molnar
2002-11-21 19:30 ` Luca Barbieri
2002-11-18 8:30 ` [patch] threading fix, tid-2.5.47-A3 Luca Barbieri
2002-11-18 12:21 ` Ingo Molnar
2002-11-18 12:50 ` Luca Barbieri
2002-11-18 12:26 ` Ingo Molnar
2002-11-18 13:20 ` Alan Cox
2002-11-18 13:03 ` Luca Barbieri
2002-11-18 16:24 ` Linus Torvalds
2002-11-18 16:42 ` Ingo Molnar
2002-11-18 1:46 ` Jamie Lokier [this message]
2002-11-18 3:40 ` Ulrich Drepper
2002-11-18 22:22 ` Jamie Lokier
2002-11-17 23:37 ` Ulrich Drepper
2002-11-17 12:40 Ingo Molnar
2002-11-17 11:57 ` Luca Barbieri
2002-11-17 13:36 ` Ingo Molnar
2002-11-17 13:49 ` Ingo Molnar
2002-11-17 13:29 ` Luca Barbieri
2002-11-17 17:28 ` Linus Torvalds
2002-11-17 19:03 ` Ulrich Drepper
2002-11-17 19:19 ` Ingo Molnar
2002-11-17 19:31 ` Ingo Molnar
2002-11-17 18:27 ` Linus Torvalds
2002-11-17 20:13 ` Ingo Molnar
2002-11-17 20:01 ` Jamie Lokier
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=20021118014612.GA2483@bjl1.asuk.net \
--to=lk@tantalophile.demon.co.uk \
--cc=drepper@redhat.com \
--cc=ldb@ldb.ods.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@transmeta.com \
/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