mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@transmeta.com>, linux-kernel@vger.kernel.org
Subject: Re: [patch] user-vm-unlock-2.5.31-A2
Date: Thu, 15 Aug 2002 22:27:32 +0100	[thread overview]
Message-ID: <20020815222731.A28998@kushida.apsleyroad.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0208151502001.7855-100000@localhost.localdomain>; from mingo@elte.hu on Thu, Aug 15, 2002 at 03:03:33PM +0200

Ingo Molnar wrote:
> (there's no need to intercept anything - glibc *is* the only legitimate
> code that might call the raw sys_execve() & sys_exit() system-calls.)

This is very glibc-centred.

I'm thinking of glibc (or other libc) + non-glibc (and non-pthreads)
thread library, for a language's run-time environment.

The less interception, and also signal wrappers (ugly things), that have
to be written in the _application-specific thread library_, which still
wishes to interface with unknown 3rd party libraries remember, the
better.

Linus Torvalds wrote:
> On Tue, 13 Aug 2002, Ingo Molnar wrote:
> > we dont really want any signal overhead, and we also dont want any extra
> > context-switching to the 'master thread'. And there's no master thread
> > anymore either.
> 
> That still doesn't make it any les crap: because any thread that exits 
> without calling the "magic exit-flag interface" will then silently be 
> lost, with no information left around anywhere.

also:
> If the parent wants to get notified on child death, it should damn well
> get notified on child death. Not "in case the child exists politely".

Ingo, the reason I suggest a futex, and to store the exit status in it,
is precisely because of the above by Linus...  if a thread exits without
calling "magic exit-flag interface" I would still like a parent thread
to know about it.  (This is for _non-glibc-threads_ applications).  And
I would like this while having the benefit of CLONE_DETACHED - because I
want to use this for high performance threading but still be robust - so
waitpid() is out.

So - following Linus' note on CLONE_CLRTID - store the tid when the
thread is created, store the exit status when the thread is destroyed,
and after storing the exit status, call sys_futex(address, FUTEX_WAKE,
1, 0) if the word value before storing was non-zero.  The condition is
to avoid the slowness of sys_futex when it's not required.  It's
probably most simple to use two consecutive words, for simplicity and to
avoid needing an atomic store (which is slower on some architectures).

This gives synchronous (FUTEX_WAIT), asynchronous (FUTEX_FD) and polling
(just read memory) interfaces to a parent monitoring its child (or
siblings monitoring each other).  It gives access to the same
information as waitpid(), but with the advantages of CLONE_DETACHED.

All this for these few untested lines in the exit path :-)

	if (tsk->user_vm_lock) {
		long user_word;
		if (likely(!get_user(user_word, tsk->user_vm_lock))) {
			put_user(tsk->exit_code, tsk->user_vm_lock);
			wmb();
			if (user_word < 0)
				sys_futex (tsk->user_vm_lock, FUTEX_WAKE, -user_word, 0);
		}
	}

