From patchwork Mon Jul 5 17:08:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1500910 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+incoming=patchwork.ozlabs.org@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=jkAYaiwk; dkim-atps=neutral Received: from sourceware.org (server2.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 4GJXPJ1RQSz9sWS for ; Tue, 6 Jul 2021 03:15:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E5EF63840017 for ; Mon, 5 Jul 2021 17:14:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5EF63840017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625505297; bh=elspd1rCthuC5Swfiy2LWRaZnvqyrctpIK43Slmf+8E=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jkAYaiwkyShJ1pRbGeUONpZ4XWwy6PBiyWa57k9j1IBtws71XZiNnEZo3DtotCPNP QaLle7zuNF8x1HFohUkj6CgqUfZKO5XzGUR1+RMzitbmnCDrQTPOx8pv76IlTW5kkM JziTz8Zd/anBd0UUlZbj/k49LDhTpU++egocLbPk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by sourceware.org (Postfix) with ESMTPS id 1D71D384002D for ; Mon, 5 Jul 2021 17:09:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D71D384002D X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6A99564160D; Mon, 5 Jul 2021 17:09:22 +0000 (UTC) Received: from pdx1-sub0-mail-a29.g.dreamhost.com (100-105-161-161.trex-nlb.outbound.svc.cluster.local [100.105.161.161]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 02619641AE1; Mon, 5 Jul 2021 17:09:21 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a29.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.105.161.161 (trex/6.3.3); Mon, 05 Jul 2021 17:09:22 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Chief-Whimsical: 54df50c168ff2752_1625504962269_3648464233 X-MC-Loop-Signature: 1625504962269:3995954268 X-MC-Ingress-Time: 1625504962268 Received: from pdx1-sub0-mail-a29.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTP id 779D97E509; Mon, 5 Jul 2021 10:09:21 -0700 (PDT) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTPSA id 9F9737E4A5; Mon, 5 Jul 2021 10:09:18 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a29 To: libc-alpha@sourceware.org Subject: [PATCH v5 7/8] Remove __after_morecore_hook Date: Mon, 5 Jul 2021 22:38:13 +0530 Message-Id: <20210705170814.4132997-8-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210705170814.4132997-1-siddhesh@sourceware.org> References: <20210705170814.4132997-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3494.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Remove __after_morecore_hook from the API and finalize the symbol so that it can no longer be used in new applications. Old applications using __after_morecore_hook will find that their hook is no longer called. --- malloc/hooks.c | 7 +++++++ malloc/malloc.c | 30 +----------------------------- malloc/malloc.h | 5 ----- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/malloc/hooks.c b/malloc/hooks.c index ffaf3a645a..50ea03b562 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -24,6 +24,10 @@ compat_symbol (libc, __malloc_initialize_hook, #endif #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34) +# ifndef weak_variable +# define weak_variable weak_function +# endif + static void *malloc_hook_ini (size_t, const void *) __THROW; static void *realloc_hook_ini (void *, size_t, const void *) __THROW; static void *memalign_hook_ini (size_t, size_t, const void *) __THROW; @@ -40,6 +44,9 @@ void *weak_variable (*__memalign_hook) (size_t, size_t, const void *) = memalign_hook_ini; compat_symbol (libc, __memalign_hook, __memalign_hook, GLIBC_2_0); +void weak_variable (*__after_morecore_hook) (void) = NULL; +compat_symbol (libc, __after_morecore_hook, __after_morecore_hook, GLIBC_2_0); + /* This is interposed by libc_malloc_debug.so to match with a compatible libc. We don't use dlsym or equivalent because the dlsym symbol version got bumped in 2.34 and is hence unusable in libc_malloc_debug.so. */ diff --git a/malloc/malloc.c b/malloc/malloc.c index 1c1e1ab60b..00fcc676a0 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1988,16 +1988,6 @@ static void malloc_consolidate (mstate); /* -------------- Early definitions for debugging hooks ---------------- */ -/* Define and initialize the hook variables. These weak definitions must - appear before any use of the variables in a function (arena.c uses one). */ -#ifndef weak_variable -/* In GNU libc we want the hook variables to be weak definitions to - avoid a problem with Emacs. */ -# define weak_variable weak_function -#endif - -void weak_variable (*__after_morecore_hook) (void) = NULL; - /* This function is called from the arena shutdown hook, to free the thread cache (if it exists). */ static void tcache_thread_shutdown (void); @@ -2623,14 +2613,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) LIBC_PROBE (memory_sbrk_more, 2, brk, size); } - if (brk != (char *) (MORECORE_FAILURE)) - { - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) = atomic_forced_read (__after_morecore_hook); - if (__builtin_expect (hook != NULL, 0)) - (*hook)(); - } - else + if (brk == (char *) (MORECORE_FAILURE)) { /* If have mmap, try using it as a backup when MORECORE fails or @@ -2769,13 +2752,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) correction = 0; snd_brk = (char *) (MORECORE (0)); } - else - { - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) = atomic_forced_read (__after_morecore_hook); - if (__builtin_expect (hook != NULL, 0)) - (*hook)(); - } } /* handle non-contiguous cases */ @@ -2934,10 +2910,6 @@ systrim (size_t pad, mstate av) */ MORECORE (-extra); - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) = atomic_forced_read (__after_morecore_hook); - if (__builtin_expect (hook != NULL, 0)) - (*hook)(); new_brk = (char *) (MORECORE (0)); LIBC_PROBE (memory_sbrk_less, 2, new_brk, extra); diff --git a/malloc/malloc.h b/malloc/malloc.h index 709fa454b5..d066a05d82 100644 --- a/malloc/malloc.h +++ b/malloc/malloc.h @@ -164,10 +164,5 @@ extern void malloc_stats (void) __THROW; /* Output information about state of allocator to stream FP. */ extern int malloc_info (int __options, FILE *__fp) __THROW; -/* Hooks for debugging and user-defined versions. */ -extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void) - __MALLOC_DEPRECATED; - - __END_DECLS #endif /* malloc.h */