public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Olivier Dion <odion@efficios.com>
Cc: libc-help@sourceware.org,  libc-alpha@sourceware.org,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	 "carlos@redhat.com" <carlos@redhat.com>
Subject: Re: Dead code in pthread_cond_wait() for spin-wait
Date: Thu, 12 Oct 2023 18:40:01 +0200	[thread overview]
Message-ID: <87mswnn6am.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <87ttqvvo7k.fsf@laura> (Olivier Dion's message of "Thu, 12 Oct 2023 11:45:51 -0400")

* Olivier Dion:

> On Wed, 11 Oct 2023, Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> wrote:
>> On 11/10/23 15:30, Olivier Dion via Libc-help wrote:
>
> [...]
>
>>> However, looking at the following snippet in nptl/pthread_cond_wait.c:
>>> 
>>>  static __always_inline int
>>>  __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
>>>      clockid_t clockid, const struct __timespec64 *abstime)
>>>  {
>>>    const int maxspin = 0;
>>>    [...]
>>>            /* Spin-wait first. [...] */
>>> 	   unsigned int spin = maxspin;
>>> 	   while (signals == 0 && spin > 0) {
>>>              [...]
>>>            }
>>>    [...]
>>>  }
>>> 
>>
>> Afaik it was added a placeholder for future extension, so fell free to
>> send a patch to delete it.
>
> [...]
>
> What about making it work instead?  Would this be something to consider?
> IMHO it would be worth it.  Having a fast-path that spins instead of
> taking the futex directly can greatly impact performance in some cases.

Changes to the condvar code are very difficult for us.  There's an
open bug with patches that have been under review for years:

  pthread_cond_signal failed to wake up pthread_cond_wait due to a bug
  in undoing stealing
  <https://sourceware.org/bugzilla/show_bug.cgi?id=25847>

      reply	other threads:[~2023-10-12 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 18:30 Olivier Dion
2023-10-11 18:36 ` Mathieu Desnoyers
2023-10-11 18:57 ` Adhemerval Zanella Netto
2023-10-12 15:45   ` Olivier Dion
2023-10-12 16:40     ` Florian Weimer [this message]

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=87mswnn6am.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-help@sourceware.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=odion@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).