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]

Re: [PATCH 10/14] Add a new pthread_rwlockattr_setelision_np function for rwlocks


[Address feedback]

Add a new exported pthread_rwlockattr_setelision_np() function that allows
enabling or disabling elision for a rwlock.

This now implies no behaviour changes that are not undefined or
are "may" in POSIX to my knowledge. The previous trylock
changes have been eliminated.

This is now purely a tuning hint.

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

	* Makefile (pthread_rwlockattr_setelision_np): Add new file.
	* Versions (pthread_rwlockattr_setelision_np): Add new symbol.
	* pthread_rwlockattr_setelision_np.c: New file.
	* pthread_rwlock_init (pthread_rwlock_init): Transfer elision state.
	* sysdeps/pthread/pthread.h (pthread_rwlockattr_setkind_np):
	  Add new prototype.
	* sysdeps/unix/sysv/linux/x86/pthread_rwlockattr_setelision_np.c:
	  New file.

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

	* sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist: Add
	  pthread_rwlockattr_setelision_np.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/s390/s390-32/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/s390/s390-64/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist: dito.
	* sysdeps/unix/sysv/linux/x86_64/x32/nptl/libpthread.abilist: dito.
---
 nptl/Makefile                                      |    1 +
 nptl/Versions                                      |    1 +
 nptl/pthread_rwlock_init.c                         |    4 ++
 nptl/pthread_rwlockattr_setelision_np.c            |   41 ++++++++++++++++++++
 nptl/sysdeps/pthread/pthread.h                     |   10 +++++
 .../linux/x86/pthread_rwlockattr_setelision_np.c   |   20 ++++++++++
 .../unix/sysv/linux/i386/nptl/libpthread.abilist   |    1 +
 .../powerpc/powerpc32/fpu/nptl/libpthread.abilist  |    1 +
 .../powerpc/powerpc64/nptl/libpthread.abilist      |    1 +
 .../linux/s390/s390-32/nptl/libpthread.abilist     |    1 +
 .../linux/s390/s390-64/nptl/libpthread.abilist     |    1 +
 sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist |    1 +
 .../linux/sparc/sparc32/nptl/libpthread.abilist    |    1 +
 .../linux/sparc/sparc64/nptl/libpthread.abilist    |    1 +
 .../sysv/linux/x86_64/64/nptl/libpthread.abilist   |    1 +
 .../sysv/linux/x86_64/x32/nptl/libpthread.abilist  |    1 +
 16 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 nptl/pthread_rwlockattr_setelision_np.c
 create mode 100644 nptl/sysdeps/unix/sysv/linux/x86/pthread_rwlockattr_setelision_np.c

diff --git a/nptl/Makefile b/nptl/Makefile
index 883c9a8..d076b68 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -66,6 +66,7 @@ libpthread-routines = nptl-init vars events version \
 		      pthread_rwlockattr_setpshared \
 		      pthread_rwlockattr_getkind_np \
 		      pthread_rwlockattr_setkind_np \
+		      pthread_rwlockattr_setelision_np \
 		      pthread_cond_init pthread_cond_destroy \
 		      pthread_cond_wait pthread_cond_timedwait \
 		      pthread_cond_signal pthread_cond_broadcast \
diff --git a/nptl/Versions b/nptl/Versions
index 1ca3943..7a161b6 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -260,6 +260,7 @@ libpthread {
     pthread_mutexattr_setkind_np;
     __pthread_mutexattr_settype;
     pthread_mutexattr_setelision_np;
+    pthread_rwlockattr_setelision_np;
   };
 
   GLIBC_PRIVATE {
diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c
index 29bef71..ba5c3f3 100644
--- a/nptl/pthread_rwlock_init.c
+++ b/nptl/pthread_rwlock_init.c
@@ -68,6 +68,10 @@ __pthread_rwlock_init (rwlock, attr)
 					      header.private_futex));
 #endif
 
+#ifdef __PTHREAD_RWLOCK_ELISION
+  rwlock->__data.__rw_elision = iattr->rw_elision;
+#endif
+
   return 0;
 }
 strong_alias (__pthread_rwlock_init, pthread_rwlock_init)
