about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-07-16 07:24:50 -0700
committerPetr Baudis <pasky@suse.cz>2009-07-16 20:35:37 +0200
commite875bad50a2247e6297c1b2306d87b3eb623a0be (patch)
tree903735fafe9037f8fd7f94b3a95b87224be29809
parenta5cceee5d55a69d82322b6ee0d17176a14b3b6bb (diff)
downloadglibc-e875bad50a2247e6297c1b2306d87b3eb623a0be.tar.gz
glibc-e875bad50a2247e6297c1b2306d87b3eb623a0be.tar.xz
glibc-e875bad50a2247e6297c1b2306d87b3eb623a0be.zip
Use rel semantics of cas instead of acq semantics with full barrier before it in _int_free
The following patch fixes catomic_compare_and_exchange_*_rel definitions
(which were never used and weren't correct) and uses
catomic_compare_and_exchange_val_rel in _int_free.  Comparing to the
pre-2009-07-02 --enable-experimental-malloc state the generated code should
be identical on all arches other than ppc/ppc64 and on ppc/ppc64 should use
lwsync instead of isync barrier.

(cherry picked from commit bea0ac1d8703091294fe5822d982591c849b5458)
-rw-r--r--ChangeLog13
-rw-r--r--include/atomic.h32
-rw-r--r--malloc/malloc.c3
3 files changed, 35 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 064475eeb6..8a0e7ab6d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-07-13  Jakub Jelinek  <jakub@redhat.com>
+
+	* include/atomic.h (catomic_compare_and_exchange_val_rel): If arch
+	overrides atomic_compare_and_exchange_val_rel, define to
+	atomic_compare_and_exchange_val_rel by default, otherwise default
+	to catomic_compare_and_exchange_val_acq.
+	(catomic_compare_and_exchange_bool_rel): If arch overrides
+	atomic_compare_and_exchange_bool_rel, define to
+	atomic_compare_and_exchange_bool_rel by default.
+	* malloc/malloc.c (_int_free): Revert 2009-07-02 change.
+	Use catomic_compare_and_exchange_val_rel instead of
+	catomic_compare_and_exchange_val_acq.
+
 2009-07-07  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* elf/Makefile: Don't build modules for tst-audit3 for anything
diff --git a/include/atomic.h b/include/atomic.h
index 9366f78734..37d0111d5f 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -107,14 +107,19 @@
 #endif
 
 
-#ifndef atomic_compare_and_exchange_val_rel
-# define atomic_compare_and_exchange_val_rel(mem, newval, oldval)	      \
-  atomic_compare_and_exchange_val_acq (mem, newval, oldval)
+#ifndef catomic_compare_and_exchange_val_rel
+# ifndef atomic_compare_and_exchange_val_rel
+#  define catomic_compare_and_exchange_val_rel(mem, newval, oldval)	      \
+  catomic_compare_and_exchange_val_acq (mem, newval, oldval)
+# else
+#  define catomic_compare_and_exchange_val_rel(mem, newval, oldval)	      \
+  atomic_compare_and_exchange_val_rel (mem, newval, oldval)
+# endif
 #endif
 
 
-#ifndef catomic_compare_and_exchange_val_rel
-# define catomic_compare_and_exchange_val_rel(mem, newval, oldval)	      \
+#ifndef atomic_compare_and_exchange_val_rel
+# define atomic_compare_and_exchange_val_rel(mem, newval, oldval)	      \
   atomic_compare_and_exchange_val_acq (mem, newval, oldval)
 #endif
 
@@ -155,15 +160,20 @@
 #endif
 
 
-#ifndef atomic_compare_and_exchange_bool_rel
-# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
-  atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
+#ifndef catomic_compare_and_exchange_bool_rel
+# ifndef atomic_compare_and_exchange_bool_rel
+#  define catomic_compare_and_exchange_bool_rel(mem, newval, oldval)	      \
+  catomic_compare_and_exchange_bool_acq (mem, newval, oldval)
+# else
+#  define catomic_compare_and_exchange_bool_rel(mem, newval, oldval)	      \
+  atomic_compare_and_exchange_bool_rel (mem, newval, oldval)
+# endif
 #endif
 
 
-#ifndef catomic_compare_and_exchange_bool_rel
-# define catomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
-  catomic_compare_and_exchange_bool_acq (mem, newval, oldval)
+#ifndef atomic_compare_and_exchange_bool_rel
+# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
+  atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
 #endif
 
 
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 703dcb56e7..bd44dee7f4 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4802,9 +4802,8 @@ _int_free(mstate av, mchunkptr p)
 	    goto errout;
 	  }
 	p->fd = fd = old;
-	atomic_full_barrier ();
       }
-    while ((old = catomic_compare_and_exchange_val_acq (fb, p, fd)) != fd);
+    while ((old = catomic_compare_and_exchange_val_rel (fb, p, fd)) != fd);
 #else
     /* Another simple check: make sure the top of the bin is not the
        record we are going to add (i.e., double free).  */