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]

RFC: i386 port of the pthread library probes


The original patch was developed on x64 and thus the low-level probes
were missing on other architectures -- this is the patch for the machine
dependent part for 32-bit x86. Please note that while every file changed
by this patch compiles successfully on my machine (and I checked that
the probes were there with stap -L), I did not get the full glibc tested
because other parts not related to the systemtap probes failed to cross
compile.

However, before I fully test the 32-bit code, I just want to see if
others are OK with the i386 changes, which I think are quite straight
forward as they are functionally similar to the x64 counterparts (the
function argument passing convention is totally different in i386 but
that's another story...)

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

diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
index 2198ccf..92437f0 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/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 (lll_lock_wait_private, 1, %ebx)
+	movl	$SYS_futex, %eax
 	ENTER_KERNEL
 
 2:	movl	%edx, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
index a7ca78f..a0e2944 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
@@ -24,6 +24,7 @@
 #include <kernel-features.h>
 #include <pthread-pi-defines.h>
 #include <pthread-errnos.h>
+#include <stap-probe.h>
 
 	.text
 
@@ -49,6 +50,8 @@ __pthread_cond_broadcast:
 
 	movl	20(%esp), %ebx
 
+	LIBC_PROBE (cond_broadcast, 1, %edx) 
+
 	/* Get internal lock.  */
 	movl	$1, %edx
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
index 05cda25..96b5928 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
@@ -24,7 +24,7 @@
 #include <kernel-features.h>
 #include <pthread-pi-defines.h>
 #include <pthread-errnos.h>
-
+#include <stap-probe.h>
 
 	.text
 
@@ -45,6 +45,8 @@ __pthread_cond_signal:
 
 	movl	12(%esp), %edi
 
+	LIBC_PROBE (cond_signal, 1, %edi)
+
 	/* Get internal lock.  */
 	movl	$1, %edx
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
index dee73f0..3762abc 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
@@ -24,7 +24,7 @@
 #include <pthread-errnos.h>
 #include <pthread-pi-defines.h>
 #include <kernel-features.h>
-
+#include <stap-probe.h>
 
 	.text
 
@@ -61,6 +61,8 @@ __pthread_cond_timedwait:
 	movl	20(%esp), %ebx
 	movl	28(%esp), %ebp
 
+	LIBC_PROBE (cond_timedwait, 3, %ebx, 24(%esp), %ebp)
+
 	cmpl	$1000000000, 4(%ebp)
 	movl	$EINVAL, %eax
 	jae	18f
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
index 53970d7..2185cf6 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
@@ -25,6 +25,7 @@
 #include <pthread-errnos.h>
 #include <pthread-pi-defines.h>
 #include <kernel-features.h>
+#include <stap-probe.h>
 
 
 	.text
@@ -61,6 +62,8 @@ __pthread_cond_wait:
 	xorl	%esi, %esi
 	movl	20(%esp), %ebx
 
+	LIBC_PROBE (cond_wait, 2, 24(%esp), %ebx)
+
 	/* Get internal lock.  */
 	movl	$1, %edx
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
index 4e5f0c5..050266e 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
@@ -23,6 +23,7 @@
 #include <pthread-errnos.h>
 #include <kernel-features.h>
 
+#include <stap-probe.h>
 
 	.text
 
@@ -41,6 +42,8 @@ __pthread_rwlock_rdlock:
 	xorl	%esi, %esi
 	movl	12(%esp), %ebx
 
+	LIBC_PROBE (rdlock_entry, 1, %ebx)
+
 	/* Get the lock.  */
 	movl	$1, %edx
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
index 1007364..3ff0ac3 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
@@ -23,6 +23,7 @@
 #include <pthread-errnos.h>
 #include <kernel-features.h>
 
+#include <stap-probe.h>
 
 	.text
 
@@ -41,6 +42,8 @@ __pthread_rwlock_wrlock:
 	xorl	%esi, %esi
 	movl	12(%esp), %ebx
 
+	LIBC_PROBE (wrlock_entry, 1, %ebx)
+
 	/* Get the lock.  */
 	movl	$1, %edx
 	xorl	%eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
index 4bb585a..34e28bd 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/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>
@@ -226,6 +228,7 @@ LLL_STUB_UNWIND_INFO_END
   do {									      \
     int __ignore;							      \
     register __typeof (nr) _nr asm ("edx") = (nr);			      \
+    LIBC_PROBE (lll_futex_wake, 3, futex, nr, private);                       \
     __asm __volatile (LLL_EBX_LOAD					      \
 		      LLL_ENTER_KERNEL					      \
 		      LLL_EBX_LOAD					      \

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

Also, thanks Tom for the comment, I've updated the patch I just sent to
Roland - I removed mutex_block totally as it was there before the
low-level probes (the asm ones) were added, and then I recycled the name
for the release probe. For pthread_mutex_timedlock(), I added a few
simple probes:

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

diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 8d0db79..55d1802 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -24,6 +24,8 @@
 #include <lowlevellock.h>
 #include <not-cancel.h>
 
+#include <stap-probe.h>
+
 
 int
 pthread_mutex_timedlock (mutex, abstime)
@@ -34,6 +36,8 @@ pthread_mutex_timedlock (mutex, abstime)
   pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
   int result = 0;
 
+  LIBC_PROBE (mutex_timedlock_entry, 2, mutex, abstime);
+
   /* We must not check ABSTIME here.  If the thread does not block
      abstime must not be checked for a valid value.  */
 
@@ -172,6 +176,8 @@ pthread_mutex_timedlock (mutex, abstime)
 
 		  ++mutex->__data.__count;
 
+                  LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
 		  return 0;
 		}
 	    }
@@ -242,6 +248,8 @@ pthread_mutex_timedlock (mutex, abstime)
 
 		++mutex->__data.__count;
 
+                LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
 		return 0;
 	      }
 	  }
@@ -377,6 +385,8 @@ pthread_mutex_timedlock (mutex, abstime)
 
 		++mutex->__data.__count;
 
+                LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
 		return 0;
 	      }
 	  }
@@ -477,6 +487,8 @@ pthread_mutex_timedlock (mutex, abstime)
       /* Record the ownership.  */
       mutex->__data.__owner = id;
       ++mutex->__data.__nusers;
+
+      LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
     }
 
  out:

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

Thanks
Rayson


On Thu, 2011-02-10 at 08:36 -0700, Tom Tromey wrote:
> Tom> The piece that is missing for my scenario is a probe that fires just
> Tom> before glibc blocks on a mutex.  I couldn't think of a way to get this
> Tom> information with the current set of probes.
> 
> Also, I noticed that the patch does not modify pthread_mutex_timedlock.c.
> I think this means that some mutex acquisitions will go unnoticed.
> 
> Tom



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