mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Change the spinlock primitives to function as compiler barriers.
Previously, they functioned as barriers against CPU reordering but not compiler reordering, an odd API that required extensive use of volatile everywhere that spinlocks are used. That's error-prone and has negative implications for performance, so change it. In theory, this makes it safe to remove many of the uses of volatile that we currently have in our code base, but we may find that there are some bugs in this effort when we do. In the long run, though, this should make for much more maintainable code. Patch by me. Review by Andres Freund.
This commit is contained in:
@@ -154,6 +154,18 @@ s_lock(volatile slock_t *lock, const char *file, int line)
|
||||
return delays;
|
||||
}
|
||||
|
||||
#ifdef USE_DEFAULT_S_UNLOCK
|
||||
void
|
||||
s_unlock(slock_t *lock)
|
||||
{
|
||||
#ifdef TAS_ACTIVE_WORD
|
||||
/* HP's PA-RISC */
|
||||
*TAS_ACTIVE_WORD(lock) = -1;
|
||||
#else
|
||||
*lock = 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set local copy of spins_per_delay during backend startup.
|
||||
|
||||
Reference in New Issue
Block a user