This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap 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] Adding systemtap probe points in pthread library (slightly revised again)


On Wed, 2011-01-26 at 10:54 -0800, Roland McGrath wrote:
> If you have probes in the lowlevellock code at all, then I think it makes
> sense to have them in all its incarnations.  Those probes are called
> "lll_*" so they are about the low-level internals rather than API-level
> pthread calls anyway.  With the macros as they are, they will wind up with
> provider "libc" instead of "libpthread", so tracing scripts can distinguish
> them that way.
> 
> You didn't say anything about the conditionalization of cases other than
> lll_* code.

The problem I had at the beginning was related to some modules not
defining IN_LIB, so the following code was complaining:

# ifndef NOT_IN_libc
#  define IN_LIB        libc
# elif !defined IN_LIB
#  error "missing -DIN_LIB=... -- not extra-lib.mk?"
# endif

Some code (files) really are not libraries, examples of those are utils
in iconv. And some do not include extra-lib.mk, as they do their own
"-DNOT_IN_libc=1" in their Makefiles.

The simplest hack would be to not "#error" the  define, but to quietly
define IN_LIB to something else.

A better fix but involves touch a lot of Makefiles this one -- note that
I defined IN_LIB for non libraries code to "nonlib":

===============================================================================

diff --git a/Makerules b/Makerules
index 9bfe550..4ff8211 100644
--- a/Makerules
+++ b/Makerules
@@ -1202,7 +1202,7 @@ include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 endif

 # The include magic above causes those files to use this variable for flags.
-CPPFLAGS-nonlib = -DNOT_IN_libc=1
+CPPFLAGS-nonlib = -DNOT_IN_libc=1 -DIN_LIB=nonlib


 ifeq ($(versioning),yes)
diff --git a/elf/Makefile b/elf/Makefile
index b0420f5..ba03077 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -455,7 +455,7 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
 CFLAGS-cache.c = $(SYSCONF-FLAGS)

-CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
+CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)

 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
 generated += $(addsuffix .so,$(strip $(modules-names)))
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
index 9f31a56..e99c81b 100644
--- a/elf/rtld-Rules
+++ b/elf/rtld-Rules
@@ -122,6 +122,6 @@ ifdef rtld-depfiles
 endif

 # This here is the whole point of all the shenanigans.
-rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
+rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld

 endif
diff --git a/iconv/Makefile b/iconv/Makefile
index 77a9ad7..6abf27b 100644
--- a/iconv/Makefile
+++ b/iconv/Makefile
@@ -63,13 +63,13 @@ CFLAGS-gconv_cache.c += -DGCONV_DIR='"$(gconvdir)"'
 CFLAGS-gconv_conf.c = -DGCONV_PATH='"$(gconvdir)"'
 CFLAGS-iconvconfig.c = -DGCONV_PATH='"$(gconvdir)"' -DGCONV_DIR='"$(gconvdir)"'

-CPPFLAGS-iconv_prog = -DNOT_IN_libc
-CPPFLAGS-iconv_charmap = -DNOT_IN_libc
-CPPFLAGS-iconvconfig = -DNOT_IN_libc
-CPPFLAGS-linereader = -DNOT_IN_libc
-CPPFLAGS-strtab = -DNOT_IN_libc
-CPPFLAGS-charmap = -DNOT_IN_libc
-CPPFLAGS-charmap-dir = -DNOT_IN_libc
+CPPFLAGS-iconv_prog = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-iconv_charmap = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-iconvconfig = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-linereader = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-strtab = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-charmap = -DNOT_IN_libc -DIN_LIB=nonlib
+CPPFLAGS-charmap-dir = -DNOT_IN_libc -DIN_LIB=nonlib

 include ../Rules

diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index d8fb282..bd25641 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -79,7 +79,7 @@ tst-iconv7-ENV = LOCPATH=$(common-objpfx)localedata
 endif

 # No code here is in libc.so.
