Doesn't MIPS S_UNLOCK require a SYNC instruction?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Martin Pitt <martin(at)piware(dot)de>
Subject: Doesn't MIPS S_UNLOCK require a SYNC instruction?
Date: 2005-08-27 18:33:38
Message-ID: 4174.1125167618@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Just when you thought it was safe to go back in the water ...

According to my reading of the MIPS documentation, that architecture
requires explicit "sync" instructions to guarantee ordering of memory
accesses, just like PowerPC does. We have a "sync" now in the tas()
inline code that grabs a spinlock, but it seems to me that there has
to be one in the unlock code as well. Else you could have a situation
where a spinlock is released but updates of the shared memory variables
it's supposed to protect aren't yet written where other processors can
see 'em. In short it seems like this architecture needs S_UNLOCK just
like PowerPC's:

#define S_UNLOCK(lock) \
do \
{\
__asm__ __volatile__ (" sync \n"); \
*((volatile slock_t *) (lock)) = 0; \
} while (0)

This would only make a difference on multi-CPU MIPS machines, which are
probably not so thick on the ground that anyone would have noticed the
bug yet.

Comments?

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-08-27 18:44:24 Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Previous Message Oleg Bartunov 2005-08-27 18:32:38 Re: bitmap scan cause core dump 8.1dev