How do I check if hardware lock elision (HLE) is disabled in libpthread.so.0?

279 Views Asked by At

From this post, I learned that HLE can be enabled/disabled differently depending on the glibc version.

How do I check whether HLE is enabled in the libpthread library object for glibc prior to and after version 2.27?

I was thinking to use dlsym(void *handle, const char *symbol) where handle is the libpthread handle and symbol refers to HLE enabled. If the function returns NULL, then HLE is disabled. If this is the case, what would symbol be ?

Is there a better way to check if HLE is disabled in the libpthread?

Update: I used "nm" command on a SLES12 system running glibc 2.22 to display all the symbols from /lib64/noelision/libpthread.so.0 which should have HLE disabled. Does the output of "nm" tell me if HLE is disabled in libpthread ?

nm "/lib64/noelision/libpthread.so.0" | grep "elision"
0000000000218290 d __elision_aconf
000000000021c4a8 b __elision_available
0000000000013440 t elision_init
0000000000013470 t __lll_lock_elision
0000000000013570 t __lll_timedlock_elision
0000000000013640 t __lll_trylock_elision
0000000000013530 t __lll_unlock_elision
000000000021c4a4 b __pthread_force_elision

Update: To answer my own question, you can indirectly check whether HLE path is disabled in pthreads by testing if there is undefined behaviour when double release a mutex from the pthreads library. A segmentation fault would indicate that the code is using HLE-enabled pthreads paths.

pthread_mutex_lock( &mutex ) ;
...
pthread_mutex_unlock( &mutex ) ;
pthread_mutex_unlock( &mutex ) ;
0

There are 0 best solutions below