From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id 275BA3861021 for ; Thu, 18 Mar 2021 12:42:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 275BA3861021 Received: by mail-qk1-x72a.google.com with SMTP id f124so1766650qkj.5 for ; Thu, 18 Mar 2021 05:42:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ECRTExZjh68W7ldqx69kCF297xGNPuyPxPk/kjwXtoA=; b=IHLwk2mkMHs0cCv5RtX/0BG3xoU0Q9tT/ieMbXlrGXAdX4iSxwMOKyi3Xv+MWsmmGB y/cSxUp8D15VhNuvga60l8mtihq2PtwtHE79po3CqQRFx8WppHwAxbgYp/vnQrQpO8du HQtEMqTLLHhxEzi9QCCxEjZtcfo1IvVx7fuSVZDBp/moN2qaon2rFitw7pwOdUxcXMtx o8XlTqCEh7geZ4E5D0t4bjFGijHw8RCrI8y1vdXqbYcTFyYuekubtaHGU65mfGSR/03i mrHgTItR3DTPYhhbRqXprdxAj8k3ahQ2jZXQyb2fXJXP+hw+btZIJ9EgrOg67SUWLqUm R7WQ== X-Gm-Message-State: AOAM531booCsMTZNtJdH7XDADPvCdNzzUf5ib6fM8HQGpbKPmnOomKv8 1NJBJMTjO6HgnUQ0umSlnI5rqKH/o6nj3kg/ X-Google-Smtp-Source: ABdhPJwM/4t0UOUeVitudSSDmSlkZq3TdKCQAPc/jIg1iSKXAg4hExJSdSiybsCmaAKwWSdUi4FxZg== X-Received: by 2002:a37:ae44:: with SMTP id x65mr4094100qke.9.1616071328575; Thu, 18 Mar 2021 05:42:08 -0700 (PDT) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id f2sm1571793qko.135.2021.03.18.05.42.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Mar 2021 05:42:08 -0700 (PDT) Subject: Re: [PATCH v3 11/37] nptl: Move internal __nptl_nthreads variable into libc To: libc-alpha@sourceware.org, Florian Weimer References: <6f4a258f7dcf4ea89dfd26aab9be2a9e0b061cb5.1615914631.git.fweimer@redhat.com> From: Adhemerval Zanella Message-ID: <292fb619-feae-17c3-9f79-62a5043587ff@linaro.org> Date: Thu, 18 Mar 2021 09:42:04 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <6f4a258f7dcf4ea89dfd26aab9be2a9e0b061cb5.1615914631.git.fweimer@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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-List-Received-Date: Thu, 18 Mar 2021 12:42:11 -0000 LGTM with just a nit with a spurious change. Reviewed-by: Adhemerval Zanella On 16/03/2021 14:29, Florian Weimer via Libc-alpha wrote: > --- > nptl/Makefile | 1 + > nptl/Versions | 1 + > nptl/libc_pthread_init.c | 1 - > nptl/nptl-init.c | 1 - > nptl/nptl_nthreads.c | 23 +++++++++++++++++++++++ > nptl/pthreadP.h | 3 ++- > nptl/pthread_create.c | 4 ---- > nptl_db/structs.def | 2 +- > sysdeps/nptl/libc_start_call_main.h | 13 ++----------- > sysdeps/nptl/pthread-functions.h | 2 -- > 10 files changed, 30 insertions(+), 21 deletions(-) > create mode 100644 nptl/nptl_nthreads.c > > diff --git a/nptl/Makefile b/nptl/Makefile > index c1ade91a0b..d7491632b8 100644 > --- a/nptl/Makefile > +++ b/nptl/Makefile > @@ -45,6 +45,7 @@ routines = \ > libc_multiple_threads \ > libc_pthread_init \ > lowlevellock \ > + nptl_nthreads \ > old_pthread_cond_destroy \ > old_pthread_cond_init \ > pthread_atfork \ Ok. > diff --git a/nptl/Versions b/nptl/Versions > index 8f1cd3f7c4..968c4fba35 100644 > --- a/nptl/Versions > +++ b/nptl/Versions > @@ -107,6 +107,7 @@ libc { > __lll_lock_wait_private; > __lll_trylock_elision; > __lll_unlock_elision; > + __nptl_nthreads; > __pthread_attr_copy; > __pthread_attr_destroy; > __pthread_attr_init; Ok. > diff --git a/nptl/libc_pthread_init.c b/nptl/libc_pthread_init.c > index 3ac54aae13..85fceff930 100644 > --- a/nptl/libc_pthread_init.c > +++ b/nptl/libc_pthread_init.c > @@ -27,7 +27,6 @@ > #include > #include > > - > #ifdef TLS_MULTIPLE_THREADS_IN_TCB > void > #else Spurious line removal. > diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c > index d30e8a9bdf..a09d6ed306 100644 > --- a/nptl/nptl-init.c > +++ b/nptl/nptl-init.c > @@ -94,7 +94,6 @@ static const struct pthread_functions pthread_functions = > .ptr___pthread_key_create = __pthread_key_create, > .ptr___pthread_getspecific = __pthread_getspecific, > .ptr___pthread_setspecific = __pthread_setspecific, > - .ptr_nthreads = &__nptl_nthreads, > .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd, > .ptr__nptl_setxid = __nptl_setxid, > .ptr_set_robust = __nptl_set_robust Ok. > diff --git a/nptl/nptl_nthreads.c b/nptl/nptl_nthreads.c > new file mode 100644 > index 0000000000..2245bb3c76 > --- /dev/null > +++ b/nptl/nptl_nthreads.c > @@ -0,0 +1,23 @@ > +/* Thread counter variable. > + Copyright (C) 2021 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > + > +/* Number of threads running. */ > +unsigned int __nptl_nthreads = 1; > +libc_hidden_data_def (__nptl_nthreads) Ok. > diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h > index f78bf03a52..b136aeae4d 100644 > --- a/nptl/pthreadP.h > +++ b/nptl/pthreadP.h > @@ -220,7 +220,8 @@ extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]; > hidden_proto (__pthread_keys) > > /* Number of threads running. */ > -extern unsigned int __nptl_nthreads attribute_hidden; > +extern unsigned int __nptl_nthreads; > +libc_hidden_proto (__nptl_nthreads) > > #ifndef __ASSUME_SET_ROBUST_LIST > /* Negative if we do not have the system call and we can use it. */ Ok. > diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c > index 6c645aff48..350bf03f5d 100644 > --- a/nptl/pthread_create.c > +++ b/nptl/pthread_create.c > @@ -51,10 +51,6 @@ static td_thr_events_t __nptl_threads_events __attribute_used__; > /* Pointer to descriptor with the last event. */ > static struct pthread *__nptl_last_event __attribute_used__; > > -/* Number of threads running. */ > -unsigned int __nptl_nthreads = 1; > - > - > /* Code to allocate and deallocate a stack. */ > #include "allocatestack.c" > Ok. > diff --git a/nptl_db/structs.def b/nptl_db/structs.def > index 999a9fc35a..d0e1cb659a 100644 > --- a/nptl_db/structs.def > +++ b/nptl_db/structs.def > @@ -73,7 +73,7 @@ DB_SYMBOL (nptl_version) > DB_FUNCTION (__nptl_create_event) > DB_FUNCTION (__nptl_death_event) > DB_SYMBOL (__nptl_threads_events) > -DB_VARIABLE (__nptl_nthreads) > +DB_MAIN_VARIABLE (__nptl_nthreads) > DB_VARIABLE (__nptl_last_event) > DB_VARIABLE (__nptl_initial_report_events) > Ok. > diff --git a/sysdeps/nptl/libc_start_call_main.h b/sysdeps/nptl/libc_start_call_main.h > index 5218e7ab1e..112cc20a7a 100644 > --- a/sysdeps/nptl/libc_start_call_main.h > +++ b/sysdeps/nptl/libc_start_call_main.h > @@ -17,6 +17,7 @@ > . */ > > #include > +#include > > _Noreturn static void > __libc_start_call_main (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), > @@ -69,17 +70,7 @@ __libc_start_call_main (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), > /* One less thread. Decrement the counter. If it is zero we > terminate the entire process. */ > result = 0; > -# ifdef SHARED > - unsigned int *ptr = __libc_pthread_functions.ptr_nthreads; > -# ifdef PTR_DEMANGLE > - PTR_DEMANGLE (ptr); > -# endif > -# else > - extern unsigned int __nptl_nthreads __attribute ((weak)); > - unsigned int *const ptr = &__nptl_nthreads; > -# endif > - > - if (! atomic_decrement_and_test (ptr)) > + if (! atomic_decrement_and_test (&__nptl_nthreads)) > /* Not much left to do but to exit the thread, not the process. */ > __exit_thread (); > } Ok. > diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h > index 280655fe40..2fa698b1da 100644 > --- a/sysdeps/nptl/pthread-functions.h > +++ b/sysdeps/nptl/pthread-functions.h > @@ -55,8 +55,6 @@ struct pthread_functions > int (*ptr___pthread_key_create) (pthread_key_t *, void (*) (void *)); > void *(*ptr___pthread_getspecific) (pthread_key_t); > int (*ptr___pthread_setspecific) (pthread_key_t, const void *); > -#define HAVE_PTR_NTHREADS > - unsigned int *ptr_nthreads; > void (*ptr__nptl_deallocate_tsd) (void); > int (*ptr__nptl_setxid) (struct xid_command *); > void (*ptr_set_robust) (struct pthread *); > Ok.