From: "Peter Wächtler" <pwaechtler@loewe-komp.de>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
linux-kernel@vger.kernel.org, frankeh@watson.ibm.com
Subject: Re: [PATCH] Futex Asynchronous Interface
Date: Wed, 12 Jun 2002 18:29:34 +0200 [thread overview]
Message-ID: <3D0776EE.4040701@loewe-komp.de> (raw)
In-Reply-To: <Pine.LNX.4.33.0206120833470.23029-100000@penguin.transmeta.com>
Linus Torvalds wrote:
> On Wed, 12 Jun 2002, Peter Wächtler wrote:
>
>>What are the plans on how to deal with a waiter when the lock holder
>>dies abnormally?
>>
>
> That's why they are called FUTEX'es - they're fast. They're NOT SysV
> semaphores, and they are done 99% in user space. The kernel doesn't even
> _know_ about them until contention happens, and even then only in a rather
> dim "somebody wants me to do this, but I don't know _what_ he is doing"
> way.
>
>
>>What about sending a signal (SIGTRAP or SIGLOST), returning -1 and
>>setting errno to a reasonable value (EIO?)
>>
>
> There's just nothing the kernel _can_ do. The common case (by far) is that
> the kernel has never seen the futex at all, since many uses are likely to
> not have much contention. So when a user program dies holding such a
> uncontended lock, the kernel simply _cannot_ do anything.
>
For the uncontended case: their is no blocked process...
Huh, I think you misunderstood me.
One (or more) process is blocked in a waitqueue in the kernel - waiting
for a futex to be released.
The lock holder crashes - say with SIGSEGV. Now if we don't release the
waiters, they wait until reboot or user/admin kills them with a signal -
assuming they are interruptible sleeping.
I know that the kernel can't do anything about the aborted critical section.
But the waiters should be "freed" - and now we can discuss if we kill them
or report an error and let them deal with that.
So we surely have a process_exit_cleanup function (where FDs are closed etc).
There we would have to add a check if that process is holding a futex, the
waitqueue for that and "release" all waiters.
Can't be done? I don't think that this would add a performance hit
since it's only done on exit (and especially "abnormal" exit).
There is no way to check if a process holds a futex and which processes
are blocked on the associated waitqueue?
The waitqueue is built upon linking a struct futex_q list on the blocked
processes stack.
The entries to these lists are in a static array
struct list_head futex_queues[1<<FUTEX_HASHBITS].
At least we could search them on "exit due to fatal signal" when exiting.
Perhaps spending a bit in task_struct WHEN they got a lock - so we don't
have to search on every process exit.
Yes, searching the hash array lists could last a long time, but:
Is process exit time that important?
> (The kernel also cannot do anything even for the contended locks, because
> the whole interface is designed for speed and with the knowledge that the
> kernel won't be able to fix stuff up, so the kernel doesn't actually have
> enough information even in the contention case. See the "dim notion"
> above).
>
> Besides, if you have a threads package that uses some lock for mutual
> exclusion, and a thread dies while holding the lock, there's nothign sane
> anybody can do about it anyway. The data structures are likely to be in an
> invalid state, and just making every other thread block on the lock until
> you can attach a debugger is probably the closest to a _right_ thing you
> can do.
>
> In short: it's not a bug, it's a design feature, and it's very much
> designed for efficiency.
>
And leave dangling processes (lost futex zombies)?
next prev parent reply other threads:[~2002-06-12 16:27 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-06 7:26 [PATCH] Futex Asynchronous Interface Rusty Russell
2002-06-02 0:10 ` Pavel Machek
2002-06-10 6:57 ` Rusty Russell
2002-06-06 16:36 ` Linus Torvalds
2002-06-06 19:27 ` Alan Cox
2002-06-06 23:21 ` Rusty Russell
2002-06-07 8:33 ` Peter Wächtler
2002-06-08 22:28 ` Linus Torvalds
2002-06-09 9:49 ` Kai Henningsen
2002-06-09 18:09 ` Linus Torvalds
2002-06-09 19:06 ` Thunder from the hill
2002-06-10 6:39 ` Kai Henningsen
2002-06-10 7:55 ` Helge Hafting
2002-06-10 14:10 ` Thunder from the hill
2002-06-10 20:46 ` Kai Henningsen
2002-06-11 14:14 ` john slee
2002-06-10 15:11 ` Linus Torvalds
2002-06-11 15:06 ` Eric W. Biederman
2002-06-10 20:57 ` H. Peter Anvin
2002-06-09 10:07 ` Peter Wächtler
2002-06-09 17:49 ` Linus Torvalds
2002-06-07 9:06 ` Rusty Russell
2002-06-08 22:42 ` Linus Torvalds
2002-06-11 9:15 ` Rusty Russell
2002-06-11 16:53 ` Linus Torvalds
2002-06-12 5:32 ` Rusty Russell
2002-06-12 9:16 ` Peter Wächtler
2002-06-12 14:19 ` Hubertus Franke
2002-06-12 16:50 ` Peter Wächtler
2002-06-12 18:15 ` Vladimir Zidar
2002-06-12 15:39 ` Linus Torvalds
2002-06-12 16:29 ` Peter Wächtler [this message]
2002-06-12 16:52 ` Linus Torvalds
2002-06-12 17:07 ` Peter Wächtler
2002-06-12 18:32 ` Saurabh Desai
2002-06-12 20:05 ` Oliver Xymoron
2002-06-12 20:16 ` Linus Torvalds
2002-06-13 2:57 ` Rusty Russell
2002-06-13 9:37 ` Peter Wächtler
2002-06-13 9:55 ` Rusty Russell
2002-06-13 16:38 ` Gabriel Paubert
2002-06-13 16:40 ` Linus Torvalds
2002-06-13 1:32 ` Rusty Russell
-- strict thread matches above, loose matches on Subject: below --
2002-06-06 16:08 Martin Wirth
2002-06-06 22:59 ` Rusty Russell
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=3D0776EE.4040701@loewe-komp.de \
--to=pwaechtler@loewe-komp.de \
--cc=frankeh@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--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