diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2016-03-30 14:42:12 +1100 |
---|---|---|
committer | Daniel Black <daniel.black@au.ibm.com> | 2016-03-31 16:35:19 +1100 |
commit | 3d1a7cba71f6c843639f0b9a48b12017ff610112 (patch) | |
tree | 039ca7ae4b2754826b70d4c83a8208797ad06be4 /storage | |
parent | d4ba50477e6f0092a3b83528c02c0f30a2b708a3 (diff) | |
download | mariadb-git-3d1a7cba71f6c843639f0b9a48b12017ff610112.tar.gz |
MDEV-8684: Remove delaying maths in ut_delay
Also introduce compiler barrier properly on all architectures.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/include/ut0ut.h | 6 | ||||
-rw-r--r-- | storage/innobase/ut/ut0ut.cc | 10 | ||||
-rw-r--r-- | storage/xtradb/include/ut0ut.h | 6 | ||||
-rw-r--r-- | storage/xtradb/ut/ut0ut.cc | 10 |
4 files changed, 14 insertions, 18 deletions
diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 03e4b5df833..1dcbae0d132 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -89,9 +89,11 @@ private: independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() # else -# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory") +# 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) # define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1") # define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2") @@ -345,7 +347,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/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 85e77b6cced..bde40220db3 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -394,25 +394,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; UT_LOW_PRIORITY_CPU(); - j = 0; - for (i = 0; i < delay * 50; i++) { - j += i; UT_RELAX_CPU(); + UT_COMPILER_BARRIER(); } UT_RESUME_PRIORITY_CPU(); - - return(j); } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 6ea23514994..a14014dc618 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -86,9 +86,11 @@ private: independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() # else -# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory") +# 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) # define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1") # define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2") @@ -337,7 +339,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 42fc04e5f81..acedb56879a 100644 --- a/storage/xtradb/ut/ut0ut.cc +++ b/storage/xtradb/ut/ut0ut.cc @@ -395,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; UT_LOW_PRIORITY_CPU(); - j = 0; - for (i = 0; i < delay * 50; i++) { - j += i; UT_RELAX_CPU(); + UT_COMPILER_BARRIER(); } UT_RESUME_PRIORITY_CPU(); - - return(j); } #endif /* !UNIV_HOTBACKUP */ |