]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/pthread_rwlock_rdlock.c
Add adaptive elision to rwlocks
[thirdparty/glibc.git] / nptl / pthread_rwlock_rdlock.c
index 1df0327a22da6ab949d2e1d70030db209dc20b2c..6eb9e091c49bddfb11a0710f25088edee75b9ab2 100644 (file)
@@ -22,6 +22,7 @@
 #include <pthread.h>
 #include <pthreadP.h>
 #include <stap-probe.h>
+#include <elide.h>
 
 
 /* Acquire read lock for RWLOCK.  Slow path.  */
@@ -102,6 +103,12 @@ __pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
 
   LIBC_PROBE (rdlock_entry, 1, rwlock);
 
+  if (ELIDE_LOCK (rwlock->__data.__rwelision,
+                 rwlock->__data.__lock == 0
+                 && rwlock->__data.__writer == 0
+                 && rwlock->__data.__nr_readers == 0))
+    return 0;
+
   /* Make sure we are alone.  */
   lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);