This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Lock elision problems in glibc-2.18
- From: Torvald Riegel <triegel at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 16 Sep 2013 17:06:26 +0200
- Subject: Re: Lock elision problems in glibc-2.18
- Authentication-results: sourceware.org; auth=none
- References: <20130823084916 dot GA5506 at linux dot vnet dot ibm dot com> <1378901002 dot 3196 dot 14075 dot camel at triegel dot csb> <1379001387 dot 32370 dot 1509 dot camel at triegel dot csb> <87ioy36hx2 dot fsf at tassilo dot jf dot intel dot com> <1379321886 dot 32370 dot 3665 dot camel at triegel dot csb> <20130916102501 dot GA4391 at linux dot vnet dot ibm dot com>
On Mon, 2013-09-16 at 12:25 +0200, Dominik Vogt wrote:
> On Mon, Sep 16, 2013 at 10:58:06AM +0200, Torvald Riegel wrote:
> > On Fri, 2013-09-13 at 23:23 -0700, Andi Kleen wrote:
> > > Torvald Riegel <triegel@redhat.com> writes:
> > >
> > > > We need to do this, and if the app
> > > > misinterprets and *always* keeps retrying, it will hang.
> > >
> > > The app is broken then. Retrying forever is simply not allowed.
> > > I don't think it makes sense to complicate glibc for this.
> >
> > I agree (at least for the near future), and my preferred solution would
> > be for certain abort codes to be part of an ABI.
>
> The zEC12 has so called "constrained" transactions that do retry
> until the transaction succeeds. The hardware make great efforts
> to guarantee that the transactions eventually completes (like
> stopping all other cpus if necessary). Although this kind of
> transaction is very, very limited in length, run time, memory
> footprint and control flow, it _might_ be possible to call very
> short inlined functions from within a constrained transaction.
>
> Now, I'm not saying that e.g. calling trylock() from a constrained
> transaction is a problem at the moment (because the limits of
> constrained transactions in the zEC12 are way too strict to call a
> library function, even if linked statically). But the statement
> (and I am aware that is not what Andi wrote)
>
> "an app that always keeps retrying is broken"
>
> is definitely incorrect. (In the future the limitations of
> constrained transactions might be pushed so that calling a
> function might be possible.)
If the HTM gives forward-progress guarantees (eg, "constrained" txns)
and the application can control that the transactions it starts never
violate the constraints for those guarantees, then always retrying would
be allowed. However, glibc doesn't give any guarantees regarding what
it does in its implementation, so if you call trylock(), for example,
you can't rely on "constrained" txns anymore because you don't control
the transaction's code anymore.