]> git.ipfire.org Git - thirdparty/glibc.git/commit - nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
Add elision to pthread_mutex_{try,timed,un}lock
authorAndi Kleen <ak@linux.intel.com>
Sat, 22 Dec 2012 09:03:04 +0000 (01:03 -0800)
committerAndi Kleen <ak@linux.intel.com>
Tue, 2 Jul 2013 15:46:55 +0000 (08:46 -0700)
commite8c659d74e011346785355eeef03b7fb6f533c61
tree7791d2e0769dc19ff7b549be745e4ddc251c3b7a
parent68cc29355f3334c7ad18f648ff9a6383a0916d23
Add elision to pthread_mutex_{try,timed,un}lock

Add elision paths to the basic mutex locks.

The normal path has a check for RTM and upgrades the lock
to RTM when available. Trylocks cannot automatically upgrade,
so they check for elision every time.

We use a 4 byte value in the mutex to store the lock
elision adaptation state. This is separate from the adaptive
spin state and uses a separate field.

Condition variables currently do not support elision.

Recursive mutexes and condition variables may be supported at some point,
but are not in the current implementation. Also "trylock" will
not automatically enable elision unless some other lock call
has been already called on the lock.

This version does not use IFUNC, so it means every lock has one
additional check for elision. Benchmarking showed the overhead
to be negligible.
14 files changed:
nptl/ChangeLog
nptl/pthreadP.h
nptl/pthread_mutex_lock.c
nptl/pthread_mutex_timedlock.c
nptl/pthread_mutex_trylock.c
nptl/pthread_mutex_unlock.c
nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/x86/elision-trylock.c
nptl/sysdeps/unix/sysv/linux/x86/force-elision.h [new file with mode: 0644]
nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c [new file with mode: 0644]
nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c [new file with mode: 0644]
nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c [new file with mode: 0644]
nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c [new file with mode: 0644]