PATCH: Add memory barrier to malloc

H. J. Lu hjl@lucon.org
Sun May 4 23:51:00 GMT 2003


On Sun, May 04, 2003 at 09:03:38AM -0700, Dan Kegel wrote:
> Momchil Velikov wrote:
> >>>>>>"H.J. Lu" == H J Lu <hjl@lucon.org> writes:
> > 
> >     H.J. Lu> --- libc/malloc/arena.c.barrier	2002-12-26 16:36:41.000000000 -0800
> >     H.J. Lu> +++ libc/malloc/arena.c	2003-05-03 23:56:59.000000000 -0700
> >     H.J. Lu> @@ -758,6 +758,7 @@ arena_get2(a_tsd, size) mstate a_tsd; si
> >     H.J. Lu>    /* Add the new arena to the global list.  */
> >     H.J. Lu>    (void)mutex_lock(&list_lock);
> >     H.J. Lu>    a->next = main_arena.next;
> >     H.J. Lu> +  atomic_write_barrier ();
> >     H.J. Lu>    main_arena.next = a;
> >     H.J. Lu>    (void)mutex_unlock(&list_lock);
> > 
> > Why would a barrier be needed inside a critical section ? Aren't POSIX
> > memory model guarantees sufficient ?
> 
> I guess list_lock doesn't protect accesses to main_arena?

That is currect. list_lock isn't held when walking through linked list
for available arenas.


H.J.



More information about the Libc-alpha mailing list