This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 06/11] Only allow to enable/disable elision for a mutex when the CPU supports it


From: Andi Kleen <ak@linux.intel.com>

This allows to leave out some extra checks for elision available
in the fast paths.

nptl/:
2013-06-24  Andi Kleen  <ak@linux.intel.com>

	* pthread_mutexattr_settype.c (pthread_mutexattr_settype_worker):
	  Add check for elision available.
	  (ENABLE_ELISION): Define to zero if not set.
	* nptl/sysdeps/unix/sysv/linux/x86/pthread_mutexattr_settype.c:
	  New file to add a ENABLE_ELISION for x86 for pthread_mutexattr_settype.
---
 nptl/pthread_mutexattr_settype.c                   |  9 +++++++++
 .../sysv/linux/x86/pthread_mutexattr_settype.c     | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 nptl/sysdeps/unix/sysv/linux/x86/pthread_mutexattr_settype.c

diff --git a/nptl/pthread_mutexattr_settype.c b/nptl/pthread_mutexattr_settype.c
index 8897653..ae1be45 100644
--- a/nptl/pthread_mutexattr_settype.c
+++ b/nptl/pthread_mutexattr_settype.c
@@ -20,6 +20,10 @@
 #include <pthreadP.h>
 #include <shlib-compat.h>
 
+#ifndef ENABLE_ELISION
+#define ENABLE_ELISION 0
+#endif
+
 static int
 pthread_mutexattr_settype_worker (pthread_mutexattr_t *attr, int kind)
 {
@@ -43,6 +47,11 @@ pthread_mutexattr_settype_worker (pthread_mutexattr_t *attr, int kind)
         kind |= PTHREAD_MUTEX_NO_ELISION_NP;
     }
 
+  /* When the CPU does not support elision never allow to set the elision
+     flags.  */
+  if ((kind & PTHREAD_MUTEX_ELISION_FLAGS_NP) && !ENABLE_ELISION)
+    kind &= ~PTHREAD_MUTEX_ELISION_FLAGS_NP;
+
   iattr = (struct pthread_mutexattr *) attr;
 
   iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;
diff --git a/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutexattr_settype.c b/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutexattr_settype.c
new file mode 100644
index 0000000..bb3dee5
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutexattr_settype.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Enable the CPUID check for elision types in pthread_mutexattr_settype.  */
+
+#include <elision-conf.h>
+#define ENABLE_ELISION (__elision_available != 0)
+#include "nptl/pthread_mutexattr_settype.c"
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]