From patchwork Fri May 21 12:45:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43526 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31666398B876; Fri, 21 May 2021 12:45:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31666398B876 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621601126; bh=H890QaXeJ5Rra9aVvcWVJc4v1T1TlcP9xPRXWdWsQ28=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NcH2UvwU56a3MjBHUq5nR2BYNITyJpJtvQ0BZQFz92qGhPrntMy26kG83OyQ6/a1w lfT+4YRbwYu8rQIcJuFMienLmuSGpFHtsIHCBJ+3n9mcfkfopqVEOBdbzZGCHp2Uhf C0mz7WTxTGLiBqevqzzlK1heAtbqNLqHygAoY0fY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1FA97398B865 for ; Fri, 21 May 2021 12:45:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1FA97398B865 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-546-EDNfPV-1MVS3wtlvYhJAHg-1; Fri, 21 May 2021 08:45:21 -0400 X-MC-Unique: EDNfPV-1MVS3wtlvYhJAHg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E36B80293E for ; Fri, 21 May 2021 12:45:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-228.ams2.redhat.com [10.36.113.228]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C49105D74B for ; Fri, 21 May 2021 12:45:19 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 3/8] nptl: Move semi-public __pthread_get_minstack symbol into libc In-Reply-To: References: X-From-Line: 59e88ba6b731fb4fb20067fc0e91e71866f48990 Mon Sep 17 00:00:00 2001 Message-Id: <59e88ba6b731fb4fb20067fc0e91e71866f48990.1621600831.git.fweimer@redhat.com> Date: Fri, 21 May 2021 14:45:17 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" No abilist updates here because it is a GLIBC_PRIVATE symbol. It's also necessary to move nptl_version into pthread_create, so that it still ends up in static binaries. Reviewed-by: Adhemerval Zanella --- nptl/Versions | 2 +- nptl/nptl-init.c | 19 ------------------- nptl/nptl-stack.c | 17 +++++++++++++++++ nptl/pthreadP.h | 1 + nptl/pthread_create.c | 4 ++++ 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/nptl/Versions b/nptl/Versions index d96b830d05..845001847b 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -408,6 +408,7 @@ libc { __pthread_disable_asynccancel; __pthread_enable_asynccancel; __pthread_force_elision; + __pthread_get_minstack; __pthread_getattr_default_np; __pthread_getattr_default_np; __pthread_keys; @@ -510,7 +511,6 @@ libpthread { GLIBC_PRIVATE { __pthread_clock_gettime; __pthread_clock_settime; - __pthread_get_minstack; __pthread_initialize_minimal; } } diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 732e580355..5a460aedba 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -38,28 +38,9 @@ #include #include -/* Version of the library, used in libthread_db to detect mismatches. */ -static const char nptl_version[] __attribute_used__ = VERSION; - void __pthread_initialize_minimal_internal (void) { } strong_alias (__pthread_initialize_minimal_internal, __pthread_initialize_minimal) - - -/* This function is internal (it has a GLIBC_PRIVATE) version, but it - is widely used (either via weak symbol, or dlsym) to obtain the - __static_tls_size value. This value is then used to adjust the - value of the stack size attribute, so that applications receive the - full requested stack size, not diminished by the TCB and static TLS - allocation on the stack. Once the TCB is separately allocated, - this function should be removed or renamed (if it is still - necessary at that point). */ -size_t -__pthread_get_minstack (const pthread_attr_t *attr) -{ - return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack () - + PTHREAD_STACK_MIN); -} diff --git a/nptl/nptl-stack.c b/nptl/nptl-stack.c index 7853c105be..1a0c460ba8 100644 --- a/nptl/nptl-stack.c +++ b/nptl/nptl-stack.c @@ -19,6 +19,7 @@ #include #include +#include /* Maximum size in kB of cache. 40MiBi by default. */ static const size_t stack_cache_maxsize = 40 * 1024 * 1024; @@ -128,3 +129,19 @@ __nptl_deallocate_stack (struct pthread *pd) lll_unlock (GL (dl_stack_cache_lock), LLL_PRIVATE); } libc_hidden_def (__nptl_deallocate_stack) + +/* This function is internal (it has a GLIBC_PRIVATE) version, but it + is widely used (either via weak symbol, or dlsym) to obtain the + __static_tls_size value. This value is then used to adjust the + value of the stack size attribute, so that applications receive the + full requested stack size, not diminished by the TCB and static TLS + allocation on the stack. Once the TCB is separately allocated, + this function should be removed or renamed (if it is still + necessary at that point). */ +size_t +__pthread_get_minstack (const pthread_attr_t *attr) +{ + return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack () + + PTHREAD_STACK_MIN); +} +libc_hidden_def (__pthread_get_minstack) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index d011a0ec34..3151842891 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -343,6 +343,7 @@ extern unsigned long int __fork_generation attribute_hidden; extern unsigned long int *__fork_generation_pointer attribute_hidden; extern size_t __pthread_get_minstack (const pthread_attr_t *attr); +libc_hidden_proto (__pthread_get_minstack) /* Namespace save aliases. */ extern int __pthread_getschedparam (pthread_t thread_id, int *policy, diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 772b5efcc6..438b8a7ae1 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -36,6 +36,7 @@ #include #include "libioP.h" #include +#include #include @@ -56,6 +57,9 @@ static struct rtld_global *__nptl_rtld_global __attribute_used__ = &_rtld_global; #endif +/* Version of the library, used in libthread_db to detect mismatches. */ +static const char nptl_version[] __attribute_used__ = VERSION; + /* This performs the initialization necessary when going from single-threaded to multi-threaded mode for the first time. */ static void