From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>,
Steve Munroe <sjmunroe@us.ibm.com>, Ryan Arnold <rsa@us.ibm.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Use rel semantics of cas instead of acq semantics with full barrier before it in _int_free
Date: Mon, 13 Jul 2009 16:11:00 -0000 [thread overview]
Message-ID: <20090713161031.GF3101@sunsite.ms.mff.cuni.cz> (raw)
Hi!
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.
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.
--- libc/include/atomic.h.jj 2009-05-16 19:23:35.000000000 +0200
+++ libc/include/atomic.h 2009-07-13 17:47:02.000000000 +0200
@@ -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
--- libc/malloc/malloc.c.jj 2009-07-07 19:10:19.000000000 +0200
+++ libc/malloc/malloc.c 2009-07-13 17:47:52.000000000 +0200
@@ -4822,9 +4822,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). */
Jakub
next reply other threads:[~2009-07-13 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-13 16:11 Jakub Jelinek [this message]
2009-07-14 14:44 ` Steve Munroe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090713161031.GF3101@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=rsa@us.ibm.com \
--cc=sjmunroe@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).