diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-05-26 17:46:57 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-05-26 17:46:57 +0000 |
commit | d8d5895e420d4976fca22b9bd9e1edc3094ebf30 (patch) | |
tree | f96c015c14ac0428150153ba98f7a681ff021931 /libc/nptl | |
parent | 62eb53f68d92687a028f3c515489b30e3df1d979 (diff) |
Merge changes between r18519 and r18730 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@18731 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/nptl')
59 files changed, 907 insertions, 218 deletions
diff --git a/libc/nptl/ChangeLog b/libc/nptl/ChangeLog index 49e42efc4..492668bde 100644 --- a/libc/nptl/ChangeLog +++ b/libc/nptl/ChangeLog @@ -1,3 +1,192 @@ +2012-05-26 Siddhesh Poyarekar <siddhesh@redhat.com> + + [BZ #12416] + * nptl/pthread_getattr_np.c (pthread_getattr_np): Use + __libc_stack_end rounded to the end of containing page as the + real stack end. + +2012-05-25 Rayson Ho <rho@redhat.com> + + * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Low-level SystemTap + probes for i386. + * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise. + * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise. + +2012-05-25 Rayson Ho <rho@redhat.com> + Roland McGrath <roland@hack.frob.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_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_timedlock.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. + +2012-05-24 Roland McGrath <roland@hack.frob.com> + + * pthread_create.c (start_thread): Define pthread_start LIBC_PROBE. + +2012-05-17 Andreas Jaeger <aj@suse.de> + + * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h + (HAVE_DL_DISCOVER_OSVERSION): Don't declare _dl_discover_osversion + only for older kernels. + +2012-05-15 Joseph Myers <joseph@codesourcery.com> + + * pthreadP.h [!__NR_set_robust_list] (__NR_set_robust_list): Do + not define. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_lock): Load + futex pointer into RDI_LP. Use RSP_LP to operate on stack. + (lll_robust_lock): Likewise. + (lll_cond_lock): Likewise. + (lll_robust_cond_lock): Likewise. + (lll_timedlock): Likewise. + (lll_robust_timedlock): Likewise. + (lll_unlock): Likewise. + (lll_robust_unlock): Likewise. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Use + LP_OP(cmp) and RCX_LP on dep_mutex pointer. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Use LP_OP(op) + on NWAITERS. + (__gcc_personality_v0): Replace 8-byte data alignment with + LP_SIZE alignment and .quad with ASM_ADDR. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Use LP_OP(op) + on NWAITERS. + (__gcc_personality_v0): Replace 8-byte data alignment with + LP_SIZE alignment and .quad with ASM_ADDR. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Use LP_OP(cmp) on + NWAITERS, which is unsigned long int. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/pthread_once.S + (__gcc_personality_v0): Replace 8-byte data alignment with + LP_SIZE alignment and .quad with ASM_ADDR. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Use + LP_OP(cmp), RSI_LP and R8_LP on dep_mutex pointer. Load + __vdso_clock_gettime pointer into RAX_LP. + (__gcc_personality_v0): Replace 8-byte data alignment with + LP_SIZE alignment and .quad with ASM_ADDR. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Use + LP_OP(cmp), RSI_LP and R8_LP on dep_mutex pointer. Load + __vdso_clock_gettime pointer into RAX_LP. + (__gcc_personality_v0): Replace 8-byte data alignment with + LP_SIZE alignment and .quad with ASM_ADDR. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Use + LP_OP(cmp) and R8_LP on dep_mutex pointer. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/cancellation.S: Use LP_OP(mov) + to update pointer in memory. Load pointer into RDI_LP. + +2012-05-15 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h + (LLL_STUB_UNWIND_INFO_START): Align label to LP_SIZE instead + of 8. + (LLL_STUB_UNWIND_INFO_END): Likewise. + (lll_timedlock): Load timeout pointer into RDX_LP. + (lll_robust_timedlock): Likewise. + +2012-05-15 Siddhesh Poyarekar <siddhesh@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + [BZ #13613] + * Makefile (tests): Add test cases. + * descr.h (struct pthread): Add a comment describing multiple_threads. + * pthreadP.h (__pthread_multiple_threads): Expand comment to include + single-process case. + * pthread_cancel.c (pthread_cancel): Enable multiple_threads + before setting cancelstate of the thread. + * sysdeps/unix/sysv/linux/libc_multiple_threads.c + (__libc_multiple_threads): Add explanatory comment. + * tst-cancel-self-cancelstate.c: New test case. + * tst-cancel-self-canceltype.c: Likewise. + * tst-cancel-self-cleanup.c: Supporting file for test cases. + * tst-cancel-self-testcancel.c: New test case. + * tst-cancel-self.c: Likewise. + * vars.c: Expand comment to include single-process case. + +2012-05-14 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/x86_64/tls.h: Don't include <bits/wordsize.h>. + (tcbhead_t): Remove __x86_64__ check. Align rtld_savespace_sse + to 32 bytes. + +2012-05-14 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/pthread/pthread.h (__PTHREAD_RWLOCK_INT_FLAGS_SHARED): + New. + (PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP): Check + __PTHREAD_RWLOCK_INT_FLAGS_SHARED instead of __WORDSIZE. + +2012-05-14 H.J. Lu <hongjiu.lu@intel.com> + + * shlib-versions: Move x86_64-.*-linux.* entry to ... + * sysdeps/x86_64/64/shlib-versions: Here. New file. + * sysdeps/x86_64/x32/shlib-versions: New file. + +2012-05-14 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Define x32 + __SIZEOF_PTHREAD_XXX_T. + (__pthread_internal_list): Check __x86_64__ instead of __WORDSIZE. + (pthread_mutex_t): Likewise. + (pthread_rwlock_t): Likewise. + (__PTHREAD_RWLOCK_INT_FLAGS_SHARED): New. Defined if __x86_64__ + is defined. + 2012-05-11 H.J. Lu <hongjiu.lu@intel.com> * sysdeps/x86_64/x32/tls.h: New file. diff --git a/libc/nptl/DESIGN-systemtap-probes.txt b/libc/nptl/DESIGN-systemtap-probes.txt new file mode 100644 index 000000000..16d7c4513 --- /dev/null +++ b/libc/nptl/DESIGN-systemtap-probes.txt @@ -0,0 +1,89 @@ +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 = pointer (pthread_t*) to thread + arg2 = pointer (pthread_attr_t*) to attr + arg3 = pointer (void *) to start_routine + arg4 = 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 succ. return of pthread_mutex_lock + arg1 = address of mutex lock +mutex_timedlock_acquired - probe for succ. return of pthread_mutex_timedlock + arg1 = address of mutex lock +mutex_entry - probe for entry to the pthread_mutex_lock function + arg1 = address of mutex lock +mutex_timedlock_entry - probe for entry to the pthread_mutex_timedlock function + arg1 = address of mutex lock, arg2 = address of timespec +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 +wrlock_acquire_write - probe for pthread_rwlock_wrlock (after getting the lock) + 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_lock_wait - probe in low-level (assembly language) locking code, only fired + when futex/FUTEX_WAIT is called (i.e. when trying to acquire a + contented lock) + arg1 = pointer to futex + arg2 = flags passed to the futex system call +lll_lock_wait_private - probe in low-level (assembly language) locking code, + only fired when futex/FUTEX_WAIT is called (i.e. when + trying to acquire a contented lock) + arg1 = pointer to futex + +lll_futex_wake - probe in low-level (assembly language) locking code, only fired + when futex (FUTEX_WAKE) is called + arg1 = pointer to futex + arg2 = number of processes to wake + arg3 = additional flags + +Condition variable Probes +========================= +cond_init - probe for pthread_cond_init + arg1 = condition + arg2 = 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/libc/nptl/Makefile b/libc/nptl/Makefile index b715304af..b7ecef547 100644 --- a/libc/nptl/Makefile +++ b/libc/nptl/Makefile @@ -240,6 +240,8 @@ tests = tst-typesizes \ tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \ tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \ tst-cancel21 tst-cancel22 tst-cancel23 tst-cancel25 \ + tst-cancel-self tst-cancel-self-cancelstate \ + tst-cancel-self-canceltype tst-cancel-self-testcancel \ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \ tst-flock1 tst-flock2 \ tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \ diff --git a/libc/nptl/descr.h b/libc/nptl/descr.h index c2fabeb1a..60d2d22e7 100644 --- a/libc/nptl/descr.h +++ b/libc/nptl/descr.h @@ -131,6 +131,21 @@ struct pthread #else struct { + /* multiple_threads is enabled either when the process has spawned at + least one thread or when a single-threaded process cancels itself. + This enables additional code to introduce locking before doing some + compare_and_exchange operations and also enable cancellation points. + The concepts of multiple threads and cancellation points ideally + should be separate, since it is not necessary for multiple threads to + have been created for cancellation points to be enabled, as is the + case is when single-threaded process cancels itself. + + Since enabling multiple_threads enables additional code in + cancellation points and compare_and_exchange operations, there is a + potential for an unneeded performance hit when it is enabled in a + single-threaded, self-canceling process. This is OK though, since a + single-threaded process will enable async cancellation only when it + looks to cancel itself and is hence going to end anyway. */ int multiple_threads; int gscope_flag; # ifndef __ASSUME_PRIVATE_FUTEX diff --git a/libc/nptl/pthreadP.h b/libc/nptl/pthreadP.h index 68c690e88..6427e3d2e 100644 --- a/libc/nptl/pthreadP.h +++ b/libc/nptl/pthreadP.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007, 2009, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -378,7 +378,9 @@ extern int *__libc_pthread_init (unsigned long int *ptr, const struct pthread_functions *functions) internal_function; -/* Variable set to a nonzero value if more than one thread runs or ran. */ +/* Variable set to a nonzero value either if more than one thread runs or ran, + or if a single-threaded process is trying to cancel itself. See + nptl/descr.h for more context on the single-threaded process case. */ extern int __pthread_multiple_threads attribute_hidden; /* Pointer to the corresponding variable in libc. */ extern int *__libc_multiple_threads_ptr attribute_hidden; @@ -580,15 +582,4 @@ extern void __wait_lookup_done (void) attribute_hidden; # define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name); #endif - -#ifndef __NR_set_robust_list -/* XXX For the time being... Once we can rely on the kernel headers - having the definition remove these lines. */ -# if defined __i386__ -# define __NR_set_robust_list 311 -# elif defined __x86_64__ -# define __NR_set_robust_list 273 -# endif -#endif - #endif /* pthreadP.h */ diff --git a/libc/nptl/pthread_cancel.c b/libc/nptl/pthread_cancel.c index 249aa1109..1bfca6358 100644 --- a/libc/nptl/pthread_cancel.c +++ b/libc/nptl/pthread_cancel.c @@ -95,6 +95,14 @@ pthread_cancel (th) break; } + + /* A single-threaded process should be able to kill itself, since there is + nothing in the POSIX specification that says that it cannot. So we set + multiple_threads to true so that cancellation points get executed. */ + THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); +#ifndef TLS_MULTIPLE_THREADS_IN_TCB + __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; +#endif } /* Mark the thread as canceled. This has to be done atomically since other bits could be modified as well. */ diff --git a/libc/nptl/pthread_cond_broadcast.c b/libc/nptl/pthread_cond_broadcast.c index 9b67f755f..7bc76ac0e 100644 --- a/libc/nptl/pthread_cond_broadcast.c +++ b/libc/nptl/pthread_cond_broadcast.c @@ -22,6 +22,7 @@ #include <lowlevellock.h> #include <pthread.h> #include <pthreadP.h> +#include <stap-probe.h> #include <shlib-compat.h> #include <kernel-features.h> @@ -31,6 +32,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/libc/nptl/pthread_cond_destroy.c b/libc/nptl/pthread_cond_destroy.c index 0f03b294b..5f57b563c 100644 --- a/libc/nptl/pthread_cond_destroy.c +++ b/libc/nptl/pthread_cond_destroy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -19,6 +19,7 @@ #include <errno.h> #include <shlib-compat.h> #include "pthreadP.h" +#include <stap-probe.h> int @@ -28,6 +29,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); @@ -50,13 +53,13 @@ __pthread_cond_destroy (cond) if (nwaiters >= (1 << COND_NWAITERS_SHIFT)) { /* Wake everybody on the associated mutex in case there are - threads that have been requeued to it. - Without this, pthread_cond_destroy could block potentially - for a long time or forever, as it would depend on other - thread's using the mutex. - When all threads waiting on the mutex are woken up, pthread_cond_wait - only waits for threads to acquire and release the internal - condvar lock. */ + threads that have been requeued to it. + Without this, pthread_cond_destroy could block potentially + for a long time or forever, as it would depend on other + thread's using the mutex. + When all threads waiting on the mutex are woken up, pthread_cond_wait + only waits for threads to acquire and release the internal + condvar lock. */ if (cond->__data.__mutex != NULL && cond->__data.__mutex != (void *) ~0l) { diff --git a/libc/nptl/pthread_cond_init.c b/libc/nptl/pthread_cond_init.c index dcc6b3c14..554fe6fed 100644 --- a/libc/nptl/pthread_cond_init.c +++ b/libc/nptl/pthread_cond_init.c @@ -1,5 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 - Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -19,6 +18,7 @@ #include <shlib-compat.h> #include "pthreadP.h" +#include <stap-probe.h> int @@ -41,6 +41,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/libc/nptl/pthread_cond_signal.c b/libc/nptl/pthread_cond_signal.c index e4716f2b0..063dcbc32 100644 --- a/libc/nptl/pthread_cond_signal.c +++ b/libc/nptl/pthread_cond_signal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -25,6 +25,7 @@ #include <shlib-compat.h> #include <kernel-features.h> +#include <stap-probe.h> int @@ -34,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/libc/nptl/pthread_cond_wait.c b/libc/nptl/pthread_cond_wait.c index c05d06c14..35505d9a1 100644 --- a/libc/nptl/pthread_cond_wait.c +++ b/libc/nptl/pthread_cond_wait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2006,2007,2011 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -24,6 +24,7 @@ #include <pthreadP.h> #include <shlib-compat.h> +#include <stap-probe.h> struct _condvar_cleanup_buffer @@ -43,7 +44,7 @@ __condvar_cleanup (void *arg) (struct _condvar_cleanup_buffer *) arg; unsigned int destroying; int pshared = (cbuffer->cond->__data.__mutex == (void *) ~0l) - ? LLL_SHARED : LLL_PRIVATE; + ? LLL_SHARED : LLL_PRIVATE; /* We are going to modify shared data. */ lll_lock (cbuffer->cond->__data.__lock, pshared); @@ -98,7 +99,9 @@ __pthread_cond_wait (cond, mutex) struct _condvar_cleanup_buffer cbuffer; int err; int pshared = (cond->__data.__mutex == (void *) ~0l) - ? LLL_SHARED : LLL_PRIVATE; + ? 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/libc/nptl/pthread_create.c b/libc/nptl/pthread_create.c index 561682588..96ca51f4e 100644 --- a/libc/nptl/pthread_create.c +++ b/libc/nptl/pthread_create.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007,2008,2009,2010,2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -32,6 +32,8 @@ #include <shlib-compat.h> +#include <stap-probe.h> + /* Local function to start thread and handle cleanup. */ static int start_thread (void *arg); @@ -302,6 +304,8 @@ start_thread (void *arg) CANCEL_RESET (oldtype); } + LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg); + /* Run the code the user provided. */ #ifdef CALL_THREAD_FCT THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd)); @@ -561,6 +565,8 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg) /* Pass the descriptor to the caller. */ *newthread = (pthread_t) pd; + LIBC_PROBE (pthread_create, 4, newthread, attr, start_routine, arg); + /* Start the thread. */ return create_thread (pd, iattr, STACK_VARIABLES_ARGS); } diff --git a/libc/nptl/pthread_getattr_np.c b/libc/nptl/pthread_getattr_np.c index f1268dd82..75d717bb1 100644 --- a/libc/nptl/pthread_getattr_np.c +++ b/libc/nptl/pthread_getattr_np.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004, 2006, 2007, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -84,6 +84,18 @@ pthread_getattr_np (thread_id, attr) ret = errno; else { + /* We consider the main process stack to have ended with + the page containing __libc_stack_end. There is stuff below + it in the stack too, like the program arguments, environment + variables and auxv info, but we ignore those pages when + returning size so that the output is consistent when the + stack is marked executable due to a loaded DSO requiring + it. */ + void *stack_end = (void *) ((uintptr_t) __libc_stack_end + & -(uintptr_t) GLRO(dl_pagesize)); +#if _STACK_GROWS_DOWN + stack_end += GLRO(dl_pagesize); +#endif /* We need no locking. */ __fsetlocking (fp, FSETLOCKING_BYCALLER); @@ -109,7 +121,7 @@ pthread_getattr_np (thread_id, attr) { /* Found the entry. Now we have the info we need. */ iattr->stacksize = rl.rlim_cur; - iattr->stackaddr = (void *) to; + iattr->stackaddr = stack_end; /* The limit might be too high. */ if ((size_t) iattr->stacksize diff --git a/libc/nptl/pthread_join.c b/libc/nptl/pthread_join.c index b8834cc9c..bf1a01dbc 100644 --- a/libc/nptl/pthread_join.c +++ b/libc/nptl/pthread_join.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -22,6 +22,8 @@ #include <atomic.h> #include "pthreadP.h" +#include <stap-probe.h> + static void cleanup (void *arg) @@ -54,6 +56,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. */ @@ -109,5 +113,7 @@ pthread_join (threadid, thread_return) __free_tcb (pd); } + LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd->result); + return result; } diff --git a/libc/nptl/pthread_mutex_destroy.c b/libc/nptl/pthread_mutex_destroy.c index 408b16a7b..107ec8e4e 100644 --- a/libc/nptl/pthread_mutex_destroy.c +++ b/libc/nptl/pthread_mutex_destroy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -19,11 +19,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/libc/nptl/pthread_mutex_init.c b/libc/nptl/pthread_mutex_init.c index 0596e07f3..6536e44d0 100644 --- a/libc/nptl/pthread_mutex_init.c +++ b/libc/nptl/pthread_mutex_init.c @@ -1,5 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 - Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +22,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. */ @@ -134,6 +135,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/libc/nptl/pthread_mutex_lock.c b/libc/nptl/pthread_mutex_lock.c index c747355e4..2b30bad48 100644 --- a/libc/nptl/pthread_mutex_lock.c +++ b/libc/nptl/pthread_mutex_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +23,7 @@ #include <not-cancel.h> #include "pthreadP.h" #include <lowlevellock.h> +#include <stap-probe.h> #ifndef LLL_MUTEX_LOCK @@ -47,6 +48,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); @@ -126,6 +130,8 @@ __pthread_mutex_lock (mutex) ++mutex->__data.__nusers; #endif + LIBC_PROBE (mutex_acquired, 1, mutex); + return 0; } @@ -466,6 +472,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/libc/nptl/pthread_mutex_timedlock.c b/libc/nptl/pthread_mutex_timedlock.c index b7f34d4fd..52fa74c0d 100644 --- a/libc/nptl/pthread_mutex_timedlock.c +++ b/libc/nptl/pthread_mutex_timedlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +23,8 @@ #include <lowlevellock.h> #include <not-cancel.h> +#include <stap-probe.h> + int pthread_mutex_timedlock (mutex, abstime) @@ -33,6 +35,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. */ @@ -171,6 +175,8 @@ pthread_mutex_timedlock (mutex, abstime) ++mutex->__data.__count; + LIBC_PROBE (mutex_timedlock_acquired, 1, mutex); + return 0; } } @@ -241,6 +247,8 @@ pthread_mutex_timedlock (mutex, abstime) ++mutex->__data.__count; + LIBC_PROBE (mutex_timedlock_acquired, 1, mutex); + return 0; } } @@ -376,6 +384,8 @@ pthread_mutex_timedlock (mutex, abstime) ++mutex->__data.__count; + LIBC_PROBE (mutex_timedlock_acquired, 1, mutex); + return 0; } } @@ -476,6 +486,8 @@ pthread_mutex_timedlock (mutex, abstime) /* Record the ownership. */ mutex->__data.__owner = id; ++mutex->__data.__nusers; + + LIBC_PROBE (mutex_timedlock_acquired, 1, mutex); } out: diff --git a/libc/nptl/pthread_mutex_unlock.c b/libc/nptl/pthread_mutex_unlock.c index 0f35f6203..aa8ecbd58 100644 --- a/libc/nptl/pthread_mutex_unlock.c +++ b/libc/nptl/pthread_mutex_unlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005-2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,6 +21,7 @@ #include <stdlib.h> #include "pthreadP.h" #include <lowlevellock.h> +#include <stap-probe.h> static int internal_function @@ -49,6 +50,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)) @@ -271,6 +275,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: @@ -278,6 +285,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr) return EINVAL; } + LIBC_PROBE (mutex_release, 1, mutex); return 0; } diff --git a/libc/nptl/pthread_rwlock_destroy.c b/libc/nptl/pthread_rwlock_destroy.c index 606833acf..78abe5ece 100644 --- a/libc/nptl/pthread_rwlock_destroy.c +++ b/libc/nptl/pthread_rwlock_destroy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -17,12 +17,15 @@ <http://www.gnu.org/licenses/>. */ #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/libc/nptl/pthread_rwlock_rdlock.c b/libc/nptl/pthread_rwlock_rdlock.c index 4aa1c5bb5..14688e298 100644 --- a/libc/nptl/pthread_rwlock_rdlock.c +++ b/libc/nptl/pthread_rwlock_rdlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2007,2011 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -21,6 +21,7 @@ #include <lowlevellock.h> #include <pthread.h> #include <pthreadP.h> +#include <stap-probe.h> /* Acquire read lock for RWLOCK. */ @@ -30,6 +31,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); @@ -48,6 +51,8 @@ __pthread_rwlock_rdlock (rwlock) --rwlock->__data.__nr_readers; result = EAGAIN; } + else + LIBC_PROBE (rdlock_acquire_read, 1, rwlock); break; } diff --git a/libc/nptl/pthread_rwlock_unlock.c b/libc/nptl/pthread_rwlock_unlock.c index 15418c82f..a727d89b9 100644 --- a/libc/nptl/pthread_rwlock_unlock.c +++ b/libc/nptl/pthread_rwlock_unlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -21,11 +21,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/libc/nptl/pthread_rwlock_wrlock.c b/libc/nptl/pthread_rwlock_wrlock.c index a64548787..6d8fb93c3 100644 --- a/libc/nptl/pthread_rwlock_wrlock.c +++ b/libc/nptl/pthread_rwlock_wrlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2007,2011 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -21,6 +21,7 @@ #include <lowlevellock.h> #include <pthread.h> #include <pthreadP.h> +#include <stap-probe.h> /* Acquire write lock for RWLOCK. */ @@ -30,6 +31,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); @@ -40,6 +43,8 @@ __pthread_rwlock_wrlock (rwlock) { /* Mark self as writer. */ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); + + LIBC_PROBE (wrlock_acquire_write, 1, rwlock); break; } diff --git a/libc/nptl/shlib-versions b/libc/nptl/shlib-versions index ee86161fd..e49e7ca41 100644 --- a/libc/nptl/shlib-versions +++ b/libc/nptl/shlib-versions @@ -1,6 +1,5 @@ sparc64.*-.*-linux.* libpthread=0 GLIBC_2.2 sh.*-.*-linux.* libpthread=0 GLIBC_2.2 s390x-.*-linux.* libpthread=0 GLIBC_2.2 -x86_64-.*-linux.* libpthread=0 GLIBC_2.2.5 powerpc64-.*-linux.* libpthread=0 GLIBC_2.3 .*-.*-linux.* libpthread=0 diff --git a/libc/nptl/sysdeps/pthread/pthread.h b/libc/nptl/sysdeps/pthread/pthread.h index fcc0ce846..88c7c257a 100644 --- a/libc/nptl/sysdeps/pthread/pthread.h +++ b/libc/nptl/sysdeps/pthread/pthread.h @@ -118,11 +118,20 @@ enum PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP }; +/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t + has the shared field. All 64-bit architectures have the shared field + in pthread_rwlock_t. */ +#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED +# if __WORDSIZE == 64 +# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1 +# endif +#endif + /* Read-write lock initializers. */ # define PTHREAD_RWLOCK_INITIALIZER \ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } # ifdef __USE_GNU -# if __WORDSIZE == 64 +# ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } diff --git a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S index fe6d4b678..7c3212cb6 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004,2006,2007,2009,2010 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,6 +21,8 @@ #include <kernel-features.h> #include <lowlevellock.h> +#include <stap-probe.h> + .text #ifdef __ASSUME_PRIVATE_FUTEX @@ -90,7 +92,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S index 71a668686..99f9bc901 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2006,2007,2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +23,7 @@ #include <kernel-features.h> #include <pthread-pi-defines.h> #include <pthread-errnos.h> +#include <stap-probe.h> .text @@ -48,6 +49,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S index 2af611aed..e204805a9 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2005,2007,2009,2010 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,7 +23,7 @@ #include <kernel-features.h> #include <pthread-pi-defines.h> #include <pthread-errnos.h> - +#include <stap-probe.h> .text @@ -44,6 +44,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S index ff3da370d..8170ab321 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004,2006-2007,2009,2010 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,7 +23,7 @@ #include <pthread-errnos.h> #include <pthread-pi-defines.h> #include <kernel-features.h> - +#include <stap-probe.h> .text @@ -60,6 +60,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S index 1d7e75105..2ae7af261 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S @@ -1,5 +1,4 @@ -/* Copyright (C) 2002-2004,2006-2007,2009,2010,2012 - Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -25,6 +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_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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S index 156fce868..ebbe80971 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -22,6 +22,7 @@ #include <pthread-errnos.h> #include <kernel-features.h> +#include <stap-probe.h> .text @@ -40,6 +41,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S index 3994b06c0..d30e93a2d 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -22,6 +22,7 @@ #include <pthread-errnos.h> #include <kernel-features.h> +#include <stap-probe.h> .text @@ -40,6 +41,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/libc/nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h b/libc/nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h index a2fa3ee21..12533438c 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h @@ -1,5 +1,5 @@ /* System-specific settings for dynamic linker code. IA-32 version. - Copyright (C) 2002, 2003, 2008 Free Software Foundation, Inc. + Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -58,9 +58,7 @@ extern void _dl_sysinfo_int80 (void) attribute_hidden; #endif -/* The _dl_discover_osversion function is so far only needed in sysconf - to check for kernels later than 2.6.23. */ -#if !defined __ASSEMBLER__ && __LINUX_KERNEL_VERSION < 0x020617 +#ifndef __ASSEMBLER__ /* Get version of the OS. */ extern int _dl_discover_osversion (void) attribute_hidden; # define HAVE_DL_DISCOVER_OSVERSION 1 diff --git a/libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h index 497d4739b..3d805ff43 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h +++ b/libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004, 2006-2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -19,6 +19,8 @@ #ifndef _LOWLEVELLOCK_H #define _LOWLEVELLOCK_H 1 +#include <stap-probe.h> + #ifndef __ASSEMBLER__ # include <time.h> # include <sys/param.h> @@ -225,6 +227,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 \ diff --git a/libc/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c b/libc/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c index 7fffb0d80..459b8cf7c 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c +++ b/libc/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c @@ -20,6 +20,9 @@ #ifndef NOT_IN_libc # ifndef TLS_MULTIPLE_THREADS_IN_TCB +/* Variable set to a nonzero value either if more than one thread runs or ran, + or if a single-threaded process is trying to cancel itself. See + nptl/descr.h for more context on the single-threaded process case. */ int __libc_multiple_threads attribute_hidden; # endif #endif diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h index e05b8f5c3..e22947f34 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h @@ -20,16 +20,28 @@ #include <bits/wordsize.h> -#if __WORDSIZE == 64 -# define __SIZEOF_PTHREAD_ATTR_T 56 -# define __SIZEOF_PTHREAD_MUTEX_T 40 -# define __SIZEOF_PTHREAD_MUTEXATTR_T 4 -# define __SIZEOF_PTHREAD_COND_T 48 -# define __SIZEOF_PTHREAD_CONDATTR_T 4 -# define __SIZEOF_PTHREAD_RWLOCK_T 56 -# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 -# define __SIZEOF_PTHREAD_BARRIER_T 32 -# define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +#ifdef __x86_64__ +# if __WORDSIZE == 64 +# define __SIZEOF_PTHREAD_ATTR_T 56 +# define __SIZEOF_PTHREAD_MUTEX_T 40 +# define __SIZEOF_PTHREAD_MUTEXATTR_T 4 +# define __SIZEOF_PTHREAD_COND_T 48 +# define __SIZEOF_PTHREAD_CONDATTR_T 4 +# define __SIZEOF_PTHREAD_RWLOCK_T 56 +# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 +# define __SIZEOF_PTHREAD_BARRIER_T 32 +# define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +# else +# define __SIZEOF_PTHREAD_ATTR_T 32 +# define __SIZEOF_PTHREAD_MUTEX_T 32 +# define __SIZEOF_PTHREAD_MUTEXATTR_T 4 +# define __SIZEOF_PTHREAD_COND_T 48 +# define __SIZEOF_PTHREAD_CONDATTR_T 4 +# define __SIZEOF_PTHREAD_RWLOCK_T 44 +# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 +# define __SIZEOF_PTHREAD_BARRIER_T 20 +# define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +# endif #else # define __SIZEOF_PTHREAD_ATTR_T 36 # define __SIZEOF_PTHREAD_MUTEX_T 24 @@ -59,7 +71,7 @@ typedef union pthread_attr_t pthread_attr_t; #endif -#if __WORDSIZE == 64 +#ifdef __x86_64__ typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; @@ -82,13 +94,13 @@ typedef union int __lock; unsigned int __count; int __owner; -#if __WORDSIZE == 64 +#ifdef __x86_64__ unsigned int __nusers; #endif /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; -#if __WORDSIZE == 64 +#ifdef __x86_64__ int __spins; __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 @@ -151,7 +163,7 @@ typedef int pthread_once_t; structure of the attribute type is not exposed on purpose. */ typedef union { -# if __WORDSIZE == 64 +# ifdef __x86_64__ struct { int __lock; @@ -167,6 +179,7 @@ typedef union /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ unsigned int __flags; +# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1 } __data; # else struct diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S index d7c7e80ce..31bb08b37 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S @@ -72,10 +72,10 @@ ENTRY(__pthread_enable_asynccancel) 3: subq $8, %rsp cfi_adjust_cfa_offset(8) - movq $TCB_PTHREAD_CANCELED, %fs:RESULT + LP_OP(mov) $TCB_PTHREAD_CANCELED, %fs:RESULT lock orl $TCB_EXITING_BITMASK, %fs:CANCELHANDLING - movq %fs:CLEANUP_JMP_BUF, %rdi + mov %fs:CLEANUP_JMP_BUF, %RDI_LP #ifdef SHARED call __pthread_unwind@PLT #else @@ -106,7 +106,7 @@ ENTRY(__pthread_disable_asynccancel) /* Performance doesn't matter in this loop. We will delay until the thread is canceled. And we will unlikely enter the loop twice. */ -4: movq %fs:0, %rdi +4: mov %fs:0, %RDI_LP movl $__NR_futex, %eax xorq %r10, %r10 addq $CANCELHANDLING, %rdi diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S index b7bfc3706..dc9542102 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007, 2009, 2010, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,6 +21,8 @@ #include <kernel-features.h> #include <lowlevellock.h> +#include <stap-probe.h> + .text #ifdef __ASSUME_PRIVATE_FUTEX @@ -86,7 +88,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, %rdi) + movl $SYS_futex, %eax syscall 2: movl %edx, %eax @@ -125,7 +128,8 @@ __lll_lock_wait: cmpl %edx, %eax /* NB: %edx == 2 */ jne 2f -1: movl $SYS_futex, %eax +1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi) + movl $SYS_futex, %eax syscall 2: movl %edx, %eax diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index dada21c2a..3686970f0 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004, 2006-2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -19,6 +19,8 @@ #ifndef _LOWLEVELLOCK_H #define _LOWLEVELLOCK_H 1 +#include <stap-probe.h> + #ifndef __ASSEMBLER__ # include <time.h> # include <sys/param.h> @@ -119,7 +121,7 @@ ".byte 0x12 # DW_CFA_def_cfa_sf\n\t" \ ".uleb128 0x7\n\t" \ ".sleb128 16\n\t" \ - ".align 8\n" \ + ".align " LP_SIZE "\n" \ "9:\t" ".long 23f-10f # FDE Length\n" \ "10:\t" ".long 10b-7b # FDE CIE offset\n\t" \ ".long 1b-. # FDE initial location\n\t" \ @@ -166,7 +168,7 @@ ".uleb128 22f-21f\n" \ "21:\t" ".byte 0x80 # DW_OP_breg16\n\t" \ ".sleb128 4b-5b\n" \ -"22:\t" ".align 8\n" \ +"22:\t" ".align " LP_SIZE "\n" \ "23:\t" ".previous\n" /* Unwind info for @@ -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 ("syscall" \ : "=a" (__ignore) \ : "0" (SYS_futex), "D" (futex), \ @@ -285,7 +288,7 @@ LLL_STUB_UNWIND_INFO_END "je 0f\n\t" \ "lock; cmpxchgl %4, %2\n\t" \ "jnz 1f\n\t" \ - "jmp 24f\n" \ + "jmp 24f\n" \ "0:\tcmpxchgl %4, %2\n\t" \ "jnz 1f\n\t" #endif @@ -298,10 +301,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_lock_%=, @function\n" \ "_L_lock_%=:\n" \ - "1:\tleaq %2, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %2, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_lock_wait_private\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_lock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -316,10 +319,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_lock_%=, @function\n" \ "_L_lock_%=:\n" \ - "1:\tleaq %2, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %2, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_lock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_lock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -338,10 +341,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_robust_lock_%=, @function\n" \ "_L_robust_lock_%=:\n" \ - "1:\tleaq %2, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %2, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_robust_lock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_robust_lock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -361,10 +364,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_cond_lock_%=, @function\n" \ "_L_cond_lock_%=:\n" \ - "1:\tleaq %2, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %2, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_lock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_cond_lock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -383,10 +386,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_robust_cond_lock_%=, @function\n" \ "_L_robust_cond_lock_%=:\n" \ - "1:\tleaq %2, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %2, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_robust_lock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_robust_cond_lock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -406,11 +409,11 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_timedlock_%=, @function\n" \ "_L_timedlock_%=:\n" \ - "1:\tleaq %4, %%rdi\n" \ - "0:\tmovq %8, %%rdx\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %4, %%" RDI_LP "\n" \ + "0:\tmov %8, %%" RDX_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_timedlock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_timedlock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -430,11 +433,11 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_robust_timedlock_%=, @function\n" \ "_L_robust_timedlock_%=:\n" \ - "1:\tleaq %4, %%rdi\n" \ - "0:\tmovq %8, %%rdx\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %4, %%" RDI_LP "\n" \ + "0:\tmov %8, %%" RDX_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_robust_timedlock_wait\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_robust_timedlock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -468,10 +471,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_unlock_%=, @function\n" \ "_L_unlock_%=:\n" \ - "1:\tleaq %0, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %0, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_unlock_wake_private\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_unlock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -485,10 +488,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_unlock_%=, @function\n" \ "_L_unlock_%=:\n" \ - "1:\tleaq %0, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %0, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_unlock_wake\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_unlock_%=, 6b-1b\n\t" \ ".previous\n" \ @@ -508,10 +511,10 @@ LLL_STUB_UNWIND_INFO_END ".subsection 1\n\t" \ ".type _L_robust_unlock_%=, @function\n" \ "_L_robust_unlock_%=:\n" \ - "1:\tleaq %0, %%rdi\n" \ - "2:\tsubq $128, %%rsp\n" \ + "1:\tlea %0, %%" RDI_LP "\n" \ + "2:\tsub $128, %%" RSP_LP "\n" \ "3:\tcallq __lll_unlock_wake\n" \ - "4:\taddq $128, %%rsp\n" \ + "4:\tadd $128, %%" RSP_LP "\n" \ "5:\tjmp 24f\n" \ "6:\t.size _L_robust_unlock_%=, 6b-1b\n\t" \ ".previous\n" \ diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S index 0db3af1cc..67ff5fc4c 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S @@ -1,5 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009 - Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -24,7 +23,7 @@ #include <kernel-features.h> #include <pthread-pi-defines.h> #include <pthread-errnos.h> - +#include <stap-probe.h> .text @@ -34,6 +33,8 @@ .align 16 __pthread_cond_broadcast: + LIBC_PROBE (cond_broadcast, 1, %rdi) + /* Get internal lock. */ movl $1, %esi xorl %eax, %eax @@ -59,14 +60,14 @@ __pthread_cond_broadcast: incl broadcast_seq-cond_futex(%rdi) /* Get the address of the mutex used. */ - movq dep_mutex-cond_futex(%rdi), %r8 + mov dep_mutex-cond_futex(%rdi), %R8_LP /* Unlock. */ LOCK decl cond_lock-cond_futex(%rdi) jne 7f -8: cmpq $-1, %r8 +8: cmp $-1, %R8_LP je 9f /* Do not use requeue for pshared condvars. */ @@ -128,7 +129,7 @@ __pthread_cond_broadcast: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -140,7 +141,7 @@ __pthread_cond_broadcast: /* Unlock in loop requires wakeup. */ 5: addq $cond_lock-cond_futex, %rdi - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -149,7 +150,7 @@ __pthread_cond_broadcast: /* Unlock in loop requires wakeup. */ 7: addq $cond_lock-cond_futex, %rdi - cmpq $-1, %r8 + cmp $-1, %R8_LP movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -158,7 +159,7 @@ __pthread_cond_broadcast: jmp 8b 9: /* The futex requeue functionality is not available. */ - cmpq $-1, %r8 + cmp $-1, %R8_LP movl $0x7fffffff, %edx #ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAKE, %eax diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S index bb9a8134d..3bff19bd1 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +23,7 @@ #include <pthread-pi-defines.h> #include <kernel-features.h> #include <pthread-errnos.h> +#include <stap-probe.h> .text @@ -33,6 +34,8 @@ .align 16 __pthread_cond_signal: + LIBC_PROBE (cond_signal, 1, %rdi) + /* Get internal lock. */ movq %rdi, %r8 movl $1, %esi @@ -55,14 +58,14 @@ __pthread_cond_signal: addl $1, (%rdi) /* Wake up one thread. */ - cmpq $-1, dep_mutex(%r8) + LP_OP(cmp) $-1, dep_mutex(%r8) movl $FUTEX_WAKE_OP, %esi movl $1, %edx movl $SYS_futex, %eax je 8f /* Get the address of the mutex used. */ - movq dep_mutex(%r8), %rcx + mov dep_mutex(%r8), %RCX_LP movl MUTEX_KIND(%rcx), %r11d andl $(ROBUST_BIT|PI_BIT), %r11d cmpl $PI_BIT, %r11d @@ -134,7 +137,7 @@ __pthread_cond_signal: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -150,7 +153,7 @@ __pthread_cond_signal: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S index cdc2bf68b..50e1ffd55 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2005,2007,2009,2010,2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -22,6 +22,7 @@ #include <lowlevelcond.h> #include <pthread-pi-defines.h> #include <pthread-errnos.h> +#include <stap-probe.h> #include <kernel-features.h> @@ -67,6 +68,8 @@ __pthread_cond_timedwait: cfi_adjust_cfa_offset(FRAME_SIZE) cfi_remember_state + LIBC_PROBE (cond_timedwait, 3, %rdi, %rsi, %rdx) + cmpq $1000000000, 8(%rdx) movl $EINVAL, %eax jae 48f @@ -89,7 +92,7 @@ __pthread_cond_timedwait: +--------------------------+ */ - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) /* Prepare structure passed to cancellation handler. */ movq %rdi, 8(%rsp) @@ -97,7 +100,7 @@ __pthread_cond_timedwait: movq %rdx, %r13 je 22f - movq %rsi, dep_mutex(%rdi) + mov %RSI_LP, dep_mutex(%rdi) 22: xorl %r15d, %r15d @@ -163,10 +166,10 @@ __pthread_cond_timedwait: movq %r13, %r10 movl $FUTEX_WAIT_BITSET, %esi - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) je 60f - movq dep_mutex(%rdi), %r8 + mov dep_mutex(%rdi), %R8_LP /* Requeue to a non-robust PI mutex if the PI bit is set and the robust bit is not set. */ movl MUTEX_KIND(%r8), %eax @@ -268,7 +271,7 @@ __pthread_cond_timedwait: jne 55f addq $cond_nwaiters, %rdi - cmpq $-1, dep_mutex-cond_nwaiters(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_nwaiters(%rdi) movl $1, %edx #ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAKE, %eax @@ -331,7 +334,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -343,7 +346,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -355,7 +358,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -370,7 +373,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -391,7 +394,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -446,9 +449,9 @@ __pthread_cond_timedwait: kernel. */ leaq 32(%rsp), %rsi # ifdef SHARED - movq __vdso_clock_gettime@GOTPCREL(%rip), %rax - movq (%rax), %rax - PTR_DEMANGLE (%rax) + mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP + mov (%rax), %RAX_LP + PTR_DEMANGLE (%RAX_LP) call *%rax # else movl $__NR_clock_gettime, %eax @@ -508,7 +511,7 @@ __pthread_cond_timedwait: movl %eax, (%rsp) leaq 32(%rsp), %r10 - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) movq %r12, %rdx # ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAIT, %eax @@ -568,7 +571,7 @@ __pthread_cond_timedwait: # if cond_lock != 0 addq $cond_lock, %rdi # endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -580,7 +583,7 @@ __pthread_cond_timedwait: # if cond_lock != 0 addq $cond_lock, %rdi # endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -592,7 +595,7 @@ __pthread_cond_timedwait: # if cond_lock != 0 addq $cond_lock, %rdi # endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -675,7 +678,7 @@ __condvar_cleanup2: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -708,7 +711,7 @@ __condvar_cleanup2: andl $~((1 << nwaiters_shift) - 1), %eax jne 4f - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) leaq cond_nwaiters(%rdi), %rdi movl $1, %edx #ifdef __ASSUME_PRIVATE_FUTEX @@ -736,7 +739,7 @@ __condvar_cleanup2: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -746,7 +749,7 @@ __condvar_cleanup2: 2: testq %r12, %r12 jnz 5f addq $cond_futex, %rdi - cmpq $-1, dep_mutex-cond_futex(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_futex(%rdi) movl $0x7fffffff, %edx #ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAKE, %eax @@ -805,9 +808,9 @@ __condvar_cleanup2: .hidden DW.ref.__gcc_personality_v0 .weak DW.ref.__gcc_personality_v0 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 + .align LP_SIZE .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 + .size DW.ref.__gcc_personality_v0, LP_SIZE DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 + ASM_ADDR __gcc_personality_v0 #endif diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S index fa0455f35..61948523a 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007, 2009, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -23,6 +23,7 @@ #include <tcb-offsets.h> #include <pthread-pi-defines.h> #include <pthread-errnos.h> +#include <stap-probe.h> #include <kernel-features.h> @@ -54,25 +55,27 @@ __pthread_cond_wait: rsp + 32 +--------------------------+ rsp + 24 | old wake_seq value | - +--------------------------+ + +--------------------------+ rsp + 16 | mutex pointer | - +--------------------------+ + +--------------------------+ rsp + 8 | condvar pointer | - +--------------------------+ + +--------------------------+ rsp + 4 | old broadcast_seq value | - +--------------------------+ + +--------------------------+ rsp + 0 | old cancellation mode | - +--------------------------+ + +--------------------------+ */ - cmpq $-1, dep_mutex(%rdi) + LIBC_PROBE (cond_wait, 2, %rdi, %rsi) + + LP_OP(cmp) $-1, dep_mutex(%rdi) - /* Prepare structure passed to cancellation handler. */ + /* Prepare structure passed to cancellation handler. */ movq %rdi, 8(%rsp) movq %rsi, 16(%rsp) je 15f - movq %rsi, dep_mutex(%rdi) + mov %RSI_LP, dep_mutex(%rdi) /* Get internal lock. */ 15: movl $1, %esi @@ -120,12 +123,12 @@ __pthread_cond_wait: movl %eax, (%rsp) xorq %r10, %r10 - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) leaq cond_futex(%rdi), %rdi movl $FUTEX_WAIT, %esi je 60f - movq dep_mutex-cond_futex(%rdi), %r8 + mov dep_mutex-cond_futex(%rdi), %R8_LP /* Requeue to a non-robust PI mutex if the PI bit is set and the robust bit is not set. */ movl MUTEX_KIND(%r8), %eax @@ -206,7 +209,7 @@ __pthread_cond_wait: jne 17f addq $cond_nwaiters, %rdi - cmpq $-1, dep_mutex-cond_nwaiters(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_nwaiters(%rdi) movl $1, %edx #ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAKE, %eax @@ -255,7 +258,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -267,7 +270,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -283,7 +286,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -298,7 +301,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -319,7 +322,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -348,7 +351,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -374,7 +377,7 @@ __pthread_cond_wait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -386,7 +389,7 @@ __pthread_cond_wait: 93: /* Set the rest of SYS_futex args for FUTEX_WAIT_REQUEUE_PI. */ xorq %r10, %r10 - movq dep_mutex(%rdi), %r8 + mov dep_mutex(%rdi), %R8_LP leaq cond_futex(%rdi), %rdi jmp 90b .LcleanupEND2: @@ -406,15 +409,15 @@ __condvar_cleanup1: rsp + 32 +--------------------------+ rsp + 24 | unused | - +--------------------------+ + +--------------------------+ rsp + 16 | mutex pointer | - +--------------------------+ + +--------------------------+ rsp + 8 | condvar pointer | - +--------------------------+ + +--------------------------+ rsp + 4 | old broadcast_seq value | - +--------------------------+ + +--------------------------+ rsp + 0 | old cancellation mode | - +--------------------------+ + +--------------------------+ */ movq %rax, 24(%rsp) @@ -434,7 +437,7 @@ __condvar_cleanup1: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -467,7 +470,7 @@ __condvar_cleanup1: andl $~((1 << nwaiters_shift) - 1), %eax jne 4f - cmpq $-1, dep_mutex(%rdi) + LP_OP(cmp) $-1, dep_mutex(%rdi) leaq cond_nwaiters(%rdi), %rdi movl $1, %edx #ifdef __ASSUME_PRIVATE_FUTEX @@ -495,7 +498,7 @@ __condvar_cleanup1: #if cond_lock != 0 addq $cond_lock, %rdi #endif - cmpq $-1, dep_mutex-cond_lock(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) movl $LLL_PRIVATE, %eax movl $LLL_SHARED, %esi cmovne %eax, %esi @@ -506,7 +509,7 @@ __condvar_cleanup1: 2: testl %ecx, %ecx jnz 5f addq $cond_futex, %rdi - cmpq $-1, dep_mutex-cond_futex(%rdi) + LP_OP(cmp) $-1, dep_mutex-cond_futex(%rdi) movl $0x7fffffff, %edx #ifdef __ASSUME_PRIVATE_FUTEX movl $FUTEX_WAKE, %eax @@ -559,9 +562,9 @@ __condvar_cleanup1: .hidden DW.ref.__gcc_personality_v0 .weak DW.ref.__gcc_personality_v0 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 + .align LP_SIZE .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 + .size DW.ref.__gcc_personality_v0, LP_SIZE DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 + ASM_ADDR __gcc_personality_v0 #endif diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S index 4dc5bacc3..d766ae7f4 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S @@ -188,9 +188,9 @@ clear_once_control: .hidden DW.ref.__gcc_personality_v0 .weak DW.ref.__gcc_personality_v0 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 + .align LP_SIZE .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 + .size DW.ref.__gcc_personality_v0, LP_SIZE DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 + ASM_ADDR __gcc_personality_v0 #endif diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S index c0761850d..abb305791 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,7 +21,7 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <kernel-features.h> - +#include <stap-probe.h> .text @@ -30,6 +30,9 @@ .align 16 __pthread_rwlock_rdlock: cfi_startproc + + LIBC_PROBE (rdlock_entry, 1, %rdi) + xorq %r10, %r10 /* Get the lock. */ diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S index b349554ed..f6a6bff09 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,7 +21,7 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <kernel-features.h> - +#include <stap-probe.h> .text @@ -30,6 +30,9 @@ .align 16 __pthread_rwlock_wrlock: cfi_startproc + + LIBC_PROBE (wrlock_entry, 1, %rdi) + xorq %r10, %r10 /* Get the lock. */ diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S index 0e0898cbb..65e715d2d 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S @@ -45,7 +45,7 @@ sem_post: #endif jnz 0b - cmpq $0, NWAITERS(%rdi) + LP_OP(cmp) $0, NWAITERS(%rdi) je 2f movl $SYS_futex, %eax diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S index a60023809..acb79dbd1 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -83,7 +83,7 @@ sem_timedwait: movq %rsi, %r10 LOCK - addq $1, NWAITERS(%rdi) + LP_OP(add) $1, NWAITERS(%rdi) .LcleanupSTART: 13: call __pthread_enable_asynccancel @@ -134,7 +134,7 @@ sem_timedwait: xorl %eax, %eax 15: LOCK - subq $1, NWAITERS(%rdi) + LP_OP(sub) $1, NWAITERS(%rdi) leaq 8(%rsp), %rsp cfi_adjust_cfa_offset(-8) @@ -189,7 +189,7 @@ sem_timedwait: movq %rsi, %r13 LOCK - addq $1, NWAITERS(%r12) + LP_OP(add) $1, NWAITERS(%r12) 7: xorl %esi, %esi movq %rsp,%rdi @@ -266,7 +266,7 @@ sem_timedwait: xorl %eax, %eax 45: LOCK - subq $1, NWAITERS(%r12) + LP_OP(sub) $1, NWAITERS(%r12) addq $STACKFRAME, %rsp cfi_adjust_cfa_offset(-STACKFRAME) @@ -304,7 +304,7 @@ sem_timedwait_cleanup: movq (%rsp), %rdi LOCK - subq $1, NWAITERS(%rdi) + LP_OP(sub) $1, NWAITERS(%rdi) movq %rax, %rdi .LcallUR: call _Unwind_Resume@PLT @@ -324,7 +324,7 @@ sem_timedwait_cleanup2: cfi_rel_offset(%r14, STACKFRAME) LOCK - subq $1, NWAITERS(%r12) + LP_OP(sub) $1, NWAITERS(%r12) movq %rax, %rdi movq STACKFRAME(%rsp), %r14 movq STACKFRAME+8(%rsp), %r13 @@ -372,9 +372,9 @@ sem_timedwait_cleanup2: .hidden DW.ref.__gcc_personality_v0 .weak DW.ref.__gcc_personality_v0 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 + .align LP_SIZE .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 + .size DW.ref.__gcc_personality_v0, LP_SIZE DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 + ASM_ADDR __gcc_personality_v0 #endif diff --git a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S index c6c6c26f8..7f911488a 100644 --- a/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S +++ b/libc/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S @@ -66,7 +66,7 @@ sem_wait: cfi_adjust_cfa_offset(8) LOCK - addq $1, NWAITERS(%rdi) + LP_OP(add) $1, NWAITERS(%rdi) .LcleanupSTART: 6: call __pthread_enable_asynccancel @@ -115,7 +115,7 @@ sem_wait: xorl %eax, %eax 9: LOCK - subq $1, NWAITERS(%rdi) + LP_OP(sub) $1, NWAITERS(%rdi) leaq 8(%rsp), %rsp cfi_adjust_cfa_offset(-8) @@ -136,7 +136,7 @@ sem_wait: sem_wait_cleanup: movq (%rsp), %rdi LOCK - subq $1, NWAITERS(%rdi) + LP_OP(sub) $1, NWAITERS(%rdi) movq %rax, %rdi .LcallUR: call _Unwind_Resume@PLT @@ -168,9 +168,9 @@ sem_wait_cleanup: .hidden DW.ref.__gcc_personality_v0 .weak DW.ref.__gcc_personality_v0 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 + .align LP_SIZE .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 + .size DW.ref.__gcc_personality_v0, LP_SIZE DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 + ASM_ADDR __gcc_personality_v0 #endif diff --git a/libc/nptl/sysdeps/x86_64/64/shlib-versions b/libc/nptl/sysdeps/x86_64/64/shlib-versions new file mode 100644 index 000000000..5093c4c18 --- /dev/null +++ b/libc/nptl/sysdeps/x86_64/64/shlib-versions @@ -0,0 +1,3 @@ +# Configuration DEFAULT Earliest symbol set +# ------------- --------------- ------------------------------ +x86_64-.*-linux.* libpthread=0 GLIBC_2.2.5 diff --git a/libc/nptl/sysdeps/x86_64/tls.h b/libc/nptl/sysdeps/x86_64/tls.h index 77f04f202..f83891605 100644 --- a/libc/nptl/sysdeps/x86_64/tls.h +++ b/libc/nptl/sysdeps/x86_64/tls.h @@ -27,7 +27,6 @@ # include <stdlib.h> # include <sysdep.h> # include <kernel-features.h> -# include <bits/wordsize.h> # include <xmmintrin.h> @@ -60,18 +59,14 @@ typedef struct # else int __unused1; # endif -# if __WORDSIZE == 64 int rtld_must_xmm_save; -# endif /* Reservation of some values for the TM ABI. */ void *__private_tm[5]; -# if __WORDSIZE == 64 long int __unused2; /* Have space for the post-AVX register size. */ - __m128 rtld_savespace_sse[8][4]; + __m128 rtld_savespace_sse[8][4] __attribute__ ((aligned (32))); void *__padding[8]; -# endif } tcbhead_t; #else /* __ASSEMBLER__ */ diff --git a/libc/nptl/sysdeps/x86_64/x32/shlib-versions b/libc/nptl/sysdeps/x86_64/x32/shlib-versions new file mode 100644 index 000000000..8fcad2e56 --- /dev/null +++ b/libc/nptl/sysdeps/x86_64/x32/shlib-versions @@ -0,0 +1,3 @@ +# Configuration DEFAULT Earliest symbol set +# ------------- --------------- ------------------------------ +x86_64-.*-linux.* libpthread=0 GLIBC_2.16 diff --git a/libc/nptl/tst-cancel-self-cancelstate.c b/libc/nptl/tst-cancel-self-cancelstate.c new file mode 100644 index 000000000..c82e6f3ce --- /dev/null +++ b/libc/nptl/tst-cancel-self-cancelstate.c @@ -0,0 +1,65 @@ +/* Copyright (C) 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "tst-cancel-self-cleanup.c" + + +static int +do_test (void) +{ + int ret = 0; + volatile int should_fail = 1; + + pthread_cleanup_push (cleanup, &should_fail); + + if ((ret = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL)) != 0) + { + printf ("setcancelstate(disable) failed: %s\n", strerror (ret)); + exit (1); + } + + if ((ret = pthread_cancel (pthread_self ())) != 0) + { + printf ("cancel failed: %s\n", strerror (ret)); + exit (1); + } + + usleep (100); + should_fail = 0; + + if ((ret = pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL)) != 0) + { + printf ("setcancelstate(enable) failed: %s\n", strerror (ret)); + exit (1); + } + + /* The write syscall within this printf should give us our cancellation + point. */ + printf ("Could not cancel self.\n"); + pthread_cleanup_pop (0); + + return 1; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/nptl/tst-cancel-self-canceltype.c b/libc/nptl/tst-cancel-self-canceltype.c new file mode 100644 index 000000000..c9bb65313 --- /dev/null +++ b/libc/nptl/tst-cancel-self-canceltype.c @@ -0,0 +1,53 @@ +/* Copyright (C) 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "tst-cancel-self-cleanup.c" + + +static int +do_test (void) +{ + int ret = 0, should_fail = 0; + + pthread_cleanup_push (cleanup, &should_fail); + + if ((ret = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL)) != 0) + { + printf ("setcanceltype failed: %s\n", strerror (ret)); + exit (1); + } + + if ((ret = pthread_cancel (pthread_self ())) != 0) + { + printf ("cancel failed: %s\n", strerror (ret)); + exit (1); + } + + /* Wait to be canceled. Don't give any cancellation points to play with. */ + while (1); + pthread_cleanup_pop (0); + + return 1; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/nptl/tst-cancel-self-cleanup.c b/libc/nptl/tst-cancel-self-cleanup.c new file mode 100644 index 000000000..9b15f555d --- /dev/null +++ b/libc/nptl/tst-cancel-self-cleanup.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +static void +cleanup (void *cleanup_should_fail) +{ + printf ("Main thread got cancelled and is being cleaned up now\n"); + exit (*(int *)cleanup_should_fail); +} diff --git a/libc/nptl/tst-cancel-self-testcancel.c b/libc/nptl/tst-cancel-self-testcancel.c new file mode 100644 index 000000000..c9422321c --- /dev/null +++ b/libc/nptl/tst-cancel-self-testcancel.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "tst-cancel-self-cleanup.c" + + +static int +do_test (void) +{ + int ret = 0, should_fail = 0; + + pthread_cleanup_push (cleanup, &should_fail); + if ((ret = pthread_cancel (pthread_self ())) != 0) + { + printf ("cancel failed: %s\n", strerror (ret)); + exit (1); + } + + pthread_testcancel (); + + printf ("Could not cancel self.\n"); + pthread_cleanup_pop (0); + + return 1; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/nptl/tst-cancel-self.c b/libc/nptl/tst-cancel-self.c new file mode 100644 index 000000000..966698ca3 --- /dev/null +++ b/libc/nptl/tst-cancel-self.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "tst-cancel-self-cleanup.c" + + +static int +do_test (void) +{ + int ret = 0, should_fail = 0; + + pthread_cleanup_push (cleanup, &should_fail); + if ((ret = pthread_cancel (pthread_self ())) != 0) + { + printf ("cancel failed: %s\n", strerror (ret)); + exit (1); + } + + /* The write syscall within this printf should give us our cancellation + point. */ + printf ("Could not cancel self.\n"); + pthread_cleanup_pop (0); + + return 1; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/nptl/tst-stackguard1.c b/libc/nptl/tst-stackguard1.c index 4af16c9c1..c45604663 100644 --- a/libc/nptl/tst-stackguard1.c +++ b/libc/nptl/tst-stackguard1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2005. @@ -23,7 +23,7 @@ #include <stdlib.h> #include <string.h> #include <sys/wait.h> -#include <elf/stackguard-macros.h> +#include <stackguard-macros.h> #include <unistd.h> static const char *command; diff --git a/libc/nptl/vars.c b/libc/nptl/vars.c index 8f3023cfc..43a6e3957 100644 --- a/libc/nptl/vars.c +++ b/libc/nptl/vars.c @@ -32,7 +32,9 @@ size_t __default_stacksize attribute_hidden int __is_smp attribute_hidden; #ifndef TLS_MULTIPLE_THREADS_IN_TCB -/* Variable set to a nonzero value if more than one thread runs or ran. */ +/* Variable set to a nonzero value either if more than one thread runs or ran, + or if a single-threaded process is trying to cancel itself. See + nptl/descr.h for more context on the single-threaded process case. */ int __pthread_multiple_threads attribute_hidden; #endif |