Linux C Library development
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
argp BZ#14812: Add missing translation marker on some argp option argument… Mar 18, 2013
assert Update copyright notices with scripts/update-copyrights. Jan 2, 2013
benchtests Fix loop construction to functions calls Jun 21, 2013
bits Avoid use of "register" as optimization hint. Jun 7, 2013
catgets Use (void) in no-arguments function definitions. Jun 8, 2013
conf (NEED_INETADDR, NEED_INETATON): Define to 1, not empty. Sep 8, 1995
conform Update copyright notices with scripts/update-copyrights. Jan 2, 2013
crypt Use (void) in no-arguments function definitions. Jun 8, 2013
csu Declare __ehdr_start with hidden visibility. Apr 25, 2013
ctype Update copyright notices with scripts/update-copyrights. Jan 2, 2013
debug Port remaining string benchmarks Jun 11, 2013
dirent Update copyright notices with scripts/update-copyrights. Jan 2, 2013
dlfcn dlfcn/Makefile: Avoid repeated $(*-ENV) definitions. Jun 21, 2013
elf Add vectorized getenv for glibc use Jul 1, 2013
gmon Avoid use of "register" as optimization hint. Jun 7, 2013
gnulib Update copyright notices with scripts/update-copyrights. Jan 2, 2013
grp Add --enable-hardcoded-path-in-tests configure option Jan 11, 2013
gshadow Update copyright notices with scripts/update-copyrights. Jan 2, 2013
hesiod Link extra-libs consistently with libc and ld.so. May 31, 2013
hurd Use (void) in no-arguments function definitions. Jun 8, 2013
iconv Add #include <stdint.h> for uint[32|64]_t usage (except installed hea… May 16, 2013
iconvdata Update BIG5-HKSCS charmap to HKSCS-2008 Jun 11, 2013
include Add vectorized getenv for glibc use Jul 1, 2013
inet Use (void) in no-arguments function definitions. Jun 8, 2013
intl Use (void) in no-arguments function definitions. Jun 8, 2013
io Avoid use of "register" as optimization hint. Jun 7, 2013
libidn Fix-trailing-whitespaces-in-libidn. Jun 11, 2013
libio Use (void) in no-arguments function definitions. Jun 8, 2013
locale Convert iso-639.def to utf-8 Jun 11, 2013
localedata Fix formatting of comment Jun 13, 2013
login Use (void) in no-arguments function definitions. Jun 8, 2013
mach Remove trailing whitespace from mach/*.sub. Jun 10, 2013
malloc Use (void) in no-arguments function definitions. Jun 8, 2013
manual Add environment variable tuning for elision parameters. Jul 1, 2013
math Allow fesetround failures in math/test-misc.c if ROUNDING_TESTS fails. Jun 20, 2013
misc Use (void) in no-arguments function definitions. Jun 8, 2013
nis Avoid use of "register" as optimization hint. Jun 7, 2013
nptl Add environment variable tuning for elision parameters. Jul 1, 2013
nptl_db Link extra-libs consistently with libc and ld.so. May 31, 2013
nscd Fix handling of netgroup cache in nscd Jun 11, 2013
nss Fix leading whitespaces. Jun 6, 2013
po Update Interlingua translation from translation project Jun 12, 2013
ports sysdeps/arm/arm-mcount.S: Comment typo fix. Jun 18, 2013
posix Fix raciness in waitid test. Jun 13, 2013
pwd Update copyright notices with scripts/update-copyrights. Jan 2, 2013
resolv Use (void) in no-arguments function definitions. Jun 8, 2013
resource Fix stub setrlimit implementation. May 6, 2013
rt Fix symbol definitions for __clock_* functions Jun 11, 2013
scripts Sort sysd-rules-patterns by descending pattern length. Jun 17, 2013
setjmp Remove trailing whitespace. Jun 5, 2013
shadow Update copyright notices with scripts/update-copyrights. Jan 2, 2013
signal Update copyright notices with scripts/update-copyrights. Jan 2, 2013
socket Update copyright notices with scripts/update-copyrights. Jan 2, 2013
soft-fp Fix soft-fp shadowing between __FP_FRAC_ADD_3 and _FP_MUL_MEAT_2_wide… Jun 22, 2013
stdio-common Avoid use of "register" as optimization hint. Jun 7, 2013
stdlib Make tst-strtod-round use ROUNDING_TESTS. Jun 14, 2013
streams Update copyright notices with scripts/update-copyrights. Jan 2, 2013
string Fix loop construction to functions calls Jun 21, 2013
sunrpc Use (void) in no-arguments function definitions. Jun 8, 2013
sysdeps Add vectorized getenv for glibc use Jul 1, 2013
sysvipc Update copyright notices with scripts/update-copyrights. Jan 2, 2013
termios Update copyright notices with scripts/update-copyrights. Jan 2, 2013
time Use (void) in no-arguments function definitions. Jun 8, 2013
timezone Update zic from tzcode 2013b. Mar 13, 2013
wcsmbs Avoid use of "register" as optimization hint. Jun 7, 2013
wctype Update copyright notices with scripts/update-copyrights. Jan 2, 2013
.gitattributes exempt timezone files from the no-bad-whitespace policy Jun 15, 2009
.gitignore Add vectorized getenv for glibc use Jul 1, 2013
BUGS [BZ #5222] Oct 28, 2007
CANCEL-FCT-WAIVE Update. Mar 8, 2004
CANCEL-FILE-WAIVE Update. Mar 8, 2004
CONFORMANCE Move __STDC_* predefined macros from features.h to stdc-predef.h. Feb 22, 2012
COPYING Update. Jul 6, 2001
COPYING.LIB 2002-08-26 Brian Youmans <3diff@gnu.org> Aug 26, 2002
ChangeLog Include <string.h> in sysdeps/unix/sysv/linux/libc_fatal.c. Jun 22, 2013
ChangeLog.1 * Makefile (distribute): Add ChangeLog.[0-9]. Apr 14, 1995
ChangeLog.10 Update. Feb 29, 2000
ChangeLog.11 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. Dec 22, 2004
ChangeLog.12 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. Dec 22, 2004
ChangeLog.13 Update. Oct 3, 2002
ChangeLog.14 Update. Apr 20, 2004
ChangeLog.15 Split out ChangeLog.15 at 2.3 branch point Feb 16, 2005
ChangeLog.16 Fix typo in name Jun 21, 2012
ChangeLog.17 Revert "Sun agreed to a change of the license for the RPC code to a B… Jun 28, 2010
ChangeLog.2 * Makefile (distribute): Add ChangeLog.[0-9]. Apr 14, 1995
ChangeLog.3 * Makefile (distribute): Add ChangeLog.[0-9]. Apr 14, 1995
ChangeLog.4 * Makefile (distribute): Add ChangeLog.[0-9]. Apr 14, 1995
ChangeLog.5 * sysdeps/posix/getaddrinfo.c: Implement configuration file May 4, 2006
ChangeLog.6 Update. Jul 22, 1997
ChangeLog.7 Update. Nov 18, 1997
ChangeLog.8 Update. Old logs are in ChangeLog.7. Aug 11, 1998
ChangeLog.9 Update. Apr 28, 2000
INSTALL Remove mention of i386-pc-linux-gnu. Mar 13, 2013
LICENSES Expand LICENSES file. Dec 5, 2012
Makeconfig Don't use run-via-rtld-prefix for anything other than tests Apr 11, 2013
Makefile Link extra-libs consistently with libc and ld.so. May 31, 2013
Makefile.in Add target bench-clean Apr 16, 2013
Makerules Rewrite sysd-rules generation using an awk script. Jun 17, 2013
NAMESPACE Add and update many more entries. Mar 20, 2000
NEWS Fix soft-fp shadowing between __FP_FRAC_ADD_3 and _FP_MUL_MEAT_2_wide… Jun 22, 2013
PROJECTS Update. Oct 12, 2004
README i386: Fail at configure time for i386 builds. Apr 6, 2013
README.md Add README.md Jul 1, 2013
Rules Move bench target to benchtests Apr 12, 2013
Versions.def New API to set default thread attributes Jun 15, 2013
WUR-REPORT * posix/unistd.h (setuid, setreuid, seteuid, setresuid): Aug 1, 2012
abi-tags * abi-tags (*-.*-syllable.*): New match, with ABI value 5. Jan 4, 2006
aclocal.m4 i386: Fail at configure time for i386 builds. Apr 6, 2013
config.h.in Add a configure option to enable lock elision and disable by default Jul 1, 2013
config.make.in Move system-specific settings out of toplevel configure.in and config… Mar 20, 2013
configure regenerate configure Jul 1, 2013
configure.in Add a configure option to enable lock elision and disable by default Jul 1, 2013
cppflags-iterator.mk 2004-03-11 Jeroen Dekkers <jeroen@dekkers.cx> Mar 14, 2004
extra-lib.mk Don't build .os objects of static-only-routines for extra libs Mar 13, 2013
extra-modules.mk Update. Mar 8, 2004
libc-abis A few more archs have IFUNC support. Mar 17, 2010
o-iterator.mk Fri Mar 17 12:58:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> Mar 17, 1995
shlib-versions Convert WORDSIZE[32|64]/ld entries to abi-variants May 30, 2012
test-skeleton.c Update copyright notices with scripts/update-copyrights. Jan 2, 2013
version.h Open development for 2.18. Dec 25, 2012

README.md

TSX lock elision for glibc v16

Proposed NEWS entry:

  • Added support for TSX lock elision for pthread mutexes and read/write locks on i386 and x86-64. This allows to improve lock scaling of existing programs. When the --enable-lock-elision=yes parameter is specified at configure time lock elision will be enabled by default for all PTHREAD_MUTEX_DEFAULT mutexes and rwlock.

History:

  • v1: Initial post
  • v2: Remove IFUNC use.
  • v3: Nested trylock aborts by default now. Trylock enables elision on non-upgraded lock. Various bug fixes. New initializers, remove explicit new lock types in external interface. Add example of abort hook to manual. Fix bugs and clean up the configuration parser. Fix bug in lock busy handling. Fix tst-elision2 which was disabled by mistake earlier.
  • v4: (= rtm-devel6) Add missing tst-elision3 file, but not it's tst-elision2 Remove abort hook and related code. Use symbolic abort codes
  • v5: (= rtm-devel7) Rebased to current master. Use GLIBC_* prefixes for environment variables. Merge environment scan with dynamic linker Fix CPUID id that broke earlier. Minor cleanups.
  • v6: Add review feedback on glibc-var.c
  • v7: Merge with partially merged patch and fix ChangeLog.
  • v8: Rebase to current master. Add --enable-lock-elision and disable by default. Address review feedback. Make environment variables extra verbose. Various test suite fixes.
  • v9: Fix test suite for systems without TSX.
  • v10: Manual fixes Minor white space changes Rename some tuning fields from retry to skip to be more logical Use correct lock for condvar lock relock when an adaptive lock is used. Fix a problem that the wrong field was used for elision of adaptive locks.
  • v11: Environment variables split out into separate patches. Remove "adaptive" alias. Don't rely on the environment variables for the test suite. This mainly affected tst-mutex8, which tests some non POSIX behaviour now only for the subtests that explicitely disable elision (this gives the same coverage overall) Various review feedback addressed, including a bug in non smp mode with adaptive locks (thanks Torvald!) Various white space and comment change. __elided -> __rw_elision for read locks and some other identifier changes. Clarify delayed deadlock behaviour in manual.
  • v12: Further clarification in the manual for deadlock behaviour. Don't enable elision by default for suid programs. Support --enable-lock-elision=on/off Add no_elision alias for none
  • v13: Add new number for PTHREAD_MUTEX_NORMAL Disable elision for PTHREAD_MUTEX_NORMAL mutexes in pthread_mutexattr_settype() Add compat code for old glibcs disabling on PTHREAD_MUTEX_DEFAULT/NORMAL Remove PTHREAD_MUTEX_INIT_NP() initializer for better binary compatibility. This also allows enforcing no elision flags ever set when RTM is not supported at runtime, so the fast path does not need to check for this. Some tweaks shave off some more instructions off in pthread_mutex_lock/unlock
  • v14: Remove support for eliding adaptive spinning locks. Separate out user visible interfaces. All user visible interfaces are pure hints now. Remove support for any nesting of elided trylock Replace elision flags with pthread_*attr_setelision_np() Move abort in trylock to correct place (Thanks Torvald) Always abort nested trywrlock Lengthen various comments and some other cleanups. Clean up fallback flags handling. Remove elision_available check from rwlock fast path.
  • v15: Readd hunk lost in v14 to set rwlock status Remove most extra test cases for extra lock types. Split test suite in minimal fixes and pure elision test cases. Elision test cases are only done late in the series now. Remove environment variable checks in test suite. Move manual in series. Typo fixes for manual (thanks Carlos) Rename --enable-lock-elision=on to yes Split configure changes and regen INSTALL. Fix some broken ChangeLogs.
  • v16: Manual updates Remove ifdefs in test code Define and enforce flags per mutex/rwlock tuning interfaces Remove extra defines. Make some comments more verbose.

Lock elision using TSX is a technique to optimize lock scaling. It allows to run existing locks in parallel using hardware memory transactions. New instructions (RTM) are used to control memory transactions.

The full series is available at http://github.com/andikleen/glibc git://github.com/andikleen/glibc rtm-devel9

An overview of lock elision is available at http://halobates.de/adding-lock-elision-to-linux.pdf

LWN article on the topic: https://lwn.net/Articles/534758/

Collection of TSX resources: http://www.intel.com/software/tsx

This patchkit 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 user can also enable or disable elision this per mutex using pthread_{mutex,rwlock}attr_setelision_np().

[The tuning functions may not be available in some versions of glibc]

The mutexes can be configured at runtime with the GLIBC_PTHREAD_MUTEX environment variable.

[The environment variables may not be available in some versions of glibc]

This will force a specific lock type for all mutexes in the program that do not have another type set explicitly. This can be done without modifying the program.

For read/write locks the default be enable/disable using the GLIBC_PTHREAD_RWLOCK environment variable.

GLIBC_PTHREAD_MUTEX=elision GLIBC_PTHREAD_RWLOCK=elision program

Currently lock elision is not forced by default, unless explicitely set. This default can be changed at glibc compile time by adding the --enable-lock-elision parameter to configure. Some packagers may chose to change this default.

Limitations that may be fixable (but it's unclear if it's worth it):

  • Elided mutexes don't track the owner, so pthread_mutex_destroy will not detect a busy mutex.
  • Unlocking an unlocked elided mutex will result in a crash currently (see above)
  • No elision support for recursive, error check, adaptive mutexes Recursive may be possible, error check is unlikely
  • Some cases can also fallback to non elision. Most are obscure, except for the condition variables.
  • Internal locks in glibc (like malloc or stdio) do not elide.

Changing some these semantics would be possible, but has some runtime cost. Currently I decided to not do any expensive changes, but wait for more testing feedback.

To be fixed:

  • The default tuning parameters may be revised.
  • Condition variables ought to be elided too.
  • Adaptive rwlocks.
  • Adaptive spinning locks