]> sourceware.org Git - glibc.git/commitdiff
Disable elision for any pthread_mutexattr_settype call
authorAndi Kleen <ak@linux.intel.com>
Thu, 27 Jun 2013 18:15:06 +0000 (11:15 -0700)
committerAndi Kleen <ak@linux.intel.com>
Tue, 2 Jul 2013 15:46:55 +0000 (08:46 -0700)
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.

nptl/ChangeLog
nptl/pthread_mutexattr_settype.c

index 7f82b2098a0b3532577647739e89baae2b56c0b5..d32046ee6523d516247d9435c431ba8b4b5d071d 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
index 7b476e95bc1a7c16daf8b7533ecdd794611e586b..a85cdcb3892b68fa358c78440afb5d9dcdb587d1 100644 (file)
@@ -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;
This page took 0.052248 seconds and 5 git commands to generate.