[PATCH] x86: Use RTM intrinsics in pthread mutex lock elision

H.J. Lu hjl.tools@gmail.com
Tue Oct 2 13:53:00 GMT 2018


On Tue, Oct 2, 2018 at 6:06 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 01/10/2018 19:08, H.J. Lu wrote:
> > Since RTM intrinsics are supported in GCC 4.9, we can use them in
> > pthread mutex lock elision.
> >
> >       * sysdeps/unix/sysv/linux/x86/Makefile (CFLAGS-elision-lock.c):
> >       Add -mrtm.
> >       (CFLAGS-elision-unlock.c): Likewise.
> >       (CFLAGS-elision-timed.c): Likewise.
> >       (CFLAGS-elision-trylock.c): Likewise.
> >       * sysdeps/unix/sysv/linux/x86/hle.h: Rewritten.
>
> LGTM, thanks.
>
> > ---
> >  sysdeps/unix/sysv/linux/x86/Makefile |  4 ++
> >  sysdeps/unix/sysv/linux/x86/hle.h    | 70 ++--------------------------
> >  2 files changed, 7 insertions(+), 67 deletions(-)
> >
> > diff --git a/sysdeps/unix/sysv/linux/x86/Makefile b/sysdeps/unix/sysv/linux/x86/Makefile
> > index 7dc4e61756..02ca36c6d2 100644
> > --- a/sysdeps/unix/sysv/linux/x86/Makefile
> > +++ b/sysdeps/unix/sysv/linux/x86/Makefile
> > @@ -14,6 +14,10 @@ endif
> >  ifeq ($(subdir),nptl)
> >  libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
> >                             elision-trylock
> > +CFLAGS-elision-lock.c += -mrtm
> > +CFLAGS-elision-unlock.c += -mrtm
> > +CFLAGS-elision-timed.c += -mrtm
> > +CFLAGS-elision-trylock.c += -mrtm
> >  endif
> >
> >  ifeq ($(subdir),elf)
> > diff --git a/sysdeps/unix/sysv/linux/x86/hle.h b/sysdeps/unix/sysv/linux/x86/hle.h
> > index 4a7b9e3bf7..0449026839 100644
> > --- a/sysdeps/unix/sysv/linux/x86/hle.h
> > +++ b/sysdeps/unix/sysv/linux/x86/hle.h
> > @@ -1,75 +1,11 @@
> > -/* Shared RTM header.  Emulate TSX intrinsics for compilers and assemblers
> > -   that do not support the intrinsics and instructions yet.  */
> > +/* Shared RTM header.  */
> >  #ifndef _HLE_H
> >  #define _HLE_H 1
> >
> > -#ifdef __ASSEMBLER__
> > +#include <x86intrin.h>
>
> Is it used in any configuration in assembly code?

No:

sysdeps/unix/sysv/linux/x86/elision-lock.c:#include "hle.h"
sysdeps/unix/sysv/linux/x86/elision-trylock.c:#include "hle.h"
sysdeps/unix/sysv/linux/x86/elision-unlock.c:#include "hle.h"
sysdeps/x86/elide.h:#include <hle.h>

BTW, elide.h isn't used anywhere.

-- 
H.J.



More information about the Libc-alpha mailing list