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:25:08 +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=LFPNnkQOUZ2tasaVmUC4HdUS2gVY3n+xBTXGmce9/r0=; b=Lr0RYFKvkIGiGcP+1lXiC76j7iFSUmv9OK64xY5RRsuwwq+GRjpWF1OU21umjGIKlKKYOwfqfNmu1qZzbwm87Sm9txXlHH88etCG4XN3HYq7wl5EHil1k8MxamGMnTikQ5CMNU8FnWuYanDF9lESMzQSz17c8t3Q/mDos3oqXXO7Rzqu+Sb8abyDGYr4XMc1uH0OsJVJfppATJy3KFFPtDkJKqqDLQG3PdrTN/dkv6X8SngC7bh9fGDssfW7LZWdluYAc4PKeXArvW1XDwmG1N4LHFCJlhTfMsCpkBnxxUAO6apntApO1CmvYnS4qWmIBFmxYWYRxxniHvv+l24wag==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OEwPPiQ9o/raM9Yi7m5IRu5ZgqbnXXDT4Kzj759CclCcubitvQWg1r4NdzaCO9m+sBljGF+lF9YZewpzEHOdMwk4kXIvWNxOCwnsewEgS8PLgFB562np5Ajt+U6YOUhH+Osjdcmk2yILb2K1ppTucrhI1ZHTBEJwAFuyGvCL5jwVC5J5JEOWvTKb52zkSqBCX5ET1uRBQ/vL4BXBaQ8DPd9MetCEx0/uAaKOEh8ZZvceLefn+sYN+OMO2pWzwZ+z+xo78BG9u00aLSjGxurQjsZ4r2U4SVFPOAoeQrxwdFo0eAgLvpyngbmdMeHE6ur3KidsyQJxHnflcUWteGhmOg==
- 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> <d5770bfd-f01f-1679-8e4b-0e5229099725@arm.com>
On 07/10/2019 15:19, Szabolcs Nagy wrote:
> 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.
hm i missed the large .bss for pthread_keys
815: 000000000002b2f0 16384 OBJECT LOCAL DEFAULT 26 __GI___pthread_keys
i guess that's non-shareable, so it is committed
memory, but can be unallocated if it's unused.
if it's a concern it can be changed to use malloc.