powerpc pthread_once bug fix

Jeff Law law@redhat.com
Thu Aug 30 19:06:00 GMT 2012


On 07/11/2012 05:36 AM, Alan Modra wrote:
> This fixes some bugs in the powerpc pthread_once code.  Ref
> gcc.gnu.org/bugzilla/show_bug.cgi?id=52839#c10
>
> Release barriers are needed to ensure any memory written by
> init_routine is seen by other threads before *once_control changes.
> In the case of clear_once_control we need to flush any partially
> written state.
>
> 2012-06-28  Alan Modra  <amodra@gmail.com>
>
> 	* sysdeps/unix/sysv/linux/powerpc/pthread_once.c (__pthread_once):
> 	Add release barrier before setting once_control to say
> 	initialisation is done.  Add hints on lwarx.  Use macro in
> 	place of isync.
> 	(clear_once_control): Add release barrier.
FWIW, I saw hangs with this too, both ppc and ppc64.  It's got something 
to do with that last hunk which replaced the atomic_increment call with 
an asm which appears to impmlement an atomic_read_barrier + 
atomic_increment.

My PPC-fu is largely gone.  The only oddities I see are the lack of a 
memory clobber and using GENERAL_REGS instead of BASE_REGS for 
once_control.  Is there something special about r0 in lwarx/stwcx insns 
on PPC?

jeff



More information about the Libc-alpha mailing list