This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv2] powerpc: Spinlock optimization and cleanup
- From: Rich Felker <dalias at libc dot org>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: Szabolcs Nagy <szabolcs dot nagy at arm dot com>, "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "rth at twiddle dot net" <rth at twiddle dot net>, Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Steve Munroe <sjmunroe at us dot ibm dot com>
- Date: Thu, 1 Oct 2015 15:27:18 -0400
- Subject: Re: [PATCHv2] powerpc: Spinlock optimization and cleanup
- Authentication-results: sourceware.org; auth=none
- References: <560C0DA6 dot 5060409 at linux dot vnet dot ibm dot com> <560CFA64 dot 2030205 at arm dot com> <1443727026 dot 30828 dot 413 dot camel at localhost dot localdomain>
On Thu, Oct 01, 2015 at 09:17:06PM +0200, Torvald Riegel wrote:
> > (the issue is that for correct pthread_spin_trylock behavior
> > the lock should be seqcst instead of acquire and the unlock
> > should be release instead of barrier+store otherwise trylock
> > can spuriously report locked state).
>
> Right now, unlock is a full barrier (ie, seqcst) plus store. That is
> stronger than a release store. Also note that a failing POSIX
> synchronization function is not supposed to synchronize memory. So, a
> failing trylock doesn't help a program unless it synchronizes through
> some other way, in which case this other way will "provide" the
> barriers.
As always, the issue is not whether it synchronizes memory on failure,
but whether it can accurately determine whether to fail or not without
synchronizing memory. The latter is an implementation detail of
course, but in practice you can't make this determination without
synchronizing memory.
Rich