reducing the contention in dl_iterate_phdr

Florian Weimer fweimer@redhat.com
Sat May 16 10:11:16 GMT 2020


* Thomas Neumann via Libc-help:

> while trying to speed up exception handling, I noticed the very
> unfortunate exclusive lock on dl_load_write_lock within dl_iterate_phdr.
> Currently, this prevents multiple threads from unwinding simultaneously.
> I think we could improve that significantly and relatively easily by
> switching that lock to a rwlock, and locking in shared mode during
> dl_iterate_phdr and in exclusive mode in dlclose and friends.
> Performance would still not be ideal, as multiple threads would still
> fight over the shared cache line of the rwlock, but it would be much
> better than now and the change would be minor.

This will break existing libgcc_s because it relies on the ld.so lock to
protect its own internal cache.  It is not a backwards-compatible
change.

I still think that an explicit function to perform the lookup on behalf
of libgcc_s is the right direction.

One obvious optimization is not to take a lock at all while checking
whether the address is located in any of the initially loaded modules
(including the main program).

The thread on the GCC list is here:

  <https://gcc.gnu.org/pipermail/gcc/2020-May/232358.html>

Thanks,
Florian



More information about the Libc-help mailing list