Commit graph

34 commits

Author SHA1 Message Date
Davi Arnaut
86ec0f98b8 Bug#56760: my_atomics failures on osx10.5-x86-64bit
The problem was due to a misuse of GCC asm constraints used to
implement a atomic load. On x86_64, the load was implemented
as a cmpxchg which implicitly uses the eax register as a
source and destination operand, yet the dummy value used for
comparison wasn't being properly loaded into eax (and other
problems).

The core problem is that cmpxchg is unnecessary as a load
on x86_64 as there are other simpler instructions such
as xadd. Even though, such instructions are only used to
have a memory barrier as load and stores are atomic by
definition. Hence, the solution is to explicitly issue the
required CPU and compiler barriers.
2010-11-30 21:19:49 -02:00
Davi Arnaut
be348787eb Bug#52419: x86 assembly based atomic CAS causes test failures
The problem was that the x86 assembly based atomic CAS
(compare and swap) implementation could copy the wrong
value to the ebx register, where the cmpxchg8b expects
to see part of the "comparand" value. Since the original
value in the ebx register is saved in the stack (that is,
the push instruction causes the stack pointer to change),
a wrong offset could be used if the compiler decides to
put the source of the comparand value in the stack.

The solution is to copy the comparand value directly from
memory. Since the comparand value is 64-bits wide, it is
copied in two steps over to the ebx and ecx registers.
2010-09-17 17:34:15 -03:00
Davi Arnaut
c6a34a9961 Bug#52261: 64 bit atomic operations do not work on Solaris i386 ..
Workaround a interface problem with the atomic macros that was
causing warnings. The correct type is retrieved using typeof if
compiling with GCC.
2010-07-27 10:25:11 -03:00
Davi Arnaut
3a22d332c7 Bug#22320: my_atomic-t unit test fails
Bug#52261: 64 bit atomic operations do not work on Solaris i386
           gcc in debug compilation

One of the various problems was that the source operand to
CMPXCHG8b was marked as a input/output operand, causing GCC
to use the EBX register as the destination register for the
CMPXCHG8b instruction. This could lead to crashes as the EBX
register is also implicitly used by the instruction, causing
the value to be potentially garbaged and a protection fault
once the value is used to access a position in memory.

Another problem was the lack of proper clobbers for the atomic
operations and, also, a discrepancy between the implementations
for the Compare and Set operation. The specific problems are
described and fixed by Kristian Nielsen patches:

Patch: 1

Fix bugs in my_atomic_cas*(val,cmp,new) that *cmp is accessed
after CAS succeds.

In the gcc builtin implementation, problem was that *cmp was
read again after atomic CAS to check if old *val == *cmp;
this fails if CAS is successful and another thread modifies
*cmp in-between.

In the x86-gcc implementation, problem was that *cmp was set
also in the case of successful CAS; this means there is a
window where it can clobber a value written by another thread
after successful CAS.

Patch 2:

Add a GCC asm "memory" clobber to primitives that imply a
memory barrier.

This signifies to GCC that any potentially aliased memory
must be flushed before the operation, and re-read after the
operation, so that read or modification in other threads of
such memory values will work as intended.

In effect, it makes these primitives work as memory barriers
for the compiler as well as the CPU. This is better and more
correct than adding "volatile" to variables.
2010-07-23 09:37:10 -03:00
Konstantin Osipov
1e6b33ec0f Fix compiler warnings in my_atomic.h 2010-02-19 17:20:29 +03:00
Sergei Golubchik
50f9dc6a1d merged 2009-12-24 21:18:53 +01:00
Sergei Golubchik
18d082109c fix atomic/solaris.h to conform
remove duplicated boilerplate code
2009-12-23 09:27:41 +01:00
Mikael Ronstrom
1d60eece25 Force use of c-register in CAS instruction on x86-32 bit architecture, b-register used for push and pop, so don't want to give compile the chance to choose the wrong register 2009-12-21 14:08:11 +01:00
Mikael Ronstrom
2e72189535 Increase probability of correct atomics implementation by choosing stable implementations first 2009-12-19 08:54:05 +01:00
Mikael Ronstrom
30390a5e95 Make choices of atomic implementation based on highest stability 2009-12-19 08:46:37 +01:00
Mikael Ronstrom
39ca1f0e1d Fixed Solaris Atomics build issues 2009-12-18 11:15:21 +01:00
Mikael Ronstrom
1ee5790589 Added extra checks of 64-bit atomic support on GCC and Solaris, also added 64-bit support in solaris.h which was missing 2009-12-18 09:29:18 +01:00
Mikael Ronstrom
4bd3686f96 Fix for Windows atomics 2009-12-16 00:33:15 +01:00
Mikael Ronstrom
432c5487e9 Fixed complex gcc assembler issues with 64-bit operations on 32-bit platforms using PIC codes, commented x86-gcc.h a lot more 2009-12-15 22:15:48 +01:00
Mikael Ronstrom
f5a547a971 Include windows.h in atomics framework for windows 2009-12-15 18:12:49 +01:00
Mikael Ronstrom
fe1287ea68 Fixed 64-bit atomics on Win x86 and removed support for 8 and 16-bit atomic operations 2009-12-15 17:07:43 +01:00
Mikael Ronstrom
f06d24c18e Fixed atomic instruction headers for Windows and x86-gcc 2009-12-15 15:40:08 +01:00
Mikael Ronstrom
0c91c582eb Merge WL#5138 to mysql-next-mr 2009-11-27 18:11:05 +01:00
Mikael Ronstrom
a849487229 WL#5138 merged to mysql-next-mr 2009-11-20 16:23:32 +01:00
Marc Alff
b16be935d4 Misc cleanup 2009-11-17 17:36:39 -07:00
Marc Alff
1e46d6a032 WL#2595 kernel-independent atomic operations
Backport from 6.0.14 to 5.6.0

