From patchwork Wed Nov 25 11:36:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Topi Miettinen X-Patchwork-Id: 41189 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 424713959CB6; Wed, 25 Nov 2020 11:37:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 424713959CB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606304222; bh=VX4hKXA06NSRWuNdKA/vJhoEFiWoU1M4o5c1wRUG7dM=; 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=wRaRNMErQFGo4psxo9dLjf3WZXFG79TtxUKcXnh6C//nPdop/pStEmPnb7eXN4zL0 Hb3McKWBcunKitK0RjhzQ17rdDWlh7v/eSVzLKHafZGxqcNZ8M7i3Ty7+fpCwv+awV /Nu6Q2/fP/gXkFaPZHelZsInNM8yTx6M+2A4yxQw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by sourceware.org (Postfix) with ESMTPS id C53343959C82 for ; Wed, 25 Nov 2020 11:36:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C53343959C82 Received: by mail-lf1-x144.google.com with SMTP id u18so2650960lfd.9 for ; Wed, 25 Nov 2020 03:36:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VX4hKXA06NSRWuNdKA/vJhoEFiWoU1M4o5c1wRUG7dM=; b=Sl5jSd2JSdyH2yG9sS5TB/j4J3oEmIKRiVcuB3k5ac6rfo0Jf2+yeicrUDVcCqnWNZ ATiOyj0w9iwTlxElPLex3Zqw/4fjjOxbsC2rhhNdIwEsY5AG1NMBuVHf+cRLtpHy03Y0 p1FjWWRO+xdzAKj76AqbuCX4oO8yrcbGw9fzLNsBmG6AfP6qAPm6fM+A7L7bbX+qwJkE AhId+4dUvlK4a40XA/DXrAtPkFq6TCCduSU23YTQWQTWC65HCNNiKtAzBLaw9S8tGYFA mLf114fI3QdNkN6AaIBBxHjjf80fuxzEDf0CEYzX9+/DWd0LClRYBg8uSinpoyuGVHit NUMw== X-Gm-Message-State: AOAM5327GdtOmZOJ+Ag6dmRMGcqIQrX/2bwqt9ewA2mzOv1lxjr1AlFl cCaNbzr9LxRwH4pySAqlGfl5hIh7XJx46g== X-Google-Smtp-Source: ABdhPJzLHisxpp+VaeTghioFtCy9EfzOJV/mEGMLH9kJiSxLewPLDxK8dMAy6d5wDh2xXoJpUBz5IQ== X-Received: by 2002:a05:6512:3605:: with SMTP id f5mr1219358lfs.345.1606304218410; Wed, 25 Nov 2020 03:36:58 -0800 (PST) Received: from localhost.localdomain (88-114-211-119.elisa-laajakaista.fi. [88.114.211.119]) by smtp.gmail.com with ESMTPSA id e15sm224271lfn.292.2020.11.25.03.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 03:36:57 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 3/3] dl-sysdep: disable remaining calls to sbrk() Date: Wed, 25 Nov 2020 13:36:32 +0200 Message-Id: <20201125113632.6486-4-toiwoton@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125113632.6486-1-toiwoton@gmail.com> References: <20201125113632.6486-1-toiwoton@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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-Patchwork-Original-From: Topi Miettinen via Libc-alpha From: Topi Miettinen Reply-To: Topi Miettinen Cc: Topi Miettinen Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" When sbrk() is not used for memory allocations, there's no need to initialize the break anymore. --- v2: use tunable Signed-off-by: Topi Miettinen --- elf/dl-sysdep.c | 11 ++++++++++- sysdeps/unix/sysv/linux/dl-sysdep.c | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c index 854570821c..406b3a3809 100644 --- a/elf/dl-sysdep.c +++ b/elf/dl-sysdep.c @@ -44,6 +44,10 @@ #include #include +#if HAVE_TUNABLES +# undef TUNABLE_NAMESPACE +# define TUNABLE_NAMESPACE malloc +#endif #include #include @@ -234,7 +238,12 @@ _dl_sysdep_start (void **start_argptr, if (GLRO(dl_platform) != NULL) GLRO(dl_platformlen) = strlen (GLRO(dl_platform)); - if (__sbrk (0) == _end) + /* Tunable glibc.malloc.use_sbrk controls use of 'sbrk()'. */ + if ( +#if HAVE_TUNABLES + TUNABLE_GET (use_sbrk, int32_t, NULL) && +#endif + __sbrk (0) == _end) /* The dynamic linker was run as a program, and so the initial break starts just after our bss, at &_end. The malloc in dl-minimal.c will consume the rest of this page, so tell the kernel to move the diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c index 90c9b1db2d..625e6cb759 100644 --- a/sysdeps/unix/sysv/linux/dl-sysdep.c +++ b/sysdeps/unix/sysv/linux/dl-sysdep.c @@ -27,14 +27,24 @@ #include #include +#if HAVE_TUNABLES +# undef TUNABLE_NAMESPACE +# define TUNABLE_NAMESPACE malloc +#endif + #ifdef SHARED # define DL_SYSDEP_INIT frob_brk () static inline void frob_brk (void) { + /* Tunable glibc.malloc.use_sbrk controls use of 'sbrk()'. */ +#if HAVE_TUNABLES + if (TUNABLE_GET (use_sbrk, int32_t, NULL)) +#endif __brk (0); /* Initialize the break. */ } +# undef TUNABLE_NAMESPACE # include #endif