From patchwork Mon May 10 12:37:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1476385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=tBOoc01m; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ff0tw4Wbsz9tkv for ; Mon, 10 May 2021 22:37:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC819396C81C; Mon, 10 May 2021 12:37:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC819396C81C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620650241; bh=XRfyXkV3InCU/oPmH/k+KGcjJFobOsMFnrPRDIOUJZI=; 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=tBOoc01mdS6yWo7PF22VZg2f6g/4xcuV/PiBnfSS0fbej3nr6Fezb+vRWXOAFjWwt 34pQ7izM+sy1ExAokFkyq3QOAjXnFbIJ7xeHIQp32VTeMtwdbX1QyT5xTpEtTCKele J6ipsOTpFpZPNuy/w2F9BBIXSeU4gfu7sJu3RVaQ= 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 F3F01395C809 for ; Mon, 10 May 2021 12:37:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F3F01395C809 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-33-Ze3bil7LOZG5JbxtJhCZ9A-1; Mon, 10 May 2021 08:37:17 -0400 X-MC-Unique: Ze3bil7LOZG5JbxtJhCZ9A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A176C1854E25 for ; Mon, 10 May 2021 12:37:16 +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 C86FE61094 for ; Mon, 10 May 2021 12:37:15 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 3/8] nptl: Remove always-disabled debugging support In-Reply-To: References: X-From-Line: 313425893d8419592a17bdad60ce2bf37d485b3f Mon Sep 17 00:00:00 2001 Message-Id: <313425893d8419592a17bdad60ce2bf37d485b3f.1620650045.git.fweimer@redhat.com> Date: Mon, 10 May 2021 14:37:41 +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.12 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" This removes the DEBUGGING_P macro and the __pthread_debug variable. The __find_in_stack_list function is now unused and deleted as well. Reviewed-by: Adhemerval Zanella --- nptl/pthreadP.h | 26 +++++----------------- nptl/pthread_create.c | 49 ----------------------------------------- nptl/pthread_sigqueue.c | 5 ----- 3 files changed, 5 insertions(+), 75 deletions(-) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index d9b97c814a..d9a6137bd3 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -243,23 +243,11 @@ libc_hidden_proto (__pthread_tpp_change_priority) extern int __pthread_current_priority (void); libc_hidden_proto (__pthread_current_priority) -/* The library can run in debugging mode where it performs a lot more - tests. */ -extern int __pthread_debug attribute_hidden; -/** For now disable debugging support. */ -#if 0 -# define DEBUGGING_P __builtin_expect (__pthread_debug, 0) -# define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL) -# define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd) -#else -# define DEBUGGING_P 0 -/* Simplified test. This will not catch all invalid descriptors but - is better than nothing. And if the test triggers the thread - descriptor is guaranteed to be invalid. */ -# define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0) -# define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0) -#endif - +/* This will not catch all invalid descriptors but is better than + nothing. And if the test triggers the thread descriptor is + guaranteed to be invalid. */ +#define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0) +#define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0) /* Cancellation test. */ #define CANCELLATION_P(self) \ @@ -322,10 +310,6 @@ __do_cancel (void) /* Internal prototypes. */ -/* Thread list handling. */ -extern struct pthread *__find_in_stack_list (struct pthread *pd) - attribute_hidden; - /* Deallocate a thread's stack after optionally making sure the thread descriptor is still valid. */ extern void __free_tcb (struct pthread *pd) attribute_hidden; diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 775287d0e4..d19456d48b 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -42,9 +42,6 @@ #include -/* Nozero if debugging mode is enabled. */ -int __pthread_debug; - /* Globally enabled events. */ static td_thr_events_t __nptl_threads_events __attribute_used__; @@ -210,46 +207,6 @@ static int create_thread (struct pthread *pd, const struct pthread_attr *attr, #include - -struct pthread * -__find_in_stack_list (struct pthread *pd) -{ - list_t *entry; - struct pthread *result = NULL; - - lll_lock (GL (dl_stack_cache_lock), LLL_PRIVATE); - - list_for_each (entry, &GL (dl_stack_used)) - { - struct pthread *curp; - - curp = list_entry (entry, struct pthread, list); - if (curp == pd) - { - result = curp; - break; - } - } - - if (result == NULL) - list_for_each (entry, &GL (dl_stack_user)) - { - struct pthread *curp; - - curp = list_entry (entry, struct pthread, list); - if (curp == pd) - { - result = curp; - break; - } - } - - lll_unlock (GL (dl_stack_cache_lock), LLL_PRIVATE); - - return result; -} - - /* Deallocate a thread's stack after optionally making sure the thread descriptor is still valid. */ void @@ -259,12 +216,6 @@ __free_tcb (struct pthread *pd) if (__builtin_expect (atomic_bit_test_set (&pd->cancelhandling, TERMINATED_BIT) == 0, 1)) { - /* Remove the descriptor from the list. */ - if (DEBUGGING_P && __find_in_stack_list (pd) == NULL) - /* Something is really wrong. The descriptor for a still - running thread is gone. */ - abort (); - /* Free TPP data. */ if (__glibc_unlikely (pd->tpp != NULL)) { diff --git a/nptl/pthread_sigqueue.c b/nptl/pthread_sigqueue.c index 64bacfe41b..3ffb595489 100644 --- a/nptl/pthread_sigqueue.c +++ b/nptl/pthread_sigqueue.c @@ -31,11 +31,6 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value) #ifdef __NR_rt_tgsigqueueinfo struct pthread *pd = (struct pthread *) threadid; - /* Make sure the descriptor is valid. */ - if (DEBUGGING_P && INVALID_TD_P (pd)) - /* Not a valid thread handle. */ - return ESRCH; - /* Force load of pd->tid into local variable or register. Otherwise if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */