mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
BUG#21102971 data corruption on arm64
The root cause is that x86 has a stronger memory model than the ARM processors. And the GCC builtins didn't issue the correct fences when setting/unsetting the lock word. In particular during the mutex release. The solution is rewriting atomic TAS operations: replace '__sync_' by '__atomic_' if possible. Reviewed-by: Sunny Bains <sunny.bains@oracle.com> Reviewed-by: Bin Su <bin.x.su@oracle.com> Reviewed-by: Debarun Banerjee <debarun.banerjee@oracle.com> Reviewed-by: Krunal Bauskar <krunal.bauskar@oracle.com> RB: 9782 RB: 9665 RB: 9783
This commit is contained in:
parent
552b1c8ab6
commit
f59d68eeae
4 changed files with 131 additions and 33 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
||||
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2008, Google Inc.
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
|
|
@ -80,7 +80,7 @@ mutex_test_and_set(
|
|||
mutex_t* mutex) /*!< in: mutex */
|
||||
{
|
||||
#if defined(HAVE_ATOMIC_BUILTINS)
|
||||
return(os_atomic_test_and_set_byte(&mutex->lock_word, 1));
|
||||
return(os_atomic_test_and_set(&mutex->lock_word));
|
||||
#else
|
||||
ibool ret;
|
||||
|
||||
|
|
@ -108,10 +108,7 @@ mutex_reset_lock_word(
|
|||
mutex_t* mutex) /*!< in: mutex */
|
||||
{
|
||||
#if defined(HAVE_ATOMIC_BUILTINS)
|
||||
/* 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. */
|
||||
os_atomic_test_and_set_byte(&mutex->lock_word, 0);
|
||||
os_atomic_clear(&mutex->lock_word);
|
||||
#else
|
||||
mutex->lock_word = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue