From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alison Chaiken <alison@she-devel.com>
Cc: corbet@lwn.net, gratian.crisan@ni.com, triegel@redhat.com,
rostedt@goodmis.org, linux-kernel@vger.kernel.org,
linux-rt-users@vger.kernel.org, achaiken@aurora.tech
Subject: Re: [PATCH] Documentation: locking: update libc support status of PI futexes
Date: Fri, 23 May 2025 17:00:28 +0200 [thread overview]
Message-ID: <20250523150028.62N5N42-@linutronix.de> (raw)
In-Reply-To: <619bfa123308eeb3a548fae36a3f9e4c@she-devel.com>
On 2025-01-11 10:55:55 [-0800], Alison Chaiken wrote:
> > Are you sure? My memory is that glibc avoided using the internal mutex.
> > The old problem should be gone and pthread_cond_signal() and
> > pthread_cond_wait() should work.
>
> Ignoring support for 64-bit time, the last substantive change to
> pthread_cond_wait() and pthread_cond_signal() was Torvald Riegel's commit
> ed19993b5b0d05d62cc883571519a67dae481a14 "New condvar implementation that
> provides stronger ordering guarantees," which fixed problems with waking of
> ineligible futex waiters and with ABA issues concerning the futex word.
> What the patch does not do is made clear by the commit message:
>
> This condvar doesn't yet use a requeue optimization (ie, on a
> broadcast,
> waking just one thread and requeueing all others on the futex of the
> mutex supplied by the program).
>
> What futex-requeue-pi.rst directs is
>
> In order to support PI-aware pthread_condvar's, the kernel needs to
> be able to requeue tasks to PI futexes.
>
> Riegel and Darren Hart discussed Riegel's patch in at length at the 2016 RT
> Summit:
>
> https://wiki.linuxfoundation.org/realtime/events/rt-summit2016/schedule
>
> The related glibc bug report by Darren may be found at
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=11588
>
> The last comment on the bug from 2017 is by Riegel:
>
> So far, there is no known solution for how to achieve PI support given
> the current constraints we have (eg, available futex operations, POSIX
> requirements, ...).
>
> I ran the bug reproducer posted by Darren in Qemu and found that it did not
> fail. I'm not sure if the result is valid given the peculiarities of Qemu,
> or whether I made some other mistake.
I've been looking at this again for other reasons and looked at the
code again…
Back then we use futex-requeue API and required both futex-object to
have the PI bit set. This wasn't the case originally, hence the patch by
Darren which did not make it into the official libc.
With the rework by Riegel, the mutex within pthread's condvar
implementation is gone also the usage of the requeue API. The
pthread_cond_wait()/ pthread_cond_signal() API is back to use futex'
wait/ wake.
The glibc comments write something about important ordering constrains.
The futex wait enqueues the waiter according to its priority. So the
task with highest priority gets always a front seat. The futex wake
function wakes always the first waiter in the queue.
With all this I would say that the glib'c condvar implementation does
not have any issues since the rework.
There were a few loops, with a 0 retry counter (basically dead) and they
have been removed.
Sebastian
next prev parent reply other threads:[~2025-05-23 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-28 18:15 [PATCH] Documentation: locking: update libc support status of PI futexes alison
2025-01-07 15:31 ` Sebastian Andrzej Siewior
2025-01-11 18:55 ` Alison Chaiken
2025-05-23 15:00 ` Sebastian Andrzej Siewior [this message]
2025-05-23 16:11 ` Jan Kiszka
2025-05-24 22:09 ` Alison Chaiken
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=20250523150028.62N5N42-@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=achaiken@aurora.tech \
--cc=alison@she-devel.com \
--cc=corbet@lwn.net \
--cc=gratian.crisan@ni.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=triegel@redhat.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 NNTP newsgroup(s).