Re: [PATCH 2.6.21-rc3-mm2 3/4] futex_requeue_pi optimization

Peter Zijlstra
2007-03-16T10:14:12Z

On Tue, 2007-03-13 at 10:52 +0100, Pierre.Peiffer@bull.net wrote:
> plain text document attachment (futex-requeue-pi.diff)
> This patch provides the futex_requeue_pi functionality.
>
> This provides an optimization, already used for (normal) futexes, to be used for
> PI-futexes.
>
> This optimization is currently used by the glibc in pthread_broadcast, when
> using "normal" mutexes. With futex_requeue_pi, it can be used with PRIO_INHERIT
> mutexes too.
>
> Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net>
>
> ---

> /*
> + * Retrieve the original address used to compute this key
> + */
> +static void *get_futex_address(union futex_key *key)
> +{
> + void *uaddr;
> +
> + if (key->both.offset & 1) {
> + /* shared mapping */
> + uaddr = (void*)((key->shared.pgoff << PAGE_SHIFT)
> + + key->shared.offset - 1);
> + } else {
> + /* private mapping */
> + uaddr = (void*)(key->private.address + key->private.offset);
> + }
> +
> + return uaddr;
> +}

This will not work for nonlinear vmas, granted, not a lot of ppl stick
futexes in nonlinear vmas, but the futex_key stuff handles it, this
doesn't.