diff --git a/nptl/pthread_rwlockattr_setelision_np.c b/nptl/pthread_rwlockattr_setelision_np.c
new file mode 100644
index 0000000..a0671d2
--- /dev/null
+++ b/nptl/pthread_rwlockattr_setelision_np.c
@@ -0,0 +1,41 @@
+/* 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/>.  */
+
+#include <pthreadP.h>
+
+#ifndef ENABLE_ELISION
+# define ENABLE_ELISION 0
+#endif
+
+int
+pthread_rwlockattr_setelision_np (pthread_rwlockattr_t *attr, int flag)
+{
+  struct pthread_rwlockattr *iattr;
+
+  iattr = (struct pthread_rwlockattr *) attr;
+
+  if (ENABLE_ELISION)
+    {
+      if (flag == PTHREAD_MUTEX_ELISION_ENABLE_NP)
+        iattr->rw_elision = 1;
+      else if (flag == PTHREAD_MUTEX_ELISION_DISABLE_NP)
+        iattr->rw_elision = -1;
+      else
+	return EINVAL;
+    }
+  return 0;
+}
diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h
index 0687aa0..7857a96 100644
--- a/nptl/sysdeps/pthread/pthread.h
+++ b/nptl/sysdeps/pthread/pthread.h
@@ -995,6 +995,16 @@ extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
 					  int __pref) __THROW __nonnull ((1));
 #endif
 
+#if defined __USE_GNU
+
+/* Set elision tuning hints for *ATTR.  When FLAG is PTHREAD_MUTEX_ELISION_ENABLE_NP
+   enable elision for the rwlock. When FLAG is PTHREAD_MUTEX_ELISION_DISABLE_NP,
+   disable elision for the rwlock. This is purely a tuning hint.  */
+
+extern int pthread_rwlockattr_setelision_np (pthread_rwlockattr_t *__attr,
+		                             int __flag);
+#endif
+
 
 /* Functions for handling conditional variables.  */
 
diff --git a/nptl/sysdeps/unix/sysv/linux/x86/pthread_rwlockattr_setelision_np.c b/nptl/sysdeps/unix/sysv/linux/x86/pthread_rwlockattr_setelision_np.c
new file mode 100644
index 0000000..ee71b43
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/x86/pthread_rwlockattr_setelision_np.c
@@ -0,0 +1,20 @@
+/* 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/>.  */
+
+#include <elision-conf.h>
+#define ENABLE_ELISION (__elision_available != 0)
+#include "nptl/pthread_rwlockattr_setelision_np.c"
diff --git a/sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist
index 56b3c98..a3c9d42 100644
--- a/sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist
@@ -181,6 +181,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libpthread.abilist
index 347bb94..db3321a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libpthread.abilist
@@ -181,6 +181,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread.abilist
index 3631e20..04fde5b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread.abilist
@@ -15,6 +15,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.3
  GLIBC_2.3 A
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/nptl/libpthread.abilist
index 56b3c98..a3c9d42 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/nptl/libpthread.abilist
@@ -181,6 +181,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/nptl/libpthread.abilist
index 7558db8..10bb402 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/nptl/libpthread.abilist
@@ -15,6 +15,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist
index 7558db8..10bb402 100644
--- a/sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/nptl/libpthread.abilist
@@ -15,6 +15,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libpthread.abilist
index ff636f8..79fd750 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libpthread.abilist
@@ -181,6 +181,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libpthread.abilist
index 4a963be..d6607c0 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libpthread.abilist
@@ -15,6 +15,7 @@ GLIBC_2.18
  __pthread_mutexattr_settype F
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
+ pthread_rwlockattr_setelision_np F
  pthread_mutexattr_settype F
 GLIBC_2.2
  GLIBC_2.2 A
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist
index b2c5f9e..c014641 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist
@@ -15,6 +15,7 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
 GLIBC_2.2.5
  GLIBC_2.2.5 A
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libpthread.abilist
index eb6cd21..8944369 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libpthread.abilist
@@ -229,4 +229,5 @@ GLIBC_2.18
  pthread_mutexattr_setelision_np F
  pthread_mutexattr_setkind_np F
  pthread_mutexattr_settype F
+ pthread_rwlockattr_setelision_np F
  pthread_setattr_default_np F
-- 
1.7.4.4


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