From: Pierre PEIFFER <pierre.peiffer@bull.net>
To: Ulrich Drepper <drepper@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
jakub@redhat.com
Subject: Re: [PATCH] 2.6.16 - futex: small optimization (?)
Date: Wed, 29 Mar 2006 15:18:43 +0200 [thread overview]
Message-ID: <442A8933.6090408@bull.net> (raw)
In-Reply-To: <a36005b50603280702n2979d8ddh97484615ea9d4f3a@mail.gmail.com>
Ulrich Drepper a écrit :
>
> There are no such situations anymore in an optimal userlevel
> implementation. The last problem (in pthread_cond_signal) was fixed
> by the addition of FUTEX_WAKE_OP. The userlevel code you're looking
> at is simply not optimized for the modern kernels.
>
I think there is a misunderstanding here.
FUTEX_WAKE_OP is implemented to handle simultaneously more than one
futex in some specific situations (such as pthread_cond_signal).
The scenario I've described occurred in futex_wake, futex_wake_op and
futex_requeue and is _independent_ of the userlevel code.
All these functions call wake_futex, and then wake_up_all, with the
futex_hash_bucket lock still held.
If the woken thread is immediately scheduled (in wake_up_all), and only
in this case (because of a higher priority, etc), it will try to take
this lock too (because of the "if (lock_ptr != 0)" statement in
unqueue_me), causing two task-switches to take this lock for nothing.
Otherwise, it will not: lock_ptr is set to NULL just after the
wake_up_all call)
This scenario happens at least in pthread_cond_signal,
pthread_cond_broadcast and probably all pthread_*_unlock functions.
The patch I've proposed should, at least in theory, solve this. But I'm
not sure of the correctness...
--
Pierre P.
next prev parent reply other threads:[~2006-03-29 13:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-28 7:37 [PATCH] 2.6.16 - futex: small optimization (?) Pierre PEIFFER
2006-03-28 10:05 ` Eric Dumazet
2006-03-28 15:02 ` Ulrich Drepper
2006-03-28 22:46 ` Bill Davidsen
2006-03-29 15:26 ` Ingo Molnar
2006-03-30 20:27 ` Bill Davidsen
2006-03-31 6:01 ` Ingo Molnar
2006-03-31 14:50 ` Bill Davidsen
2006-03-31 18:15 ` Ingo Molnar
2006-03-29 13:18 ` Pierre PEIFFER [this message]
2006-03-29 15:26 ` Eric Dumazet
2006-03-30 14:51 ` Pierre PEIFFER
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=442A8933.6090408@bull.net \
--to=pierre.peiffer@bull.net \
--cc=drepper@gmail.com \
--cc=jakub@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.