-- Jamie

  reply	other threads:[~2002-08-15 21:24 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-13 15:25 [patch] exit_free(), 2.5.31-A0 Ingo Molnar
2002-08-13 15:36 ` Linus Torvalds
2002-08-13 17:50   ` Ingo Molnar
2002-08-13 18:00     ` Linus Torvalds
2002-08-13 18:03       ` Ingo Molnar
2002-08-13 18:17         ` Linus Torvalds
2002-08-13 18:22           ` Ingo Molnar
2002-08-15 20:51           ` mgross
2002-08-13 18:08       ` Ingo Molnar
2002-08-13 18:23         ` Linus Torvalds
2002-08-13 18:52           ` Linus Torvalds
2002-08-13 19:16             ` Ingo Molnar
2002-08-13 19:43               ` Linus Torvalds
2002-08-13 19:55                 ` Ingo Molnar
2002-08-13 20:06                   ` Ingo Molnar
2002-08-13 20:42                     ` Linus Torvalds
2002-08-13 21:17                       ` [patch] clone-detached-2.5.31-B0 Ingo Molnar
2002-08-13 21:23                         ` [patch] user-vm-unlock-2.5.31-A2 Ingo Molnar
2002-08-15  4:03                           ` Jamie Lokier
2002-08-15  6:37                             ` Ingo Molnar
2002-08-15 10:38                               ` Ingo Molnar
2002-08-15 13:24                                 ` Ingo Molnar
2002-08-15 18:02                                 ` Linus Torvalds
2002-08-15 22:26                                   ` Ingo Molnar
2002-08-15 23:01                                     ` Ingo Molnar
2002-08-15 23:45                                     ` Linus Torvalds
2002-08-15 23:46                                       ` Ingo Molnar
2002-08-15 23:58                                         ` Linus Torvalds
2002-08-16  0:00                                           ` Ingo Molnar
2002-08-15 23:47                                       ` Ingo Molnar
2002-08-15 23:53                                         ` Linus Torvalds
2002-08-15 23:58                                           ` Ingo Molnar
2002-08-16  0:06                                             ` Linus Torvalds
2002-08-16  0:11                                               ` Ingo Molnar
2002-08-16  0:14                                                 ` Ingo Molnar
2002-08-16  1:06                                                 ` Linus Torvalds
2002-08-16  1:14                                                   ` Linus Torvalds
2002-08-16  9:51                                                     ` Ingo Molnar
2002-08-16  9:49                                                   ` Ingo Molnar
2002-08-16 16:54                                                     ` Linus Torvalds
2002-08-15  6:45                             ` Ingo Molnar
2002-08-15 10:31                               ` Jamie Lokier
2002-08-15 11:30                                 ` Alex Riesen
2002-08-15 13:03                                 ` Ingo Molnar
2002-08-15 21:27                                   ` Jamie Lokier [this message]
2002-08-15 22:02                                     ` Ingo Molnar
2002-08-16  3:09                                       ` Jamie Lokier
2002-08-16 10:02                                         ` Ingo Molnar
2002-08-16 12:34                                           ` Jamie Lokier
2002-08-16 13:18                                             ` Ingo Molnar
2002-08-16 14:19                                               ` CLONE_DETACHED and exit notification (was user-vm-unlock-2.5.31-A2) Jamie Lokier
2002-08-16 14:48                                                 ` Ingo Molnar
2002-08-16 16:30                                                   ` Jamie Lokier
2002-08-16 17:12                                                     ` Ingo Molnar
2002-08-16 17:22                                                     ` Linus Torvalds
2002-08-16 17:28                                                       ` Ingo Molnar
2002-08-16 17:34                                                         ` Linus Torvalds
2002-08-16 17:38                                                           ` Ingo Molnar
2002-08-16 17:47                                                           ` Ingo Molnar
2002-08-17 18:48                                                           ` Ingo Molnar
2002-08-17 19:06                                                             ` Christoph Hellwig
2002-08-17 22:18                                                             ` Jamie Lokier
2002-08-15 23:29                                     ` [patch] user-vm-unlock-2.5.31-A2 Jamie Lokier
2002-08-15  6:49                             ` Ingo Molnar
2002-08-15 15:16                         ` [patch] clone-detached-2.5.31-B0 Ingo Molnar
2002-08-26 12:35                           ` Pavel Machek
2002-08-26 19:28                             ` Robert Love
2002-08-26 19:33                               ` Ingo Molnar
2002-08-13 19:31             ` [patch] exit_free(), 2.5.31-A0 Ingo Molnar
2002-08-13 19:50               ` Linus Torvalds
2002-08-13 20:47                 ` [patch] user-vm-unlock-2.5.31-A1 Ingo Molnar
2002-08-13 20:53                   ` Ingo Molnar
2002-08-13 18:14   ` [patch] exit_free(), 2.5.31-A0 Ingo Molnar
2002-08-13 18:24     ` Linus Torvalds

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=20020815222731.A28998@kushida.apsleyroad.org \
    --to=lk@tantalophile.demon.co.uk \
    --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

all inboxes | Powered by JetHome®