Commit d4ba5047 authored by Yasufumi Kinoshita's avatar Yasufumi Kinoshita Committed by Daniel Black

Some POWER specific optimizations

Bug#18842925 : SET THREAD PRIORITY IN INNODB MUTEX SPINLOOP
Like "pause" instruction for hyper-threading at Intel CPUs,
POWER has special instructions only for hinting priority of hardware-threads.

Approved by Sunny in rb#6256

Backport of the 5.7 fix - https://github.com/mysql/mysql-server/commit/c92102a6ef0f280bfb56e5585fca0d0cdcc34890
(excluded cache line size patch)

Suggestion by Stewart Smith
parent 2275640d
......@@ -225,6 +225,7 @@
#cmakedefine HAVE_PREAD 1
#cmakedefine HAVE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_HMT_PRIORITY_INSTRUCTION 1
#cmakedefine HAVE_RDTSCLL 1
#cmakedefine HAVE_READ_REAL_TIME 1
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
......
......@@ -855,6 +855,16 @@ IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
}
" HAVE_FAKE_PAUSE_INSTRUCTION)
ENDIF()
IF (NOT HAVE_PAUSE_INSTRUCTION)
CHECK_C_SOURCE_COMPILES("
int main()
{
__asm__ __volatile__ (\"or 1,1,1\");
__asm__ __volatile__ (\"or 2,2,2\");
return 0;
}
" HAVE_HMT_PRIORITY_INSTRUCTION)
ENDIF()
ENDIF()
CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1)
......
......@@ -92,6 +92,14 @@ struct ut_when_dtor {
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# endif
# 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")
# 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.
......
......@@ -401,6 +401,8 @@ ut_delay(
{
ulint i, j;
UT_LOW_PRIORITY_CPU();
j = 0;
for (i = 0; i < delay * 50; i++) {
......@@ -408,6 +410,8 @@ ut_delay(
UT_RELAX_CPU();
}
UT_RESUME_PRIORITY_CPU();
return(j);
}
#endif /* !UNIV_HOTBACKUP */
......
......@@ -89,6 +89,14 @@ struct ut_when_dtor {
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# endif
# 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")
# 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.
......
......@@ -402,6 +402,8 @@ ut_delay(
{
ulint i, j;
UT_LOW_PRIORITY_CPU();
j = 0;
for (i = 0; i < delay * 50; i++) {
......@@ -409,6 +411,8 @@ ut_delay(
UT_RELAX_CPU();
}
UT_RESUME_PRIORITY_CPU();
return(j);
}
#endif /* !UNIV_HOTBACKUP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment