public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] threading fix, tid-2.5.47-A3
@ 2002-11-17 12:40 Ingo Molnar
  2002-11-17 11:57 ` Luca Barbieri
  2002-11-17 17:28 ` Linus Torvalds
  0 siblings, 2 replies; 70+ messages in thread
From: Ingo Molnar @ 2002-11-17 12:40 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Luca Barbieri


the attached patch (against BK-curr) implements another threading related
detail, it changes the way TID setting/clearing works. These changes fix a
weakness of NPTL's handling of the "initial thread", noticed by Luca
Barbieri.

the problem is the following: the 'initial thread', ie. the 'process',
does not have any ->user_tid value set. But still it's a generic thread
that can be pthread_join()-ed upon. (but pthread_join() does not work, the
kernel does not do the futex wakeup because ->user_tid is NULL.)

the solution is to add a new syscall that sets the current->user_tid
address. This new syscall is used by glibc's exec() implementation.  
Another change is to make CLONE_SETTID work even if CLONE_VM is not used.
This means that the TID must be set in the child's address space, not in
the parent's address space. I've also merged SETTID and CLEARTID, the two
should always be used together by any new-style threading abstraction.

the sys_set_tid_address() syscall returns the current TID, which is used
by glibc to set the TID address in the parent's context. (this is cheaper
than to do a put_user() in kernel-space.)

to implement the above semantics i've used the schedule_tail() callback to
do the TID setting in the child's context - doing it a'la
ptrace_writedata() / access_process_vm() would be way too expensive. It
looks a bit ugly to do the TID setting both in schedule_tail() and
do_fork(), and to do the CLONE_VM check, but the correct (and generic)  
solution

In future glibc versions every process and thread will have a nonzero
user_tid address, so the callback is necessary.

Ulrich Drepper has changed glibc/NPTL to use these new semantics and the
initial thread now works fine. Also, i've compressed the CLONE flags to
remove the CLONE_CLEARTID hole, since NPTL is the only one using them
currently.

(the patch has no effect on old-style threading libraries.)

	Ingo


^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2002-11-21 19:23 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox