diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/changelog percona-xtradb-cluster-5.6-5.6.34-26.19/debian/changelog --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/changelog 2017-07-30 22:50:08.000000000 -0400 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/changelog 2017-09-11 13:06:41.000000000 -0300 @@ -1,3 +1,19 @@ +percona-xtradb-cluster-5.6 (5.6.34-26.19-0ubuntu3) artful; urgency=high + + * d/p/ibuf-uses-full-memory-barrier-ppc64.patch: This patch implements + a full memory barrier for InnoDB mutex entry/exit on PowerPC. + (LP: #1657256). + + * d/p/debian/patches/weak-memory-compat.patch: Removed as is already + covered by the newer patch. + + * d/control: Sets gcc-6/g++-6 as a build-dependency as 7.x breaks + the build in different sections of the code. (LP: #1714554). + + * d/rules: Enforces the usage of gcc-6 as the default compiler. + + -- Jorge Niedbalski Thu, 10 Aug 2017 14:53:52 -0400 + percona-xtradb-cluster-5.6 (5.6.34-26.19-0ubuntu2) artful; urgency=medium * No-change rebuild against libevent-2.1-6 diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/control percona-xtradb-cluster-5.6-5.6.34-26.19/debian/control --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/control 2017-03-03 06:41:02.000000000 -0300 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/control 2017-09-11 12:57:48.000000000 -0300 @@ -12,9 +12,9 @@ debhelper (>= 9~), dh-python, file (>= 3.28), - g++ (>= 4.4), + g++-6, gawk, - gcc (>= 4.4), + gcc-6, ghostscript, libaio-dev [linux-any], libevent-dev, diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/ibuf-mutex-use-full-memory-barrier-powerpc.patch percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/ibuf-mutex-use-full-memory-barrier-powerpc.patch --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/ibuf-mutex-use-full-memory-barrier-powerpc.patch 1969-12-31 21:00:00.000000000 -0300 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/ibuf-mutex-use-full-memory-barrier-powerpc.patch 2017-09-11 13:04:02.000000000 -0300 @@ -0,0 +1,331 @@ +Description: This patch is a combination of different upstream MariaDB +patches for fixing the behavior of memory barriers when acquiring and +releasing mutexes on PowerPC machines. + +* Commit 6ea41f1e84eb6b864cac17ad0b862bde9820dc33: Implements +the os_fast_mutex(unlock_full_barrier/trylock_full_barrier) which +implies a full memory barrier. + +It also implements the os_mb OS memory barrier primitives for the +different architectures which is guaranteed to act as +full acquire-release barrier. + +* Commit 5ad02062d928cccbd29c0a2db6f0f7ceb33195d1: Based on the +previous commit, it adds a memory barrier on the mutex_exit +to prevent reading the number of waiters before releasing the lock, +this is completed with a modification on mutex_set_waiters that adds +a os_mb to make sure waiters store won't pass over mutex_test_and_set. + +* Commit 40497577ffd9f85557b15e08ad913f627b2e9530: The ib mutex set_and_test +function and acquires the lock by calling the os_atomic_test_and_set_byte_acquire +method which should be safe in PowerPC, at the same time the mutex unlock method +will call the os_atomic_test_and_set_byte_release which is implemented as a +__sync_lock_release + a __sync_synchronize call in PowerPC. + +Bug-Ubuntu: https://launchpad.net/bugs/1657256 +Reviewed-By: Jorge Niedbalski + +--- percona-xtradb-cluster-5.6-5.6.34-26.19.orig/storage/innobase/include/os0sync.h ++++ percona-xtradb-cluster-5.6-5.6.34-26.19/storage/innobase/include/os0sync.h +@@ -393,12 +393,32 @@ pfs_os_fast_mutex_unlock( + #endif /* UNIV_PFS_MUTEX */ + + /**********************************************************//** ++Acquires ownership of a fast mutex. Implies a full memory barrier even on ++platforms such as PowerPC where this is not normally required. ++@return 0 if success, != 0 if was reserved by another thread */ ++UNIV_INLINE ++ulint ++os_fast_mutex_trylock_full_barrier( ++/*==================*/ ++ os_fast_mutex_t* fast_mutex); /*!< in: mutex to acquire */ ++/**********************************************************//** ++ + Releases ownership of a fast mutex. */ + UNIV_INTERN + void + os_fast_mutex_unlock_func( + /*======================*/ + fast_mutex_t* fast_mutex); /*!< in: mutex to release */ ++ ++/**********************************************************//** ++Releases ownership of a fast mutex. Implies a full memory barrier even on ++platforms such as PowerPC where this is not normally required. */ ++UNIV_INTERN ++void ++os_fast_mutex_unlock_full_barrier( ++/*=================*/ ++ os_fast_mutex_t* fast_mutex); /*!< in: mutex to release */ ++ + /*********************************************************//** + Initializes an operating system fast mutex semaphore. */ + UNIV_INTERN +@@ -500,7 +520,7 @@ amount to decrement. */ + # define os_atomic_decrement_uint64(ptr, amount) \ + os_atomic_decrement(ptr, amount) + +-# if defined(IB_STRONG_MEMORY_MODEL) ++# if defined(HAVE_ATOMIC_BUILTINS) + + /** Do an atomic test and set. + @param[in,out] ptr Memory location to set to non-zero +@@ -514,19 +534,13 @@ os_atomic_test_and_set(volatile lock_wor + + /** Do an atomic release. + +-In theory __sync_lock_release should be used to release the lock. +-Unfortunately, it does not work properly alone. The workaround is +-that more conservative __sync_lock_test_and_set is used instead. +- +-Performance regression was observed at some conditions for Intel +-architecture. Disable release barrier on Intel architecture for now. + @param[in,out] ptr Memory location to write to + @return the previous value */ + inline +-lock_word_t ++void + os_atomic_clear(volatile lock_word_t* ptr) + { +- return(__sync_lock_test_and_set(ptr, 0)); ++ __sync_lock_release(ptr); + } + + # elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) +@@ -556,6 +570,29 @@ os_atomic_clear(volatile lock_word_t* pt + + # endif /* HAVE_IB_GCC_ATOMIC_TEST_AND_SET */ + ++#if defined(__powerpc__) || defined(__aarch64__) ++/* ++ os_atomic_test_and_set_byte_release() should imply a release barrier before ++ setting, and a full barrier after. But __sync_lock_test_and_set() is only ++ documented as an aquire barrier. So on PowerPC we need to add the full ++ barrier explicitly. */ ++# define os_atomic_test_and_set_byte_release(ptr, new_val) \ ++ do { __sync_lock_release(ptr); \ ++ __sync_synchronize(); } while (0) ++#else ++/* ++ On x86, __sync_lock_test_and_set() happens to be full barrier, due to ++ LOCK prefix. ++*/ ++# define os_atomic_test_and_set_byte_release(ptr, new_val) \ ++ __sync_lock_test_and_set(ptr, (byte) new_val) ++#endif ++/* ++ os_atomic_test_and_set_byte_acquire() is a full memory barrier on x86. But ++ in general, just an aquire barrier should be sufficient. */ ++# define os_atomic_test_and_set_byte_acquire(ptr, new_val) \ ++ __sync_lock_test_and_set(ptr, (byte) new_val) ++ + #elif defined(HAVE_IB_SOLARIS_ATOMICS) + + # define HAVE_ATOMIC_BUILTINS +@@ -810,6 +847,9 @@ os_atomic_clear(volatile lock_word_t* pt + return(InterlockedExchange(ptr, 0)); + } + ++# define os_atomic_lock_release_byte(ptr) \ ++ (void) InterlockedExchange(ptr, 0) ++ + #else + # define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use InnoDB's own implementation" +@@ -863,12 +903,14 @@ for synchronization */ + architecture. Disable memory barrier for Intel architecture for now. */ + # define os_rmb + # define os_wmb ++# define os_mb + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "Memory barrier is not used" + #elif defined(HAVE_IB_GCC_ATOMIC_THREAD_FENCE) + # define HAVE_MEMORY_BARRIER + # define os_rmb __atomic_thread_fence(__ATOMIC_ACQUIRE) + # define os_wmb __atomic_thread_fence(__ATOMIC_RELEASE) ++# define os_mb __atomic_thread_fence(__ATOMIC_SEQ_CST) + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "GCC builtin __atomic_thread_fence() is used for memory barrier" + +@@ -876,6 +918,7 @@ architecture. Disable memory barrier for + # define HAVE_MEMORY_BARRIER + # define os_rmb __sync_synchronize() + # define os_wmb __sync_synchronize() ++# define os_mb __sync_synchronize() + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "GCC builtin __sync_synchronize() is used for memory barrier" + +@@ -884,6 +927,7 @@ architecture. Disable memory barrier for + # include + # define os_rmb __machine_r_barrier() + # define os_wmb __machine_w_barrier() ++# define os_mb __machine_rw_barrier() + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "Solaris memory ordering functions are used for memory barrier" + +@@ -892,12 +936,14 @@ architecture. Disable memory barrier for + # include + # define os_rmb _mm_lfence() + # define os_wmb _mm_sfence() ++# define os_mb _mm_mfence() + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "_mm_lfence() and _mm_sfence() are used for memory barrier" + + #else + # define os_rmb + # define os_wmb ++# define os_mb do { } while(0) + # define IB_MEMORY_BARRIER_STARTUP_MSG \ + "Memory barrier is not used" + #endif +--- percona-xtradb-cluster-5.6-5.6.34-26.19.orig/storage/innobase/include/os0sync.ic ++++ percona-xtradb-cluster-5.6-5.6.34-26.19/storage/innobase/include/os0sync.ic +@@ -232,3 +232,34 @@ win_cmp_and_xchg_dword( + + #endif /* HAVE_WINDOWS_ATOMICS */ + ++/**********************************************************//** ++Acquires ownership of a fast mutex. Implies a full memory barrier even on ++platforms such as PowerPC where this is not normally required. ++@return 0 if success, != 0 if was reserved by another thread */ ++UNIV_INLINE ++ulint ++os_fast_mutex_trylock_full_barrier( ++/*==================*/ ++ os_fast_mutex_t* fast_mutex) /*!< in: mutex to acquire */ ++{ ++#ifdef __WIN__ ++ if (TryEnterCriticalSection(&fast_mutex->mutex)) { ++ ++ return(0); ++ } else { ++ ++ return(1); ++ } ++#else ++ /* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock ++ so that it returns 0 on success. In the operating system ++ libraries, HP-UX-10.20 follows the old Posix 1003.4a Draft 4 and ++ returns 1 on success (but MySQL remaps that to 0), while Linux, ++ FreeBSD, Solaris, AIX, Tru64 Unix, HP-UX-11.0 return 0 on success. */ ++ ++#ifdef __powerpc__ ++ os_mb; ++#endif ++ return((ulint) pthread_mutex_trylock(&fast_mutex->mutex)); ++#endif ++} +--- percona-xtradb-cluster-5.6-5.6.34-26.19.orig/storage/innobase/include/sync0sync.ic ++++ percona-xtradb-cluster-5.6-5.6.34-26.19/storage/innobase/include/sync0sync.ic +@@ -83,19 +83,17 @@ ib_mutex_test_and_set( + ib_mutex_t* mutex) /*!< in: mutex */ + { + #if defined(HAVE_ATOMIC_BUILTINS) +- return(os_atomic_test_and_set(&mutex->lock_word)); ++ return(os_atomic_test_and_set_byte_acquire(&mutex->lock_word, 1)); + #else + ibool ret; + +- ret = os_fast_mutex_trylock(&(mutex->os_fast_mutex)); ++ ret = os_fast_mutex_trylock_full_barrier(&(mutex->os_fast_mutex)); + + if (ret == 0) { + /* We check that os_fast_mutex_trylock does not leak + and allow race conditions */ + ut_a(mutex->lock_word == 0); +- + mutex->lock_word = 1; +- os_wmb; + } + + return((byte) ret); +@@ -112,11 +110,11 @@ mutex_reset_lock_word( + ib_mutex_t* mutex) /*!< in: mutex */ + { + #if defined(HAVE_ATOMIC_BUILTINS) +- os_atomic_clear(&mutex->lock_word); ++ os_atomic_test_and_set_byte_release(&mutex->lock_word, 0); + #else + mutex->lock_word = 0; + +- os_fast_mutex_unlock(&(mutex->os_fast_mutex)); ++ os_fast_mutex_unlock_full_barrier(&(mutex->os_fast_mutex)); + #endif /* HAVE_ATOMIC_BUILTINS */ + } + +@@ -182,6 +180,10 @@ mutex_exit_func( + to wake up possible hanging threads if + they are missed in mutex_signal_object. */ + ++ /* We add a memory barrier to prevent reading of the ++ number of waiters before releasing the lock. */ ++ os_mb; ++ + if (mutex_get_waiters(mutex) != 0) { + + mutex_signal_object(mutex); +--- percona-xtradb-cluster-5.6-5.6.34-26.19.orig/storage/innobase/os/os0sync.cc ++++ percona-xtradb-cluster-5.6-5.6.34-26.19/storage/innobase/os/os0sync.cc +@@ -724,6 +724,26 @@ os_fast_mutex_unlock_func( + } + + /**********************************************************//** ++Releases ownership of a fast mutex. Implies a full memory barrier even on ++platforms such as PowerPC where this is not normally required. */ ++UNIV_INTERN ++void ++os_fast_mutex_unlock_full_barrier( ++/*=================*/ ++ os_fast_mutex_t* fast_mutex) /*!< in: mutex to release */ ++{ ++#ifdef __WIN__ ++ LeaveCriticalSection(&fast_mutex->mutex); ++#else ++ pthread_mutex_unlock(&fast_mutex->mutex); ++#ifdef __powerpc__ ++ os_mb; ++#endif ++#endif ++} ++ ++ ++/**********************************************************//** + Frees a mutex object. */ + UNIV_INTERN + void +--- percona-xtradb-cluster-5.6-5.6.34-26.19.orig/storage/innobase/sync/sync0sync.cc ++++ percona-xtradb-cluster-5.6-5.6.34-26.19/storage/innobase/sync/sync0sync.cc +@@ -30,6 +30,7 @@ Mutex, the basic synchronization primiti + Created 9/5/1995 Heikki Tuuri + *******************************************************/ + ++#include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ + #include "sync0sync.h" + #ifdef UNIV_NONINL + #include "sync0sync.ic" +@@ -41,7 +42,6 @@ Created 9/5/1995 Heikki Tuuri + #include "srv0srv.h" + #include "btr0types.h" + #include "buf0types.h" +-#include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ + #ifdef UNIV_SYNC_DEBUG + # include "srv0start.h" /* srv_is_being_started */ + #endif /* UNIV_SYNC_DEBUG */ +@@ -526,7 +526,6 @@ mutex_set_waiters( + + *ptr = n; /* Here we assume that the write of a single + word in memory is atomic */ +- os_wmb; + } + + /******************************************************************//** +@@ -636,6 +635,10 @@ spin_loop: + mutex_set_waiters(mutex, 1); + } + ++/* Make sure waiters store won't pass over mutex_test_and_set */ ++#if defined(__powerpc__) ++ os_mb; ++#endif + /* Try to reserve still a few times */ + for (i = 0; i < 4; i++) { + if (ib_mutex_test_and_set(mutex) == 0) { diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/series percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/series --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/series 2017-03-03 06:41:02.000000000 -0300 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/series 2017-09-11 13:04:21.000000000 -0300 @@ -1,3 +1,3 @@ scripts__mysqld_safe.sh__signals.patch fix_tc_log_initialization_on_ppc64.patch -weak-memory-compat.patch +ibuf-mutex-use-full-memory-barrier-powerpc.patch diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/weak-memory-compat.patch percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/weak-memory-compat.patch --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/weak-memory-compat.patch 2017-03-03 06:41:02.000000000 -0300 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/patches/weak-memory-compat.patch 1969-12-31 21:00:00.000000000 -0300 @@ -1,23 +0,0 @@ -From f31a89191f6b1679d9f8b584aa95fe006182ee7d Mon Sep 17 00:00:00 2001 -From: Sergey Vojtovich -Date: Wed, 18 Nov 2015 15:51:20 +0400 -Subject: [PATCH] MDEV-9128 - Compiling on IBM System Z fails - -Provided IBM System Z have outdated compiler version, which supports gcc sync -builtins but not gcc atomic builtins. It also has weak memory model. - -InnoDB attempted to verify if __sync_lock_test_and_set() is available by -checking IB_STRONG_MEMORY_MODEL. This macro has nothing to do with availability -of __sync_lock_test_and_set(), the right one is HAVE_ATOMIC_BUILTINS. - ---- a/storage/innobase/include/os0sync.h -+++ b/storage/innobase/include/os0sync.h -@@ -500,7 +500,7 @@ amount to decrement. */ - # define os_atomic_decrement_uint64(ptr, amount) \ - os_atomic_decrement(ptr, amount) - --# if defined(IB_STRONG_MEMORY_MODEL) -+# if defined(HAVE_ATOMIC_BUILTINS) - - /** Do an atomic test and set. - @param[in,out] ptr Memory location to set to non-zero diff -Nru percona-xtradb-cluster-5.6-5.6.34-26.19/debian/rules percona-xtradb-cluster-5.6-5.6.34-26.19/debian/rules --- percona-xtradb-cluster-5.6-5.6.34-26.19/debian/rules 2017-03-03 06:41:02.000000000 -0300 +++ percona-xtradb-cluster-5.6-5.6.34-26.19/debian/rules 2017-09-11 12:57:54.000000000 -0300 @@ -2,6 +2,7 @@ export DH_VERBOSE=1 export DEB_BUILD_HARDENING=1 +export USE_THIS_GCC_VERSION=-6 include DEB-VERSION @@ -68,10 +69,10 @@ ifeq ($(SKIP_DEBUG_BINARY),) ( test -d $(builddebug) || mkdir $(builddebug) ) && cd $(builddebug) && \ sh -c 'PATH=$${MYSQL_BUILD_PATH:-"/bin:/usr/bin"} \ - CC=$${MYSQL_BUILD_CC:-gcc} \ - CFLAGS=$${MYSQL_BUILD_CFLAGS:-"-O3 -g -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare -Wno-error=unused-result"} \ - CXX=$${MYSQL_BUILD_CXX:-g++} \ - CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O3 -g -felide-constructors -fno-rtti -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare -Wno-error=unused-result"} \ + CC=$${MYSQL_BUILD_CC:-gcc-6} \ + CFLAGS=$${MYSQL_BUILD_CFLAGS:-"-O3 -g -fno-strict-aliasing -w -Wno-deprecated-declarations -Wno-error=nonnull-compare -Wno-error=unused-result"} \ + CXX=$${MYSQL_BUILD_CXX:-g++-6} \ + CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O3 -g -felide-constructors -fno-rtti -fno-strict-aliasing -w -Wno-deprecated-declarations -Wno-error=nonnull-compare -Wno-error=unused-result"} \ cmake -DCMAKE_INSTALL_PREFIX=/usr \ \ -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \ @@ -104,10 +105,10 @@ ( test -d $(builddir) || mkdir $(builddir) ) && cd $(builddir) && \ sh -c 'PATH=$${MYSQL_BUILD_PATH:-"/bin:/usr/bin"} \ - CC=$${MYSQL_BUILD_CC:-gcc} \ - CFLAGS=$${MYSQL_BUILD_CFLAGS:-"-O3 -g -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare"} \ - CXX=$${MYSQL_BUILD_CXX:-g++} \ - CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O3 -g -felide-constructors -fno-rtti -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare"} \ + CC=$${MYSQL_BUILD_CC:-gcc-6} \ + CFLAGS=$${MYSQL_BUILD_CFLAGS:-"-O3 -g -w -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare"} \ + CXX=$${MYSQL_BUILD_CXX:-g++-6} \ + CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O3 -g -w -felide-constructors -fno-rtti -fno-strict-aliasing -Wno-deprecated-declarations -Wno-error=nonnull-compare"} \ cmake -DCMAKE_INSTALL_PREFIX=/usr \ \ -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \