This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for PR libgomp/37938, IA64 specific.


On Thu, Nov 6, 2008 at 11:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Nov 6, 2008 at 10:33 AM, Steve Ellcey <sje@cup.hp.com> wrote:
>>
>> On Thu, 2008-11-06 at 09:56 -0800, H.J. Lu wrote:
>>
>>> Shouldn't we use __sync_lock_test_and_set  to initialize mutux?
>>>
>>>
>>> H.J.
>>> --- libgomp/config/linux/mutex.h.sync 2006-11-18 06:22:18.000000000 -0800
>>> +++ libgomp/config/linux/mutex.h      2008-11-06 09:50:46.000000000 -0800
>>> @@ -38,7 +38,7 @@ typedef int gomp_mutex_t;
>>>
>>>  static inline void gomp_mutex_init (gomp_mutex_t *mutex)
>>>  {
>>> -  *mutex = 0;
>>> +  __sync_lock_test_and_set (mutex, 0);
>>>  }
>>>
>>>  extern void gomp_mutex_lock_slow (gomp_mutex_t *mutex);
>>
>> I was wondering about the initialization but this patch didn't seem to
>> fix the test case in PR 37938 when I added it and then removed my
>> patches.
>>
>
> We have to make sure that both read and write to mutex are done with
> proper memory ordering. I don't think this is IA64 specific.
>
> We can add a memory barrier before _sync_lock_test_and_set (). But I
> don't think we should add a memory barrier in _sync_lock_test_and_set.
>

There are

libgomp/critical.c:static gomp_mutex_t default_lock;
libgomp/critical.c:static gomp_mutex_t create_lock_lock;
libgomp/critical.c:  gomp_mutex_t *plock;
libgomp/critical.c:      && sizeof (gomp_mutex_t) <= sizeof (void *)
libgomp/critical.c:      && __alignof (gomp_mutex_t) <= sizeof (void *))
libgomp/critical.c:    plock = (gomp_mutex_t *)pptr;
libgomp/critical.c:	  gomp_mutex_t *nlock = gomp_malloc (sizeof (gomp_mutex_t));
libgomp/critical.c:	      plock = gomp_malloc (sizeof (gomp_mutex_t));
libgomp/critical.c:  gomp_mutex_t *plock;
libgomp/critical.c:      && sizeof (gomp_mutex_t) <= sizeof (void *)
libgomp/critical.c:      && __alignof (gomp_mutex_t) <= sizeof (void *))
libgomp/critical.c:    plock = (gomp_mutex_t *)pptr;
libgomp/critical.c:static gomp_mutex_t atomic_lock;

Those reads look suspicious.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]