From patchwork Wed May 12 16:59:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43418 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 CF4A339AD875; Wed, 12 May 2021 16:59:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF4A339AD875 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620838772; bh=ZtJM/mMlRCoIDlE8aI0yTkyPWOWz1e0I/TduvXlrV1M=; 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=LVzcoBJ5eXSzyXT7SgNNjR+8XYO53KCiram5OKyq16DR7OjFEhST4YnliM1WAgGd4 Ek/nJiaEtuLabIKyG72o+l2XvGHP9yDEH8JVgQZCRpSUm4/Up9AggycRUnIHnbp8XN rc1J7Dy98BuCfvC8g1w4qf6k4Hocm7goitUnkHDI= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 6E1B139AD849 for ; Wed, 12 May 2021 16:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E1B139AD849 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-255-tyc5K7_OOM-tIGw0-KkxYA-1; Wed, 12 May 2021 12:59:28 -0400 X-MC-Unique: tyc5K7_OOM-tIGw0-KkxYA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E393107ACCD for ; Wed, 12 May 2021 16:59:27 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6497F60D79 for ; Wed, 12 May 2021 16:59:26 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 23/23] nptl: Move semi-public __pthread_get_minstack symbol into libc In-Reply-To: References: X-From-Line: a8d79a3d86ce38fea916a49e0ff3f3208f68a2bf Mon Sep 17 00:00:00 2001 Message-Id: Date: Wed, 12 May 2021 18:59:24 +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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 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 2097e517ae..016a9bef09 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 3e9da9c7ea..c6b82851bf 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -340,6 +340,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 43f3722f57..220edda917 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; + /* Code to allocate and deallocate a stack. */ #include "allocatestack.c"