Original code from Sergei Golubchik
2009-11-17 17:11:32 -07:00
Luis Soares
58e2fde011 manual merge: mysql-5.1-rep+2-delivery1 --> mysql-5.1-rpl-merge
Conflicts
=========

Text conflict in .bzr-mysql/default.conf
Text conflict in libmysqld/CMakeLists.txt
Text conflict in libmysqld/Makefile.am
Text conflict in mysql-test/collections/default.experimental
Text conflict in mysql-test/extra/rpl_tests/rpl_row_sp006.test
Text conflict in mysql-test/suite/binlog/r/binlog_tmp_table.result
Text conflict in mysql-test/suite/rpl/r/rpl_loaddata.result
Text conflict in mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
Text conflict in mysql-test/suite/rpl/r/rpl_row_create_table.result
Text conflict in mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result
Text conflict in mysql-test/suite/rpl/r/rpl_stm_log.result
Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result
Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_sp006.result
Text conflict in mysql-test/t/mysqlbinlog.test
Text conflict in sql/CMakeLists.txt
Text conflict in sql/Makefile.am
Text conflict in sql/log_event_old.cc
Text conflict in sql/rpl_rli.cc
Text conflict in sql/slave.cc
Text conflict in sql/sql_binlog.cc
Text conflict in sql/sql_lex.h
21 conflicts encountered.

NOTE
====
 mysql-5.1-rpl-merge has been made a mirror of mysql-next-mr:
 - "mysql-5.1-rpl-merge$ bzr pull ../mysql-next-mr"

 This is the first cset (merge/...) committed after pulling 
 from mysql-next-mr.
2009-10-22 23:30:28 +01:00
Mikael Ronstrom
c4ce446f19 Backported my_atomic from 6.0-codebase and added support for 64-bit atomics to enable removal of LOCK_thread_count from every query, removed LOCK_thread_count from use in dispatch_command and close of query which is used in every query, now uses atomic increments/decrements instead 2009-10-12 11:00:39 +02:00
Mikael Ronstrom
6e4f01fa8b Moved atomics from 6.0 codebase to prepare for using atomic increments in places where LOCK_thread_count previously was used 2009-10-09 14:21:29 +02:00
Mats Kindahl
4ad8ef0602 WL#5016: Fix header file include guards
Adding header include file guards to files that are missing such.
2009-09-23 23:32:31 +02:00
Mikael Ronstrom
4557f4ee9e Fix for BUG#45131 2009-06-10 12:23:02 +02:00
Mikael Ronstrom
5d6e44f886 Added new file solaris.h 2008-10-16 21:12:16 +02:00
Mikael Ronstrom
c45bd8ce96 Performance patch: Mysql atomic patch 2008-10-13 22:03:12 +02:00
davi@mysql.com/endora.local
e88edf6ab1 Bug#33728 Atomic builtins
Use compiler provided atomic builtins as a 'backend' for
MySQL's atomic primitives. The builtins are available on
a handful of platforms and compilers.
2008-01-11 20:34:36 -02:00
kent@mysql.com/kent-amd64.(none)
1e3237fefa Many files:
Changed header to GPL version 2 only
2006-12-27 02:23:51 +01:00
serg@serg.mylan
5e2777b445 support for xadd emulation, workaround for Darwin 2006-06-29 15:39:53 +02:00
serg@serg.mylan
48c453a40b atomic ops:
my_atomic_XX_t -> intXX, no implicit locking anymore
    simplified framework, support for requested cleanups
2006-06-17 16:20:39 +02:00
serg@serg.mylan
5409997d49 unittest:
rename *.t* to *-t* to be automake-friendly
  simplify Makefiles
test_atomic.c:
  move to unittest, add GPL comment, fix warnings, convert to tap framework.
configure:
  remove custom tests for available types, use AC_CHECK_TYPE instead
x86-gcc.h:
  fix gcc -ansi errors while maintaining readability
ignore:
  added *-t
2006-06-01 12:25:47 +02:00
serg@serg.mylan
efdf221d49 WL#2595 - atomic operations 2006-05-31 18:44:09 +02:00