aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2013-06-27 11:15:06 -0700
committerAndi Kleen <ak@linux.intel.com>2013-07-02 08:46:55 -0700
commit49186d21ef2d87986bccaf0a7c45c48c91b265f3 (patch)
tree3b30a707c3a8e969e84d7e9ee954153d39299565 /nptl
parente8c659d74e011346785355eeef03b7fb6f533c61 (diff)
downloadglibc-49186d21ef2d87986bccaf0a7c45c48c91b265f3.tar
glibc-49186d21ef2d87986bccaf0a7c45c48c91b265f3.tar.gz
glibc-49186d21ef2d87986bccaf0a7c45c48c91b265f3.tar.bz2
glibc-49186d21ef2d87986bccaf0a7c45c48c91b265f3.zip
Disable elision for any pthread_mutexattr_settype call
PTHREAD_MUTEX_NORMAL requires deadlock for nesting, DEFAULT does not. Since glibc uses the same value (0) disable elision for any call to pthread_mutexattr_settype() with a 0 value. This implies that a program can disable elision by doing pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL) Based on a original proposal by Rich Felker.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog5
-rw-r--r--nptl/pthread_mutexattr_settype.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 7f82b2098a..d32046ee65 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,4 +1,9 @@
2013-07-02 Andi Kleen <ak@linux.intel.com>
+
+ * pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
+ Disable elision for PTHREAD_MUTEX_DEFAULT.
+
+2013-07-02 Andi Kleen <ak@linux.intel.com>
Hongjiu Lu <hongjiu.lu@intel.com>
* pthread_mutex_lock.c
diff --git a/nptl/pthread_mutexattr_settype.c b/nptl/pthread_mutexattr_settype.c
index 7b476e95bc..a85cdcb389 100644
--- a/nptl/pthread_mutexattr_settype.c
+++ b/nptl/pthread_mutexattr_settype.c
@@ -30,6 +30,11 @@ __pthread_mutexattr_settype (attr, kind)
if (kind < PTHREAD_MUTEX_NORMAL || kind > PTHREAD_MUTEX_ADAPTIVE_NP)
return EINVAL;
+ /* Cannot distinguish between DEFAULT and NORMAL. So any settype
+ call disables elision for now. */
+ if (kind == PTHREAD_MUTEX_DEFAULT)
+ kind |= PTHREAD_MUTEX_NO_ELISION_NP;
+
iattr = (struct pthread_mutexattr *) attr;
iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;