about summary refs log tree commit diff
path: root/nptl/lowlevellock.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/lowlevellock.c')
-rw-r--r--nptl/lowlevellock.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c
index 5eaa3807ea..47548ff121 100644
--- a/nptl/lowlevellock.c
+++ b/nptl/lowlevellock.c
@@ -17,20 +17,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sysdep.h>
 #include <lowlevellock.h>
-#include <sys/time.h>
 #include <atomic.h>
+#include <stap-probe.h>
 
 void
 __lll_lock_wait_private (int *futex)
 {
-  if (*futex == 2)
-    lll_futex_wait (futex, 2, LLL_PRIVATE); /* Wait if *futex == 2.  */
-
-  while (atomic_exchange_acq (futex, 2) != 0)
-    lll_futex_wait (futex, 2, LLL_PRIVATE); /* Wait if *futex == 2.  */
+  if (atomic_load_relaxed (futex) == 2)
+    goto futex;
+
+  while (atomic_exchange_acquire (futex, 2) != 0)
+    {
+    futex:
+      LIBC_PROBE (lll_lock_wait_private, 1, futex);
+      lll_futex_wait (futex, 2, LLL_PRIVATE); /* Wait if *futex == 2.  */
+    }
 }
 
 
@@ -39,10 +42,14 @@ __lll_lock_wait_private (int *futex)
 void
 __lll_lock_wait (int *futex, int private)
 {
-  if (*futex == 2)
-    lll_futex_wait (futex, 2, private); /* Wait if *futex == 2.  */
-
-  while (atomic_exchange_acq (futex, 2) != 0)
-    lll_futex_wait (futex, 2, private); /* Wait if *futex == 2.  */
+  if (atomic_load_relaxed (futex) == 2)
+    goto futex;
+
+  while (atomic_exchange_acquire (futex, 2) != 0)
+    {
+    futex:
+      LIBC_PROBE (lll_lock_wait, 1, futex);
+      lll_futex_wait (futex, 2, private); /* Wait if *futex == 2.  */
+    }
 }
 #endif