This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 0/6][BZ #11588] pi-condvars: add priority inheritance for pthread_cond_* internal lock
- From: Rich Felker <dalias at libc dot org>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: gratian dot crisan at ni dot com, libc-alpha at sourceware dot org, Darren Hart <dvhart at linux dot intel dot com>, Carlos O'Donell <carlos at redhat dot com>, Joseph Myers <joseph at codesourcery dot com>, Jeff Law <law at redhat dot com>, Scot Salmon <scot dot salmon at ni dot com>, Siddhesh Poyarekar <spoyarek at redhat dot com>, Thomas Gleixner <tglx at linutronix dot de>, Clark Williams <williams at redhat dot com>, "Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>, Will Newton <will dot newton at linaro dot org>, gratian at gmail dot com
- Date: Wed, 20 Aug 2014 16:58:45 -0400
- Subject: Re: [PATCH 0/6][BZ #11588] pi-condvars: add priority inheritance for pthread_cond_* internal lock
- Authentication-results: sourceware.org; auth=none
- References: <OF6ABEE614 dot FAE80AD2-ON86257D0E dot 006B38F4-86257D0E dot 0070034A at ni dot com> <1406680317-20189-1-git-send-email-gratian dot crisan at ni dot com> <1408396459 dot 14301 dot 29 dot camel at triegel dot csb> <20140818214134 dot GW12888 at brightrain dot aerifal dot cx> <1408398798 dot 2220 dot 11 dot camel at triegel dot csb> <20140818221755 dot GY12888 at brightrain dot aerifal dot cx> <1408478310 dot 2220 dot 84 dot camel at triegel dot csb>
On Tue, Aug 19, 2014 at 09:58:29PM +0200, Torvald Riegel wrote:
> On Mon, 2014-08-18 at 18:17 -0400, Rich Felker wrote:
> > On Mon, Aug 18, 2014 at 11:53:18PM +0200, Torvald Riegel wrote:
> > > On Mon, 2014-08-18 at 17:41 -0400, Rich Felker wrote:
> > > > On Mon, Aug 18, 2014 at 11:14:19PM +0200, Torvald Riegel wrote:
> > > > > On Tue, 2014-07-29 at 19:31 -0500, gratian.crisan@ni.com wrote:
> > > > > > Torvald Riegel made us aware of the new POSIX changes related to condvars
> > > > > > (http://austingroupbugs.net/view.php?id=609) and C++11 clarification
> > > > > > (http://cplusplus.github.com/LWG/lwg-active.html#2190)
> > > > > > We believe we can work on these issues in parallel and if they end up
> > > > > > colliding we will fix it.
> > > > >
> > > > > I've asked the Austin Group about the current status of #609. It seems
> > > > > they want the stronger ordering guarantees:
> > > > > http://austingroupbugs.net/view.php?id=609#c2349
> > > > >
> > > > > I have an implementation that fulfills these guarantees, but I don't
> > > > > think it's possible to fully implement PI with the stronger guarantees
> > > > > and the futex operations that we currently have. The possible options
> >
> > BTW, does the current implementation, or your new one pending, address
> > self-synchronized destruction, i.e.
> >
> > "It shall be safe to destroy an initialized condition variable upon
> > which no threads are currently blocked."
>
> The new one does fulfill that requirement (well, the requirement is not
> completely specified, but a cond_signal won't do any harm after it has
> woken up a waiter). The general futex issue (futex_wakes hitting
> possibly reused memory) still applies, of course.
Nice.
BTW, while FUTEX_WAKE on possibly-reused memory seems harmless to me
(unless you have code relying on the successful return value of
futex_wait being distinct from EAGAIN), FUTEX_REQUEUE on possibly
reused memory seems potentially dangerous. I haven't worked out the
details except to reason that FUTEX_REQUEUE is safe as long as the
thread performing the requeue operation holds the lock that the target
will be requeued to.
> > > > > that I see are:
> > > > > * Accept potential ABA issues (e.g., a lost wake-up if you do exactly
> > > > > 2^32 signals after a wait).
> > > > > * Accept that there's no PI every 2^32 wait calls (maybe that number can
> > > > > be increased somewhat, but this depends on the interleaving of
> > > > > wait/signal calls I believe).
> > > > > * Don't support PI on process-shared condvars, so that we can boost the
> > > > > priority of waiters with per-waiter PI mutexes. More overhead.
> > > >
> > > > Is there any documentation on the current glibc design and how it
> > > > avoids the 2^32 ABA issue with sequence numbers?
> > >
> > > The current algorithm doesn't prevent the ABA issue.
> >
> > Do you have an in-progress new one that does, though?
>
> The algorithm I have has no ABA issue.
Looking forward to seeing what you came up with!
Rich