This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: revamp sdt.h
Thanks Roland,
I've ported my pthread probe changes against your systemtap glibc tree.
I think the interface of the new sdt.h and that of the LIBC_PROBE()
marco is almost the identical, but I am not sure if we are going to have
macros like PROBE2() in the new-sdt -- not an issue at all as it is just
a handy macro.
I've inline-attached the diff, and the biggest change is that
"pthread_probe.h" used with the old sdt.h is now gone.
I have not attached the diffs for the probes in the inline assembly code
yet, I will do that soon.
Rayson
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 6a87a8b..9f67a58 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, 2, threadid, result);
+
return result;
}
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index e2c9f8a..dd690cd 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include "pthreadP.h"
+#include <stap-probe.h>
int
__pthread_mutex_destroy (mutex)
@@ -32,6 +33,8 @@ __pthread_mutex_destroy (mutex)
/* Set to an invalid value. */
mutex->__data.__kind = -1;
+ LIBC_PROBE(pthread_mutex_destroy, 1, mutex);
+
return 0;
}
strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index d9b1ef0..e4fcae7 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. */
@@ -47,6 +49,8 @@ __pthread_mutex_init (mutex, mutexattr)
imutexattr = (const struct pthread_mutexattr *) mutexattr ?:
&default_attr;
+ LIBC_PROBE(pthread_mutex_init, 2, mutex, mutexattr);
+
/* Sanity checks. */
switch (__builtin_expect (imutexattr->mutexkind
& PTHREAD_MUTEXATTR_PROTOCOL_MASK,
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 50dc188..b754372 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -25,6 +25,7 @@
#include "pthreadP.h"
#include <lowlevellock.h>
+#include <stap-probe.h>
#ifndef LLL_MUTEX_LOCK
# define LLL_MUTEX_LOCK(mutex) \
@@ -48,6 +49,10 @@ __pthread_mutex_lock (mutex)
assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
unsigned int type = PTHREAD_MUTEX_TYPE (mutex);
+
+ /* systemtap marker */
+ LIBC_PROBE(pthread_mutex_lock, 1, mutex);
+
if (__builtin_expect (type & ~PTHREAD_MUTEX_KIND_MASK_NP, 0))
return __pthread_mutex_lock_full (mutex);
@@ -60,6 +65,8 @@ __pthread_mutex_lock (mutex)
/* Normal mutex. */
LLL_MUTEX_LOCK (mutex);
assert (mutex->__data.__owner == 0);
+
+ LIBC_PROBE(pthread_mutex_lock_block, 1, mutex);
}
else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
{
@@ -75,6 +82,11 @@ __pthread_mutex_lock (mutex)
++mutex->__data.__count;
+ /* currently, the systemtap pthread probe does not have a */
+ /* probe point here because the thread already owns this */
+ /* recursive lock before the call to this function. */
+ /* this might change in the future */
+
return 0;
}
@@ -83,6 +95,8 @@ __pthread_mutex_lock (mutex)
assert (mutex->__data.__owner == 0);
mutex->__data.__count = 1;
+
+ LIBC_PROBE(pthread_mutex_lock_block, 1, mutex);
}
else if (__builtin_expect (type == PTHREAD_MUTEX_ADAPTIVE_NP, 1))
{
@@ -94,6 +108,7 @@ __pthread_mutex_lock (mutex)
int cnt = 0;
int max_cnt = MIN (MAX_ADAPTIVE_COUNT,
mutex->__data.__spins * 2 + 10);
+
do
{
if (cnt++ >= max_cnt)
@@ -108,6 +123,8 @@ __pthread_mutex_lock (mutex)
}
while (LLL_MUTEX_TRYLOCK (mutex) != 0);
+ LIBC_PROBE(pthread_mutex_lock_block, 1, mutex);
+
mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
}
assert (mutex->__data.__owner == 0);
@@ -127,6 +144,8 @@ __pthread_mutex_lock (mutex)
++mutex->__data.__nusers;
#endif
+ LIBC_PROBE(pthread_mutex_lock_acquire, 1, mutex);
+
return 0;
}
@@ -277,6 +296,10 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
++mutex->__data.__count;
+ /* currently, the systemtap pthread probe does not have
a */
+ /* probe point here because the thread already owns
this */
+ /* recursive lock before the call to this function. */
+ /* this might change in the future */
return 0;
}
}
@@ -393,6 +416,11 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
/* Overflow of the counter. */
return EAGAIN;
+ /* currently, the systemtap pthread probe does not
have a */
+ /* probe point here because the thread already owns
this */
+ /* recursive lock before the call to this function. */
+ /* this might change in the future */
+
++mutex->__data.__count;
return 0;
@@ -451,6 +479,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
}
while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+ LIBC_PROBE(pthread_mutex_lock_full_block, 1, mutex);
+
assert (mutex->__data.__owner == 0);
mutex->__data.__count = 1;
}
@@ -467,6 +497,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
++mutex->__data.__nusers;
#endif
+ LIBC_PROBE(pthread_mutex_lock_full_acquire, 1, mutex);
+
return 0;
}
#ifndef __pthread_mutex_lock
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index f9fe10b..e0f305e 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -23,6 +23,8 @@
#include "pthreadP.h"
#include <lowlevellock.h>
+#include <stap-probe.h>
+
static int
internal_function
__pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
@@ -50,6 +52,7 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
/* Unlock. */
lll_unlock (mutex->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex));
+ LIBC_PROBE(pthread_mutex_release, 1, mutex);
return 0;
}
else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
@@ -60,6 +63,10 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
+
+ /* currently, the systemtap pthread probe does not have */
+ /* probe point here because the thread still owns the lock */
+ /* this might change in the future */
return 0;
goto normal;
}
@@ -104,6 +111,10 @@ __pthread_mutex_unlock_full (pthread_mutex_t
*mutex, int decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
+
+ /* currently, the systemtap pthread probe does not have */
+ /* probe point here because the thread still owns the lock */
+ /* this might change in the future */
return 0;
goto robust;
@@ -149,6 +160,10 @@ __pthread_mutex_unlock_full (pthread_mutex_t
*mutex, int decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
+
+ /* currently, the systemtap pthread probe does not have */
+ /* probe point here because the thread still owns the lock */
+ /* this might change in the future */
return 0;
goto continue_pi_non_robust;
@@ -171,6 +186,10 @@ __pthread_mutex_unlock_full (pthread_mutex_t
*mutex, int decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
+
+ /* currently, the systemtap pthread probe does not have */
+ /* probe point here because the thread still owns the lock */
+ /* this might change in the future */
return 0;
goto continue_pi_robust;
@@ -237,6 +256,10 @@ __pthread_mutex_unlock_full (pthread_mutex_t
*mutex, int decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
+
+ /* currently, the systemtap pthread probe does not have */
+ /* probe point here because the thread still owns the lock */
+ /* this might change in the future */
return 0;
goto pp;
@@ -272,6 +295,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(pthread_mutex_release, 1, mutex);
+
return __pthread_tpp_change_priority (oldprio, -1);
default:
@@ -279,6 +305,8 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex,
int decr)
return EINVAL;
}
+ LIBC_PROBE(pthread_mutex_release, 1, mutex);
+
return 0;
}
diff --git a/nptl/pthread_rwlock_destroy.c
b/nptl/pthread_rwlock_destroy.c
index 28fd24b..b14de8f 100644
--- a/nptl/pthread_rwlock_destroy.c
+++ b/nptl/pthread_rwlock_destroy.c
@@ -19,12 +19,14 @@
#include "pthreadP.h"
+#include <stap-probe.h>
int
__pthread_rwlock_destroy (rwlock)
pthread_rwlock_t *rwlock;
{
/* Nothing to be done. For now. */
+ LIBC_PROBE(pthread_rwlock_destroy, 1, rwlock);
return 0;
}
strong_alias (__pthread_rwlock_destroy, pthread_rwlock_destroy)
diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c
index 31eb508..7b4d8f0 100644
--- a/nptl/pthread_rwlock_rdlock.c
+++ b/nptl/pthread_rwlock_rdlock.c
@@ -23,6 +23,8 @@
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
+
/* Acquire read lock for RWLOCK. */
int
@@ -31,6 +33,8 @@ __pthread_rwlock_rdlock (rwlock)
{
int result = 0;
+ LIBC(pthread_rwlock_rdlock, 1, rwlock);
+
/* Make sure we are along. */
lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
@@ -49,6 +53,13 @@ __pthread_rwlock_rdlock (rwlock)
--rwlock->__data.__nr_readers;
result = EAGAIN;
}
+ else
+ {
+ /* systemtap pthread probe - this is the only place where
*/
+ /* we get this read-write lock */
+ LIBC_PROBE(pthread_rwlock_rdlock, 1, rwlock);
+ }
+
break;
}
diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c
index a7ef71a..ba9620b 100644
--- a/nptl/pthread_rwlock_unlock.c
+++ b/nptl/pthread_rwlock_unlock.c
@@ -23,10 +23,14 @@
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
+
/* Unlock RWLOCK. */
int
__pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
{
+ LIBC_PROBE(pthread_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 64fe970..09b9454 100644
--- a/nptl/pthread_rwlock_wrlock.c
+++ b/nptl/pthread_rwlock_wrlock.c
@@ -23,6 +23,7 @@
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
/* Acquire write lock for RWLOCK. */
int
@@ -31,6 +32,8 @@ __pthread_rwlock_wrlock (rwlock)
{
int result = 0;
+ LIBC_PROBE(pthread_rwlock_wrlock, 1, rwlock);
+
/* Make sure we are along. */
lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
@@ -41,6 +44,11 @@ __pthread_rwlock_wrlock (rwlock)
{
/* Mark self as writer. */
rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+
+ /* systemtap pthread probe - this is the only place where we
can */
+ /* get this read-write lock. */
+ LIBC_PROBE(pthread_rwlock_wrlock_acquire, 1, rwlock);
+
break;
}
On Mon, 2010-08-09 at 09:37 -0700, Roland McGrath wrote:
> > I have modified your sdt.h slightly and used it for the pthread
> > probes. Is there a special branch of systemtap or utrace that I need
> > to use in order to test/benchmark the overhead of the existance of the
> > new sdt probes in libpthread?
>
> The translator work has yet to be done. So at the moment all you could
> test is having the probes in there statically (i.e. addition of nop
> instructions) and not using them.
>
>
> Thanks,
> Roland