-CPPFLAGS += -DNOT_IN_libc
+CPPFLAGS += -DNOT_IN_libc -DIN_LIB=localedata

 libJIS-routines := jis0201 jis0208 jis0212
 libKSC-routines := ksc5601
diff --git a/malloc/Makefile b/malloc/Makefile
index e7ec1ab..412e7ba 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -57,7 +57,7 @@ aux := set-freeres thread-freeres

 include ../Makeconfig

-CPPFLAGS-memusagestat = -DNOT_IN_libc
+CPPFLAGS-memusagestat = -DNOT_IN_libc -DIN_LIB=libmalloc

 # The Perl script to analyze the output of the mtrace functions.
 ifneq ($(PERL),no)

===============================================================================

And with the changes in the Makefiles, the ugly #define code can be
cleaned up.

Addition to Changelog (against nptl/ChangeLog):

2011-01-26  Rayson Ho  <rho@redhat.com>

	* DESIGN-systemtap-probes.txt: New file.
	* pthread_cond_broadcast.c: SystemTap probes.
	* pthread_cond_init.c: Likewise.
	* pthread_cond_signal.c: Likewise.
	* pthread_cond_wait.c: Likewise.
	* pthread_condattr_destroy.c: Likewise.
	* pthread_cond_destroy.c: Likewise.
	* pthread_create.c: Likewise.
	* pthread_join.c: Likewise.
	* pthread_mutex_destroy.c: Likewise.
	* pthread_mutex_init.c: Likewise.
	* pthread_mutex_lock.c: Likewise.
	* pthread_mutex_unlock.c: Likewise.
	* pthread_rwlock_destroy.c: Likewise.
	* pthread_rwlock_rdlock.c: Likewise.
	* pthread_rwlock_unlock.c: Likewise.
	* pthread_rwlock_wrlock.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.


And the patch:

===============================================================================

diff --git a/nptl/DESIGN-systemtap-probes.txt b/nptl/DESIGN-systemtap-probes.txt
index e69de29..dff4dc1 100644
--- a/nptl/DESIGN-systemtap-probes.txt
+++ b/nptl/DESIGN-systemtap-probes.txt
@@ -0,0 +1,80 @@
+Systemtap is a dynamic tracing/instrumenting tool available on Linux. Probes
+that are not fired at run time have close to zero overhead.
+
+The following probes are available for NPTL:
+
+Thread creation & Join Probes
+=============================
+pthread_create - probe for pthread_create
+               arg1 = start_routine
+               arg2 = arguments to start_routine
+pthread_start - probe for actual thread creation
+              arg1 = struct pthread (members include thread ID, process ID)
+              arg2 = address of start_routine
+              arg3 = pointer to the list of arguments
+pthread_join - probe for pthread_join
+             arg1 = thread ID
+pthread_join_ret - probe for pthread_join return
+                 arg1 = thread ID
+                 arg2 = return value
+
+Lock-related Probes
+===================
+mutex_init    - probe for pthread_mutex_init
+              arg1 = address of mutex lock
+mutex_acquired - probe for pthread_mutex_lock
+               arg1 = address of mutex lock
+mutex_block   - probe for resume from _possible_ mutex block event
+              arg1 = address of mutex lock
+mutex_entry   - probe for entry to the pthread_mutex_lock function
+              arg1 = address of mutex lock
+mutex_release - probe for pthread_mutex_unlock after the successful release of a
+                mutex lock
+              arg1 = address of mutex lock
+mutex_destroy - probe for pthread_mutex_destroy
+              arg1 = address of mutex lock
+
+wrlock_entry - probe for entry to the pthread_rwlock_wrlock function
+             arg1 = address of rw lock
+rdlock_entry - probe for entry to the pthread_rwlock_rdlock function
+             arg1 = address of rw lock
+
+rwlock_destroy - probe for pthread_rwlock_destroy
+               arg1 = address of rw lock
+rwlock_acquire_write - probe for pthread_rwlock_wrlock
+                     arg1 = address of rw lock
+rdlock_acquire_read - probe for pthread_rwlock_rdlock after successfully getting
+                      the lock
+                    arg1 = address of rw lock
+rwlock_unlock - probe for pthread_rwlock_unlock
+              arg1 = address of rw lock
+
+lll_futex_wait - probe in low-level (assembly language) locking code, only fired
+                 when futex is called (i.e. when trying to acquire a contented
+                 lock)
+lll_futex_wait_private - probe in low-level (assembly language) locking code,
+                         only fired when futex is called (i.e. when trying to
+                         acquire a contented lock)
+lll_futex_wake - probe in low-level (assembly language) locking code, only fired
+                 when futex is called (FUTEX_WAIT), arg1 = 
+
+Condition variable Probes
+=========================
+cond_init - probe for pthread_cond_init
+          arg1 = condition
+          arg2 = attr
+condattr_destroy - probe for pthread_condattr_destroy
+             arg1 = attr
+cond_destroy - probe for pthread_cond_destroy
+             arg1 = cond
+cond_wait - probe for pthread_cond_wait
+          arg1 = condition
+          arg2 = mutex lock
+cond_timedwait - probe for pthread_cond_timedwait
+               arg1 = condition
+               arg2 = mutex lock
+               arg3 = timespec
+cond_signal - probe for pthread_cond_signal
+            arg1 = condition
+cond_broadcast - probe for pthread_cond_broadcast
+               arg1 = condition
diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c
index 22523c2..a2e462f 100644
--- a/nptl/pthread_cond_broadcast.c
+++ b/nptl/pthread_cond_broadcast.c
@@ -23,6 +23,7 @@
 #include <lowlevellock.h>
 #include <pthread.h>
 #include <pthreadP.h>
