1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Use mutex hint bit in PPC LWARX instructions, where possible.

The hint bit makes for a small but measurable performance improvement
in access to contended spinlocks.

On the other hand, some PPC chips give an illegal-instruction failure.
There doesn't seem to be a completely bulletproof way to tell whether the
hint bit will cause an illegal-instruction failure other than by trying
it; but most if not all 64-bit PPC machines should accept it, so follow
the Linux kernel's lead and assume it's okay to use it in 64-bit builds.
Of course we must also check whether the assembler accepts the command,
since even with a recent CPU the toolchain could be old.

Patch by Manabu Ori, significantly modified by me.
This commit is contained in:
Tom Lane
2012-01-01 22:39:59 -05:00
parent 6b6137e4ef
commit 5cfa8dd300
5 changed files with 104 additions and 3 deletions

View File

@@ -6,6 +6,9 @@
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/pg_config_manual.h
*------------------------------------------------------------------------
*/
@@ -170,6 +173,21 @@
#define PG_PRINTF_ATTRIBUTE printf
#endif
/*
* On PPC machines, decide whether to use the mutex hint bit in LWARX
* instructions. Setting the hint bit will slightly improve spinlock
* performance on POWER6 and later machines, but does nothing before that,
* and will result in illegal-instruction failures on some pre-POWER4
* machines. By default we use the hint bit when building for 64-bit PPC,
* which should be safe in nearly all cases. You might want to override
* this if you are building 32-bit code for a known-recent PPC machine.
*/
#ifdef HAVE_PPC_LWARX_MUTEX_HINT /* must have assembler support in any case */
#if defined(__ppc64__) || defined(__powerpc64__)
#define USE_PPC_LWARX_MUTEX_HINT
#endif
#endif
/*
*------------------------------------------------------------------------
* The following symbols are for enabling debugging code, not for