From: Ulrich Drepper <drepper@redhat.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Ingo Molnar <mingo@elte.hu>, 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: Sun, 17 Nov 2002 22:46:13 -0800 [thread overview]
Message-ID: <3DD88CB5.5070904@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0211172003050.1206-100000@home.transmeta.com>
[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]
Linus Torvalds wrote:
> I'm convinced. However, I still want som elargely cosmetic changes to the
> patch, Ingo:
> [...]
I'm not Ingo but changing the patch seemed easy enough to do, even for
me. I append the patch below. It is not meant for inclusion since
there is onw more problem to solve. Ingo patch had another bug. The
user_tid field in the child didn't get set if CLONE_CHILD_CLEARTID was
set. This obviously has bad results.
I've changed the test to read
+ if (clone_flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
which works for me. But since in schedule_tail() the code reads
+ if (current->user_tid)
+ put_user(current->pid, current->user_tid);
this enables writing the TID even if CLONE_CHILD_SETTID isn't set. The
question is: how to access the clone flag information in the child?
Anyway, since this distinction isn't important for my tests I've applied
the attached patch and all runs fine.
--
--------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
[-- Attachment #2: d-tid --]
[-- Type: text/plain, Size: 3152 bytes --]
--- linux-2.5/arch/i386/kernel/entry.S.tid 2002-11-17 16:11:26.000000000 -0800
+++ linux-2.5/arch/i386/kernel/entry.S 2002-11-17 21:56:18.000000000 -0800
@@ -193,10 +193,8 @@
ENTRY(ret_from_fork)
-#if CONFIG_SMP || CONFIG_PREEMPT
# NOTE: this function takes a parameter but it's unused on x86.
call schedule_tail
-#endif
GET_THREAD_INFO(%ebx)
jmp syscall_exit
--- linux-2.5/include/linux/sched.h.tid 2002-11-17 16:11:26.000000000 -0800
+++ linux-2.5/include/linux/sched.h 2002-11-17 22:04:56.000000000 -0800
@@ -46,10 +46,11 @@
#define CLONE_NEWNS 0x00020000 /* New namespace group? */
#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
-#define CLONE_SETTID 0x00100000 /* write the TID back to userspace */
-#define CLONE_CLEARTID 0x00200000 /* clear the userspace TID */
+#define CLONE_PARENT_SETTID 0x00100000 /* write the TID back to userspace */
+#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the userspace TID */
#define CLONE_DETACHED 0x00400000 /* parent wants no child-exit signal */
#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
+#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
/*
* List of flags we want to share for kernel threads,
@@ -332,7 +333,7 @@
wait_queue_head_t wait_chldexit; /* for wait4() */
struct completion *vfork_done; /* for vfork() */
- int *user_tid; /* for CLONE_CLEARTID */
+ int *user_tid; /* for CLONE_[SET|CLEAR]TID */
unsigned long rt_priority;
unsigned long it_real_value, it_prof_value, it_virt_value;
--- linux-2.5/kernel/sched.c.tid 2002-11-17 16:11:26.000000000 -0800
+++ linux-2.5/kernel/sched.c 2002-11-17 21:59:58.000000000 -0800
@@ -503,12 +503,17 @@
* schedule_tail - first thing a freshly forked thread must call.
* @prev: the thread we just switched away from.
*/
-#if CONFIG_SMP || CONFIG_PREEMPT
+asmlinkage void FASTCALL(schedule_tail(task_t *prev));
asmlinkage void schedule_tail(task_t *prev)
{
finish_arch_switch(this_rq(), prev);
+
+ /*
+ * Does the child thread/process want to be notified of the TID/PID?
+ */
+ if (current->user_tid)
+ put_user(current->pid, current->user_tid);
}
-#endif
/*
* context_switch - switch to the new MM and the new
--- linux-2.5/kernel/fork.c.tid 2002-11-17 16:11:26.000000000 -0800
+++ linux-2.5/kernel/fork.c 2002-11-17 22:06:00.000000000 -0800
@@ -822,18 +822,15 @@
retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
if (retval)
goto bad_fork_cleanup_namespace;
- /*
- * Notify the child of the TID?
- */
retval = -EFAULT;
- if (clone_flags & CLONE_SETTID)
+ if (clone_flags & CLONE_PARENT_SETTID)
if (put_user(p->pid, user_tid))
goto bad_fork_cleanup_namespace;
-
/*
- * Does the userspace VM want the TID cleared on mm_release()?
+ * Does the userspace VM want the TID set in the child's
+ * address space and it cleared on mm_release()?
*/
- if (clone_flags & CLONE_CLEARTID)
+ if (clone_flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
p->user_tid = user_tid;
/*
next prev parent reply other threads:[~2002-11-18 6: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 [this message]
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
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=3DD88CB5.5070904@redhat.com \
--to=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