+#include <stap-probe.h>
 
 #include <shlib-compat.h>
 #include <kernel-features.h>
@@ -32,6 +33,8 @@ int
 __pthread_cond_broadcast (cond)
      pthread_cond_t *cond;
 {
+  LIBC_PROBE (cond_broadcast, 1, cond);
+
   int pshared = (cond->__data.__mutex == (void *) ~0l)
 		? LLL_SHARED : LLL_PRIVATE;
   /* Make sure we are alone.  */
diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c
index 65c01b1..caec6ca 100644
--- a/nptl/pthread_cond_init.c
+++ b/nptl/pthread_cond_init.c
@@ -20,6 +20,7 @@
 
 #include <shlib-compat.h>
 #include "pthreadP.h"
+#include <stap-probe.h>
 
 
 int
@@ -42,6 +43,8 @@ __pthread_cond_init (cond, cond_attr)
 			  ? NULL : (void *) ~0l);
   cond->__data.__broadcast_seq = 0;
 
+  LIBC_PROBE (cond_init, 2, cond, cond_attr);
+
   return 0;
 }
 versioned_symbol (libpthread, __pthread_cond_init,
diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c
index 023bbb5..6615f21 100644
--- a/nptl/pthread_cond_signal.c
+++ b/nptl/pthread_cond_signal.c
@@ -35,6 +35,8 @@ __pthread_cond_signal (cond)
   int pshared = (cond->__data.__mutex == (void *) ~0l)
                ? LLL_SHARED : LLL_PRIVATE;
 
+  LIBC_PROBE (cond_signal, 1, cond);
+
   /* Make sure we are alone.  */
   lll_lock (cond->__data.__lock, pshared);
 
diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
index 467a03a..bac1bef 100644
--- a/nptl/pthread_cond_wait.c
+++ b/nptl/pthread_cond_wait.c
@@ -23,6 +23,7 @@
 #include <lowlevellock.h>
 #include <pthread.h>
 #include <pthreadP.h>
+#include <stap-probe.h>
 
 #include <shlib-compat.h>
 
@@ -101,6 +102,8 @@ __pthread_cond_wait (cond, mutex)
   int pshared = (cond->__data.__mutex == (void *) ~0l)
                ? LLL_SHARED : LLL_PRIVATE;
 
+  LIBC_PROBE (cond_wait, 2, cond, mutex);
+
   /* Make sure we are alone.  */
   lll_lock (cond->__data.__lock, pshared);
 
diff --git a/nptl/pthread_condattr_destroy.c b/nptl/pthread_condattr_destroy.c
index e6d069e..5a604bc 100644
--- a/nptl/pthread_condattr_destroy.c
+++ b/nptl/pthread_condattr_destroy.c
@@ -18,6 +18,7 @@
    02111-1307 USA.  */
 
 #include "pthreadP.h"
+#include <stap-probe.h>
 
 
 int
@@ -25,6 +26,8 @@ __pthread_condattr_destroy (attr)
      pthread_condattr_t *attr;
 {
   /* Nothing to be done.  */
+
+  LIBC_PROBE (condattr_destroy, 1, attr);
   return 0;
 }
 strong_alias (__pthread_condattr_destroy, pthread_condattr_destroy)

diff --git a/nptl/pthread_cond_destroy.c b/nptl/pthread_cond_destroy.c
index 35135a6..a28d061 100644
--- a/nptl/pthread_cond_destroy.c
+++ b/nptl/pthread_cond_destroy.c
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <shlib-compat.h>
 #include "pthreadP.h"
+#include <stap-probe.h>
 
 
 int
@@ -29,6 +30,8 @@ __pthread_cond_destroy (cond)
   int pshared = (cond->__data.__mutex == (void *) ~0l)
                ? LLL_SHARED : LLL_PRIVATE;
 
+  LIBC_PROBE (cond_destroy, 1, cond);
+
   /* Make sure we are alone.  */
   lll_lock (cond->__data.__lock, pshared);

diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 4075dd9..d574cc5 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -556,6 +556,8 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
   /* Pass the descriptor to the caller.  */
   *newthread = (pthread_t) pd;
 
+  LIBC_PROBE (pthread_create, 2, start_routine, arg);
+
   /* Start the thread.  */
   return create_thread (pd, iattr, STACK_VARIABLES_ARGS);
 }
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 6a87a8b..609e2cf 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -23,6 +23,8 @@
 #include <atomic.h>
 #include "pthreadP.h"
 
+#include <stap-probe.h>
+
 
 static void
 cleanup (void *arg)
@@ -55,6 +57,8 @@ pthread_join (threadid, thread_return)
   struct pthread *self = THREAD_SELF;
   int result = 0;
 
+  LIBC_PROBE (pthread_join, 1, threadid);
+
   /* During the wait we change to asynchronous cancellation.  If we
      are canceled the thread we are waiting for must be marked as
      un-wait-ed for again.  */
@@ -110,5 +114,7 @@ pthread_join (threadid, thread_return)
       __free_tcb (pd);
     }
 
+  LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd->result);
+
   return result;
 }
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index e2c9f8a..45c80b8 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -20,11 +20,15 @@
 #include <errno.h>
 #include "pthreadP.h"
 
+#include <stap-probe.h>
+
 
 int
 __pthread_mutex_destroy (mutex)
      pthread_mutex_t *mutex;
 {
+  LIBC_PROBE (mutex_destroy, 1, mutex);
+
   if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
       && mutex->__data.__nusers != 0)
     return EBUSY;
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index d9b1ef0..a025a38 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -24,6 +24,8 @@
 #include <kernel-features.h>
 #include "pthreadP.h"
 
+#include <stap-probe.h>
+
 static const struct pthread_mutexattr default_attr =
   {
     /* Default is a normal mutex, not shared between processes.  */
@@ -135,6 +137,8 @@ __pthread_mutex_init (mutex, mutexattr)
   // mutex->__spins = 0;	already done by memset
   // mutex->__next = NULL;	already done by memset
 
+  LIBC_PROBE (mutex_init, 1, mutex);
+
   return 0;
 }
 strong_alias (__pthread_mutex_init, pthread_mutex_init)
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 50dc188..010d43e 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -24,6 +24,7 @@
 #include <not-cancel.h>
 #include "pthreadP.h"
 #include <lowlevellock.h>
+#include <stap-probe.h>
 
 
 #ifndef LLL_MUTEX_LOCK
@@ -48,6 +49,9 @@ __pthread_mutex_lock (mutex)
   assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
 
   unsigned int type = PTHREAD_MUTEX_TYPE (mutex);
+
+  LIBC_PROBE (mutex_entry, 1, mutex);
+
   if (__builtin_expect (type & ~PTHREAD_MUTEX_KIND_MASK_NP, 0))
     return __pthread_mutex_lock_full (mutex);
 
@@ -60,6 +64,8 @@ __pthread_mutex_lock (mutex)
       /* Normal mutex.  */
       LLL_MUTEX_LOCK (mutex);
       assert (mutex->__data.__owner == 0);
+
+      LIBC_PROBE (mutex_block, 1, mutex);
     }
   else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
     {
@@ -83,6 +89,8 @@ __pthread_mutex_lock (mutex)
 
       assert (mutex->__data.__owner == 0);
       mutex->__data.__count = 1;
+
+      LIBC_PROBE (mutex_block, 1, mutex);
     }
   else if (__builtin_expect (type == PTHREAD_MUTEX_ADAPTIVE_NP, 1))
     {
@@ -108,6 +116,8 @@ __pthread_mutex_lock (mutex)
 	    }
 	  while (LLL_MUTEX_TRYLOCK (mutex) != 0);
 
+          LIBC_PROBE (mutex_block, 1, mutex);
+
 	  mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
 	}
       assert (mutex->__data.__owner == 0);
@@ -127,6 +137,8 @@ __pthread_mutex_lock (mutex)
   ++mutex->__data.__nusers;
 #endif
 
+  LIBC_PROBE (mutex_acquired, 1, mutex);
+
   return 0;
 }
 
@@ -451,6 +463,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
 	  }
 	while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
 
+        LIBC_PROBE (mutex_block, 1, mutex);
+
 	assert (mutex->__data.__owner == 0);
 	mutex->__data.__count = 1;
       }
@@ -467,6 +481,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
   ++mutex->__data.__nusers;
 #endif
 
+  LIBC_PROBE (mutex_acquired, 1, mutex);
+
   return 0;
 }
 #ifndef __pthread_mutex_lock
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index f9fe10b..479e500 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include "pthreadP.h"
 #include <lowlevellock.h>
+#include <stap-probe.h>
 
 static int
 internal_function
@@ -50,6 +51,9 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
 
       /* Unlock.  */
       lll_unlock (mutex->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex));
+
+      LIBC_PROBE (mutex_release, 1, mutex);
+
       return 0;
     }
   else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
@@ -272,6 +276,9 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
 			PTHREAD_MUTEX_PSHARED (mutex));
 
       int oldprio = newval >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+      LIBC_PROBE (mutex_release, 1, mutex);
+
       return __pthread_tpp_change_priority (oldprio, -1);
 
     default:
@@ -279,6 +286,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
       return EINVAL;
     }
 
+  LIBC_PROBE (mutex_release, 1, mutex);
   return 0;
 }
 
diff --git a/nptl/pthread_rwlock_destroy.c b/nptl/pthread_rwlock_destroy.c
index 28fd24b..84aa693 100644
--- a/nptl/pthread_rwlock_destroy.c
+++ b/nptl/pthread_rwlock_destroy.c
@@ -18,12 +18,15 @@
    02111-1307 USA.  */
 
 #include "pthreadP.h"
+#include <stap-probe.h>
 
 
 int
 __pthread_rwlock_destroy (rwlock)
      pthread_rwlock_t *rwlock;
 {
+  LIBC_PROBE (rwlock_destroy, 1, rwlock);
+
   /* Nothing to be done.  For now.  */
   return 0;
 }
diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c
index 2feac57..09bad14 100644
--- a/nptl/pthread_rwlock_rdlock.c
+++ b/nptl/pthread_rwlock_rdlock.c
@@ -22,6 +22,7 @@
 #include <lowlevellock.h>
 #include <pthread.h>
 #include <pthreadP.h>
+#include <stap-probe.h>
 
 
 /* Acquire read lock for RWLOCK.  */
@@ -31,6 +32,8 @@ __pthread_rwlock_rdlock (rwlock)
 {
   int result = 0;
 
+  LIBC_PROBE (rdlock_entry, 1, rwlock);
+
   /* Make sure we are alone.  */
   lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
 
@@ -49,6 +52,8 @@ __pthread_rwlock_rdlock (rwlock)
              --rwlock->__data.__nr_readers;
              result = EAGAIN;
            }
+          else
+            LIBC_PROBE (rdlock_acquire_read, 1, rwlock);
 
          break;
        }
diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c
index a7ef71a..a6e8d87 100644
--- a/nptl/pthread_rwlock_unlock.c
+++ b/nptl/pthread_rwlock_unlock.c
@@ -22,11 +22,14 @@
 #include <lowlevellock.h>
 #include <pthread.h>
 #include <pthreadP.h>
+#include <stap-probe.h>
 
 /* Unlock RWLOCK.  */
 int
 __pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
 {
+  LIBC_PROBE (rwlock_unlock, 1, rwlock);
+
   lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
   if (rwlock->__data.__writer)
     rwlock->__data.__writer = 0;
diff --git a/nptl/pthread_rwlock_wrlock.c b/nptl/pthread_rwlock_wrlock.c
index 9d5f135..5b93b3c 100644
--- a/nptl/pthread_rwlock_wrlock.c
+++ b/nptl/pthread_rwlock_wrlock.c
@@ -22,6 +22,7 @@
 #include <lowlevellock.h>
 #include <pthread.h>
 #include <pthreadP.h>
+#include <stap-probe.h>
 
 
 /* Acquire write lock for RWLOCK.  */
@@ -31,6 +32,8 @@ __pthread_rwlock_wrlock (rwlock)
 {
   int result = 0;
 
+  LIBC_PROBE (wrlock_entry, 1, rwlock);
+
   /* Make sure we are alone.  */
   lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
 
@@ -41,6 +44,9 @@ __pthread_rwlock_wrlock (rwlock)
        {
          /* Mark self as writer.  */
          rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+
+          LIBC_PROBE (rwlock_acquire_write, 1, rwlock);
+
          break;
        }

 
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index 3195db2..568643c 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -22,6 +22,8 @@
 #include <kernel-features.h>
 #include <lowlevellock.h>
 
+#include <stap-probe.h>
+
 	.text
 
 #ifdef __ASSUME_PRIVATE_FUTEX
@@ -91,7 +93,8 @@ __lll_lock_wait_private:
 	cmpl	%edx, %eax	/* NB:	 %edx == 2 */
 	jne	2f
 
-1:	movl	$SYS_futex, %eax
+1:	LIBC_PROBE_ASM (lll_futex_wait_private, %rdi)
+	movl	$SYS_futex, %eax
 	syscall
 
 2:	movl	%edx, %eax
@@ -130,7 +133,8 @@ __lll_lock_wait:
 	cmpl	%edx, %eax	/* NB:	 %edx == 2 */
 	jne	2f
 
-1:	movl	$SYS_futex, %eax
+1:	LIBC_PROBE_ASM (lll_futex_wait, %rdi)
+	movl	$SYS_futex, %eax
 	syscall
 
 2:	movl	%edx, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index 9b15bfb..4871b5b 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -20,6 +20,8 @@
 #ifndef _LOWLEVELLOCK_H
 #define _LOWLEVELLOCK_H	1
 
+#include <stap-probe.h>
+
 #ifndef __ASSEMBLER__
 # include <time.h>
 # include <sys/param.h>
@@ -227,6 +229,7 @@ LLL_STUB_UNWIND_INFO_END
   do {									      \
     int __ignore;							      \
     register __typeof (nr) _nr __asm ("edx") = (nr);			      \
+    LIBC_PROBE (lll_futex_wake, 2, futex, nr);                                \
     __asm __volatile ("syscall"						      \
 		      : "=a" (__ignore)					      \
 		      : "0" (SYS_futex), "D" (futex),			      \
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
index 224a560..c56deae 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
@@ -25,7 +25,7 @@
 #include <kernel-features.h>
 #include <pthread-pi-defines.h>
 #include <pthread-errnos.h>
-
+#include <stap-probe.h>
 
 	.text
 
@@ -35,6 +35,8 @@
 	.align	16
 __pthread_cond_broadcast:
 
+        LIBC_PROBE_ASM (cond_broadcast, %rdi)
+
 	/* Get internal lock.  */
 	movl	$1, %esi
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
index d1d83a8..739fedd 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
@@ -24,6 +24,7 @@
 #include <pthread-pi-defines.h>
 #include <kernel-features.h>
 #include <pthread-errnos.h>
+#include <stap-probe.h>
 
 
 	.text
@@ -34,6 +35,8 @@
 	.align	16
 __pthread_cond_signal:
 
+        LIBC_PROBE_ASM (cond_signal, %rdi)
+
 	/* Get internal lock.  */
 	movq	%rdi, %r8
 	movl	$1, %esi
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
index e6535fb..06fbdae 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -23,6 +23,7 @@
 #include <lowlevelcond.h>
 #include <pthread-pi-defines.h>
 #include <pthread-errnos.h>
+#include <stap-probe.h>
 
 #include <kernel-features.h>
 
@@ -41,6 +42,9 @@
 __pthread_cond_timedwait:
 .LSTARTCODE:
 	cfi_startproc
+
+        LIBC_PROBE_ASM (cond_timedwait, %rdi)
+
 #ifdef SHARED
 	cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect,
 			DW.ref.__gcc_personality_v0)
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
index f5b929e..cb0f5bd 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
@@ -23,6 +23,7 @@
 #include <lowlevelcond.h>
 #include <tcb-offsets.h>
 #include <pthread-pi-defines.h>
+#include <stap-probe.h>
 
 #include <kernel-features.h>
 
@@ -34,6 +35,9 @@
 	.type	__pthread_cond_wait, @function
 	.align	16
 __pthread_cond_wait:
+
+        LIBC_PROBE_ASM (cond_wait, %rdi)
+
 .LSTARTCODE:
 	cfi_startproc
 #ifdef SHARED
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
index 35eb09c..09c1db1 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
@@ -22,7 +22,7 @@
 #include <lowlevelrwlock.h>
 #include <pthread-errnos.h>
 #include <kernel-features.h>
-
+#include <stap-probe.h>
 
 	.text
 
@@ -31,6 +31,9 @@
 	.align	16
 __pthread_rwlock_rdlock:
 	cfi_startproc
+
+        LIBC_PROBE_ASM (rdlock_entry, %rdi)
+
 	xorq	%r10, %r10
 
 	/* Get the lock.  */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
index be6b8d8..961b50b 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
@@ -22,7 +22,7 @@
 #include <lowlevelrwlock.h>
 #include <pthread-errnos.h>
 #include <kernel-features.h>
-
+#include <stap-probe.h>
 
 	.text
 
@@ -31,6 +31,9 @@
 	.align	16
 __pthread_rwlock_wrlock:
 	cfi_startproc
+
+        LIBC_PROBE_ASM (wrlock_entry, %rdi)
+
 	xorq	%r10, %r10
 
 	/* Get the lock.  */

===============================================================================

Thanks,
Rayson




> 
> 
> Thanks,
> Roland



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