mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, drepper@redhat.com,
	tglx@linutronix.de, arjan@infradead.org, dsingleton@mvista.com
Subject: Re: [patch 0/5] lightweight robust futexes: -V1
Date: Wed, 15 Feb 2006 13:45:56 -0800	[thread overview]
Message-ID: <20060215134556.57cec83a.akpm@osdl.org> (raw)
In-Reply-To: <20060215151711.GA31569@elte.hu>

Ingo Molnar <mingo@elte.hu> wrote:
>
> ...
>
> E.g. in David Singleton's robust-futex-6.patch, there are 3 new syscall 
> variants to sys_futex(): FUTEX_REGISTER, FUTEX_DEREGISTER and 
> FUTEX_RECOVER. The kernel attaches such robust futexes to vmas (via 
> vma->vm_file->f_mapping->robust_head), and at do_exit() time, all vmas 
> are searched to see whether they have a robust_head set.

hm.   What happened if the futex was in anonymous memory (vm_file==NULL)?

> New approach to robust futexes
> ------------------------------
> 
> At the heart of this new approach there is a per-thread private list of 
> robust locks that userspace is holding (maintained by glibc) - which 
> userspace list is registered with the kernel via a new syscall [this 
> registration happens at most once per thread lifetime]. At do_exit() 
> time, the kernel checks this user-space list: are there any robust futex 
> locks to be cleaned up?

Neat.

> 
> ...
> The list is guaranteed to be private and per-thread, so it's lockless. 
>

Why is that guaranteed??  Another thread could be scribbling on it while
the kernel is walking it?

Why use a list and not just a sparse array? (realloc() works..)

>
> There is one race possible though: since adding to and removing from the 
> list is done after the futex is acquired by glibc, there is a few 
> instructions window for the thread (or process) to die there, leaving 
> the futex hung. To protect against this possibility, userspace (glibc) 
> also maintains a simple per-thread 'list_op_pending' field, to allow the 
> kernel to clean up if the thread dies after acquiring the lock, but just 
> before it could have added itself to the list. Glibc sets this 
> list_op_pending field before it tries to acquire the futex, and clears 
> it after the list-add (or list-remove) has finished.

Oh.  I'm surprised that glibc cannot just add the futex to the list prior
to acquiring it, then the exit-time code can work out whether the futex was
really taken-and-contended.  Even if the kernel makes a mistake it either
won't find a futex there or it won't wake anyone up.


I think the patch breaks the build if CONFIG_FUTEX=n?

The patches are misordered - with only the first patch applied, the kernel
won't build.  That's a nasty little landmine for git-bisect users.

Why do we need sys_get_robust_list(other task)?

  parent reply	other threads:[~2006-02-15 21:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-15 15:17 Ingo Molnar
2006-02-15 15:22 ` Ingo Molnar
2006-02-15 17:35 ` Andi Kleen
2006-02-15 17:50   ` Ulrich Drepper
2006-02-15 18:42     ` Andi Kleen
2006-02-15 19:49       ` Christopher Friesen
2006-02-15 20:02         ` Andi Kleen
2006-02-15 20:13           ` Antonio Vargas
2006-02-15 20:25             ` Andi Kleen
2006-02-15 20:59           ` Ingo Molnar
2006-02-15 20:43       ` Ingo Molnar
2006-02-15 19:05 ` Daniel Walker
2006-02-15 19:11   ` Arjan van de Ven
2006-02-15 19:13     ` Daniel Walker
2006-02-15 21:31   ` Ingo Molnar
2006-02-16 15:43     ` Daniel Walker
2006-02-15 21:45 ` Andrew Morton [this message]
2006-02-15 22:14   ` Ingo Molnar
2006-02-17 21:59     ` Daniel Jacobowitz
2006-02-16  3:57 ` Darren Hart
2006-02-16 14:58 ` Johannes Stezenbach
2006-02-16 17:20   ` Ingo Molnar
2006-02-16 19:04     ` Daniel Walker
2006-02-17  9:09       ` Avi Kivity
2006-02-17 19:55     ` Johannes Stezenbach
2006-02-17 20:02       ` Arjan van de Ven

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=20060215134556.57cec83a.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=drepper@redhat.com \
    --cc=dsingleton@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome