Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit631beea

Browse files
committed
Use LWSYNC in place of SYNC/ISYNC in PPC spinlocks, where possible.
This is allegedly a win, at least on some PPC implementations, accordingto the PPC ISA documents. However, as with LWARX hints, some PPCplatforms give an illegal-instruction failure. Use the same trick asbefore of assuming that PPC64 platforms will accept it; we might need torefine that based on experience, but there are other projects doinglikewise according to google.I did not add an assembler compatibility test because LWSYNC has beenaround much longer than hint bits, and it seems unlikely that anytoolchains currently in use don't recognize it.
1 parent8496c6c commit631beea

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

‎src/include/pg_config_manual.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@
188188
#endif
189189
#endif
190190

191+
/*
192+
* On PPC machines, decide whether to use LWSYNC instructions in place of
193+
* ISYNC and SYNC. This provides slightly better performance, but will
194+
* result in illegal-instruction failures on some pre-POWER4 machines.
195+
* By default we use LWSYNC when building for 64-bit PPC, which should be
196+
* safe in nearly all cases.
197+
*/
198+
#if defined(__ppc64__)|| defined(__powerpc64__)
199+
#defineUSE_PPC_LWSYNC
200+
#endif
201+
191202
/*
192203
*------------------------------------------------------------------------
193204
* The following symbols are for enabling debugging code, not for

‎src/include/storage/s_lock.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ typedef unsigned int slock_t;
361361
/*
362362
* NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
363363
* an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
364+
* On newer machines, we can use lwsync instead for better performance.
364365
*/
365366
static __inline__int
366367
tas(volatileslock_t*lock)
@@ -382,7 +383,11 @@ tas(volatile slock_t *lock)
382383
"1:li %1,1\n"
383384
"b3f\n"
384385
"2:\n"
386+
#ifdefUSE_PPC_LWSYNC
387+
"lwsync\n"
388+
#else
385389
"isync\n"
390+
#endif
386391
"li %1,0\n"
387392
"3:\n"
388393

@@ -392,13 +397,25 @@ tas(volatile slock_t *lock)
392397
return_res;
393398
}
394399

395-
/* PowerPC S_UNLOCK is almost standard but requires a "sync" instruction */
400+
/*
401+
* PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
402+
* On newer machines, we can use lwsync instead for better performance.
403+
*/
404+
#ifdefUSE_PPC_LWSYNC
405+
#defineS_UNLOCK(lock)\
406+
do \
407+
{ \
408+
__asm__ __volatile__ ("lwsync \n"); \
409+
*((volatile slock_t *) (lock)) = 0; \
410+
} while (0)
411+
#else
396412
#defineS_UNLOCK(lock)\
397413
do \
398414
{ \
399415
__asm__ __volatile__ ("sync \n"); \
400416
*((volatile slock_t *) (lock)) = 0; \
401417
} while (0)
418+
#endif/* USE_PPC_LWSYNC */
402419

403420
#endif/* powerpc */
404421

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp