From 8491ed6d70b60e4c75cdcfde10ae759898547b08 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 31 Mar 2014 08:07:46 -0700 Subject: Add adaptive elision to rwlocks This patch relies on the C version of the rwlocks posted earlier. With C rwlocks it is very straight forward to do adaptive elision using TSX. It is based on the infrastructure added earlier for mutexes, but uses its own elision macros. The macros are fairly general purpose and could be used for other elision purposes too. This version is much cleaner than the earlier assembler based version, and in particular implements adaptation which makes it safer. I changed the behavior slightly to not require any changes in the test suite and fully conform to all expected behaviors (generally at the cost of not eliding in various situations). In particular this means the timedlock variants are not elided. Nested trylock aborts. --- sysdeps/x86/nptl/bits/pthreadtypes.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sysdeps/x86/nptl/bits') diff --git a/sysdeps/x86/nptl/bits/pthreadtypes.h b/sysdeps/x86/nptl/bits/pthreadtypes.h index b4329f652b..b04c32b11f 100644 --- a/sysdeps/x86/nptl/bits/pthreadtypes.h +++ b/sysdeps/x86/nptl/bits/pthreadtypes.h @@ -184,11 +184,13 @@ typedef union unsigned int __nr_writers_queued; int __writer; int __shared; - unsigned long int __pad1; + signed char __rwelision; + unsigned char __pad1[7]; unsigned long int __pad2; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ unsigned int __flags; +# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, {0, 0, 0, 0, 0, 0, 0 } # define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1 } __data; # else @@ -204,7 +206,8 @@ typedef union binary compatibility. */ unsigned char __flags; unsigned char __shared; - unsigned char __pad1; + signed char __rwelision; +# define __PTHREAD_RWLOCK_ELISION_EXTRA 0 unsigned char __pad2; int __writer; } __data; -- cgit 1.4.1