This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: libpthread removal project
- From: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Carlos O'Donell <carlos at redhat dot com>
- Cc: nd <nd at arm dot com>, Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 7 Oct 2019 14:19:43 +0000
- Subject: Re: libpthread removal project
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E/0QEp2/pmAv0sRB5cIr64UWVpzL5FuQxn6X5TH9Wm4=; b=jUzv9n2RTZQgD76+YvT2j6waGv1Pbb9gM9+dswXAC0s2FpF2OBuVRWWfRg0DtAyJEVrwYrDJj5g0riAPqZ7qoeljG581FmEXWcNG8FR//2oG8QlfaVcKrF08uPs9aEOWBBsJ8oHuDU1GSkLu0/hQNQ57ZkkHgefT3TNPhQexn06e8rsE0bnNW6PqFYLfp0gvoUcoXA/WBpN2HTJewOq6YHjZ0iPOZXuw1kUFehn1DBEE2bnqCr5zERW4f6mwIJLPG0Ec6Hgx7v+y+9PggWc3bavoryRrKl1EBHl+iR07MOKoHXchM0MvhyKuCgDBoV23RAdJhmFhR+BfQqdrx3oXRw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BPPd7edAsw6H8iaCIlunEx5+e1YFh9WF2zc2zVQeHCSVfbjLgD2iNqoObGGsi6iQi7tRLkesjq3B2hNNCriO0evXIdLo1MaN/bKYyaI9n0CLe/Dw3M88y+v44+/xcad4WQeG4SlJ8FLDtUbqlz4otYlrxtuPzF/UlyyMkkfbSVtKyrZ8yh4E0yxm1egvO5kruSXBW3Bn+UARAA2RLOcRWxgVCu0p4l+nJV1ezJBXTiO7Uptfu6PhlDGX0d3lNhbwUyp7r4Hs5KC9Wc0HJlRfWW6UomEUywpgIjFkUp1q0IMHbHVNyS+Vh+ah1QUc6rXWYdcqxp3JvTse8HjOd8BR3g==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- References: <87eezsj0jb.fsf@oldenburg2.str.redhat.com> <322c6454-8651-a6c6-fa12-c5a6073ea92b@redhat.com> <CAMXh4bUa+0dSp8bqJc7DjkaYDNmqHJjrZnFKLc2tkLvsvm_qPw@mail.gmail.com>
On 07/10/2019 14:18, Adhemerval Zanella wrote:
> On Sun, Oct 6, 2019 at 11:25 PM Carlos O'Donell <carlos@redhat.com> wrote:
>> On 10/4/19 5:57 AM, Florian Weimer wrote:
>>> One of my long-term goals is to remove libpthread and move everything
>>> into libc. The remaining library will just be stub, and maybe contain
>>> some compatibility data symbols (if we have any by then).
>>>
>>> My motivation for this is that we continue to have problems with
>>> underlinking and symbol versioning. For example, users forget to link
>>> against librt and therefore get the compat definition of timer_create at
>>> run time. Another example is libstdc++, which uses an unversioned
>>> reference to pthread_create, which is bound to the compat definition of
>>> pthread_create. (This only works because libstdc++ doesn't pass any
>>> thread attributes.)
>>>
>>> Some libraries (including libstdc++) use weak symbol references to
>>> detect the presence of libpthread. If libpthread has not been loaded,
>>> they assume that they do not have to use atomics for updating counters
>>> etc. After libpthread removal, this optimization no longer works. This
>>> is why I plan to add the __libc_single_threaded variable as a
>>> replacement, which will continue to work for detecting single-threaded
>>> processes once pthread_create or pthread_key_create are always
>>> available. (The not-linking-against-libpthread optimization is already
>>> of decreased use today because a lot of single-threaded processes load
>>> the library indirectly, so I think .)
>>>
>>> Previous discussion:
>>>
>>> <https://sourceware.org/ml/libc-alpha/2019-08/msg00295.html>
>>
>> I think this is the right way forward and avoids a number of difficult
>> and nasty corner cases we get wrong. Like it or not threads are an integral
>> part of the implementation, and we should move in that direction.
>
> Agreed. The possible drawback is a higher increase in memory footprint, but I
> also think the benefits in general usage described are large in the long term.
i don't think the memory usage should be worse.
ideally most of libpthread is shareable rodata/text
and there will be at least something on the system
that depends on libpthread so all of that is in
memory anyway.
it seems currently the largest non-sharable part
of libpthread are relocs + got entries and dynamic
section some of which you can save if you move
it into libc.so.