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