Back-patch fix for correct TAS operation on multi-CPU PPC machines.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Sep 2002 20:24:53 +0000 (20:24 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Sep 2002 20:24:53 +0000 (20:24 +0000)
src/backend/storage/lmgr/s_lock.c
src/include/storage/s_lock.h

index ea7b40581e4c562260923a8261de540bccaf15c9..3719762e75f83e4ccc3606bd3e1c2ac5916d728b 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.5 2001/11/05 17:46:28 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.5.2.1 2002/09/30 20:24:53 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -115,6 +115,9 @@ _success:                       \n\
 /* used in darwin. */
 /* We key off __APPLE__ here because this function differs from
  * the LinuxPPC implementation only in compiler syntax.
+ *
+ * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
+ * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
  */
 static void
 tas_dummy()
@@ -134,6 +137,7 @@ tas:                            \n\
 fail:      li      r3,1        \n\
            blr                 \n\
 success:                       \n\
+           isync               \n\
            li      r3,0        \n\
            blr                 \n\
 ");
@@ -158,6 +162,7 @@ tas:                            \n\
 fail:      li      3,1         \n\
            blr                 \n\
 success:                       \n\
+           isync               \n\
            li      3,0         \n\
            blr                 \n\
 ");
index be79b51a17b56e3473cb55260dfa56c2511a2897..d8d897e2c98fe8b11ba61c39eb2c8eb1360bec63 100644 (file)
@@ -63,7 +63,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *   $Id: s_lock.h,v 1.97 2002/01/29 15:44:42 tgl Exp $
+ *   $Id: s_lock.h,v 1.97.2.1 2002/09/30 20:24:53 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -217,6 +217,21 @@ tas(volatile slock_t *lock)
 #endif  /* defined(__mc68000__) && defined(__linux__) */
 
 
+#if defined(__ppc__) || defined(__powerpc__)
+/*
+ * We currently use out-of-line assembler for TAS on PowerPC; see s_lock.c.
+ * S_UNLOCK is almost standard but requires a "sync" instruction.
+ */
+#define S_UNLOCK(lock) \
+do \
+{\
+   __asm__ __volatile__ (" sync \n"); \
+   *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+
+#endif /* defined(__ppc__) || defined(__powerpc__) */
+
+
 #if defined(NEED_VAX_TAS_ASM)
 /*
  * VAXen -- even multiprocessor ones