diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-04-06 08:50:59 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-04-06 08:50:59 +0300 |
commit | 9794cf2311c8fe86f05e046f0b96b46862219e03 (patch) | |
tree | 6bb491a7f5c972c0a5391099a39bd1582ba29802 /storage/xtradb | |
parent | 04737330bea89437d8069d8eeb4bc484213dfdf0 (diff) | |
parent | 26c38de804ecb87eae7fbe6ac32dadebb7803b4d (diff) | |
download | mariadb-git-9794cf2311c8fe86f05e046f0b96b46862219e03.tar.gz |
Merge pull request #168 from grooverdan/10.1-MDEV-8684-UT_RELAX_CPU_isnt_relaxing
MDEV-8684 ut relax cpu isnt relaxing
Diffstat (limited to 'storage/xtradb')
-rw-r--r-- | storage/xtradb/include/ut0ut.h | 23 | ||||
-rw-r--r-- | storage/xtradb/ut/ut0ut.cc | 17 |
2 files changed, 22 insertions, 18 deletions
diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 9228c25d8be..722acdb607e 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -80,20 +80,31 @@ private: # elif defined(HAVE_FAKE_PAUSE_INSTRUCTION) # define UT_RELAX_CPU() __asm__ __volatile__ ("rep; nop") -# elif defined(HAVE_ATOMIC_BUILTINS) -# define UT_RELAX_CPU() do { \ - volatile lint volatile_var; \ - os_compare_and_swap_lint(&volatile_var, 0, 1); \ - } while (0) # elif defined(HAVE_WINDOWS_ATOMICS) /* In the Win32 API, the x86 PAUSE instruction is executed by calling the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() +# elif defined(__powerpc__) +#include <sys/platform/ppc.h> +# define UT_RELAX_CPU() do { \ + volatile lint volatile_var = __ppc_get_timebase(); \ + } while (0) # else # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */ # endif +#define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory") + +# if defined(HAVE_HMT_PRIORITY_INSTRUCTION) +#include <sys/platform/ppc.h> +# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low() +# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med() +# else +# define UT_LOW_PRIORITY_CPU() ((void)0) +# define UT_RESUME_PRIORITY_CPU() ((void)0) +# endif + /*********************************************************************//** Delays execution for at most max_wait_us microseconds or returns earlier if cond becomes true. @@ -334,7 +345,7 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */ diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc index 4eade1fe26e..acedb56879a 100644 --- a/storage/xtradb/ut/ut0ut.cc +++ b/storage/xtradb/ut/ut0ut.cc @@ -46,9 +46,6 @@ Created 5/11/1994 Heikki Tuuri # include <string> #endif /* UNIV_HOTBACKUP */ -/** A constant to prevent the compiler from optimizing ut_delay() away. */ -UNIV_INTERN ibool ut_always_false = FALSE; - #ifdef __WIN__ /*****************************************************************//** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix @@ -398,25 +395,21 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */ { - ulint i, j; + ulint i; - j = 0; + UT_LOW_PRIORITY_CPU(); for (i = 0; i < delay * 50; i++) { - j += i; UT_RELAX_CPU(); + UT_COMPILER_BARRIER(); } - if (ut_always_false) { - ut_always_false = (ibool) j; - } - - return(j); + UT_RESUME_PRIORITY_CPU(); } #endif /* !UNIV_HOTBACKUP */ |