Dummy pthread functions in libc considered harmful
Florian Weimer
fweimer@redhat.com
Tue Aug 25 07:19:00 GMT 2015
On 08/25/2015 09:09 AM, Andreas Schwab wrote:
> Samuel Thibault <samuel.thibault@ens-lyon.org> writes:
>
>> It's usually not programs which call pthread_mutex, but libraries which
>> want to be thread-safe without actually bringing the libpthread
>> dependencye.
>
> Does the reason for avoiding the dependency still exist? Surely the
> overhead of libpthread has been greatly reduced since the days of
> linuxthreads.
It's the use of atomics. I think it's still costly even if the cache
line containing the lock is not bouncing between CPUs. If we put the
full implementation into libc.so.6, we may need to add a fast path for
the no-threads-created case. This would actually benefit
single-threaded programs which spuriously link against libpthread (which
happens quite often).
(Note: I do not fully understand the sysdeps overrides, someone more
familiar with the code should check that the fast path is currently
missing from the libpthread version.)
--
Florian Weimer / Red Hat Product Security
More information about the Libc-alpha
mailing list