glibc/nptl/sysdeps/unix/sysv/linux/x86_64
Andi Kleen 1cdbe57948 Add the low level infrastructure for pthreads lock elision with TSX
Lock elision using TSX is a technique to optimize lock scaling
It allows to run locks in parallel using hardware support for
a transactional execution mode in 4th generation Intel Core CPUs.
See http://www.intel.com/software/tsx for more Information.

This patch implements a simple adaptive lock elision algorithm based
on RTM. It enables elision for the pthread mutexes and rwlocks.
The algorithm keeps track whether a mutex successfully elides or not,
and stops eliding for some time when it is not.

When the CPU supports RTM the elision path is automatically tried,
otherwise any elision is disabled.

The adaptation algorithm and its tuning is currently preliminary.

The code adds some checks to the lock fast paths. Micro-benchmarks
show little to no difference without RTM.

This patch implements the low level "lll_" code for lock elision.
Followon patches hook this into the pthread implementation

Changes with the RTM mutexes:
-----------------------------
Lock elision in pthreads is generally compatible with existing programs.
There are some obscure exceptions, which are expected to be uncommon.
See the manual for more details.

- A broken program that unlocks a free lock will crash.
  There are ways around this with some tradeoffs (more code in hot paths)
  I'm still undecided on what approach to take here; have to wait for testing reports.
- pthread_mutex_destroy of a lock mutex will not return EBUSY but 0.
- There's also a similar situation with trylock outside the mutex,
  "knowing" that the mutex must be held due to some other condition.
  In this case an assert failure cannot be recovered. This situation is
  usually an existing bug in the program.
- Same applies to the rwlocks. Some of the return values changes
  (for example there is no EDEADLK for an elided lock, unless it aborts.
   However when elided it will also never deadlock of course)
- Timing changes, so broken programs that make assumptions about specific timing
  may expose already existing latent problems.  Note that these broken programs will
  break in other situations too (loaded system, new faster hardware, compiler
  optimizations etc.)
- Programs with non recursive mutexes that take them recursively in a thread and
  which would always deadlock without elision may not always see a deadlock.
  The deadlock will only happen on an early or delayed abort (which typically
  happens at some point)
  This only happens for mutexes not explicitely set to PTHREAD_MUTEX_NORMAL
  or PTHREAD_MUTEX_ADAPTIVE_NP.  PTHREAD_MUTEX_NORMAL mutexes do not elide.

The elision default can be set at configure time.

This patch implements the basic infrastructure for elision.
2013-07-02 08:46:54 -07:00
..
cancellation.S Fix static build when configured with --disable-hidden-plt 2013-04-04 19:43:56 +05:30
clone.S * Makefile (subdir-target-args): New variable. 2006-02-28 07:11:04 +00:00
compat-timer.h Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
fork.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Implies Use x86-64 bits/pthreadtypes.h/semaphore.h for i386/x86-64 2012-05-30 17:29:22 -07:00
libc-cancellation.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
libc-lowlevellock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
librt-cancellation.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
lowlevellock.h Add the low level infrastructure for pthreads lock elision with TSX 2013-07-02 08:46:54 -07:00
lowlevellock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
lowlevelrobustlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
not-cancel.h Fix a typo. 2003-09-02 13:25:06 +00:00
pt-vfork.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_barrier_wait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_cond_broadcast.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_cond_signal.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_cond_timedwait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_cond_wait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_once.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_rwlock_rdlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_rwlock_timedrdlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_rwlock_timedwrlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_rwlock_unlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_rwlock_wrlock.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
pthread_setaffinity.c * sysdeps/unix/sysv/linux/sched_setaffinity.c 2007-05-10 23:38:55 +00:00
pthread_spin_init.c Add __builtin_expect where appropriate. 2003-03-18 00:31:30 +00:00
pthread_spin_unlock.S Add __builtin_expect where appropriate. 2003-03-18 00:31:30 +00:00
sem_post.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
sem_timedwait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
sem_trywait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
sem_wait.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
sysdep-cancel.h Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
timer_create.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
timer_delete.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
timer_getoverr.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
timer_gettime.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
timer_settime.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Versions Update. 2003-03-25 20:41:26 +00:00
vfork.S Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00