ce426f
commit 49186d21ef2d87986bccaf0a7c45c48c91b265f3
ce426f
Author: Andi Kleen <ak@linux.intel.com>
ce426f
Date:   Thu Jun 27 11:15:06 2013 -0700
ce426f
ce426f
    Disable elision for any pthread_mutexattr_settype call
ce426f
    
ce426f
    PTHREAD_MUTEX_NORMAL requires deadlock for nesting, DEFAULT
ce426f
    does not. Since glibc uses the same value (0) disable elision
ce426f
    for any call to pthread_mutexattr_settype() with a 0 value.
ce426f
    This implies that a program can disable elision by doing
ce426f
    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL)
ce426f
    
ce426f
    Based on a original proposal by Rich Felker.
ce426f
Index: glibc-2.17-c758a686/nptl/pthread_mutexattr_settype.c
ce426f
===================================================================
ce426f
--- glibc-2.17-c758a686.orig/nptl/pthread_mutexattr_settype.c
ce426f
+++ glibc-2.17-c758a686/nptl/pthread_mutexattr_settype.c
ce426f
@@ -30,6 +30,11 @@ __pthread_mutexattr_settype (attr, kind)
ce426f
   if (kind < PTHREAD_MUTEX_NORMAL || kind > PTHREAD_MUTEX_ADAPTIVE_NP)
ce426f
     return EINVAL;
ce426f
 
ce426f
+  /* Cannot distinguish between DEFAULT and NORMAL. So any settype
ce426f
+     call disables elision for now.  */
ce426f
+  if (kind == PTHREAD_MUTEX_DEFAULT)
ce426f
+    kind |= PTHREAD_MUTEX_NO_ELISION_NP;
ce426f
+
ce426f
   iattr = (struct pthread_mutexattr *) attr;
ce426f
 
ce426f
   iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;