From patchwork Sat Nov 28 11:59:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Topi Miettinen X-Patchwork-Id: 41229 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 162113972C18; Sat, 28 Nov 2020 12:00:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 162113972C18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606564814; bh=SSya5PGeWVt50JFRDhgpeeeh20Y1V4bMXnu6DcMG/to=; 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=eXhydxsClKIT8jR2mfOF67B74FGYtgJlTPcO5g8AFi1w1cWfQl9fFYQf7ubkE31mm riT3j93QrNqxcOgU1jKpaDhKjrvNPNosW/MtaQyamb2Cuc+KsA/qXQCQx1FRt9gyEg Oew1cOju62SyokCCBAnAOLLy4XLmjsm38W+cdstA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by sourceware.org (Postfix) with ESMTPS id 2F410386184A for ; Sat, 28 Nov 2020 12:00:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F410386184A Received: by mail-lf1-x142.google.com with SMTP id s27so10859350lfp.5 for ; Sat, 28 Nov 2020 04:00:05 -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=SSya5PGeWVt50JFRDhgpeeeh20Y1V4bMXnu6DcMG/to=; b=ChpfadFhc+JV8S/M0k+NusogCRQhubSRS834MMWbXIeDpe/TaiWuQbKG9jj8mmm/mA BXip0r/cbkxMidbSCa9d73up0Z12i70CsHxB26Ubk2mSqv4+KqZ3DabuvJa8JaKD2uq4 ZBhMX2lUwZu2frpebKsZw3GCMlw5M0wavw5DzxoXQenYXih8w/yxmYfgJ2ZOUg4trE0J ZxGVzr73LBe/wcYaqyttaFmLfOdYpFvsOckvl7ww6FzQf55ggXiemo2Shb1Mc2XL2X8h fGehEUjg0+nknxvdtwhq/l2yGrRyvKWsPGAQKe6sWccUAdm1Gwi9Rf9tsUSgWuCJ+hIp xYfw== X-Gm-Message-State: AOAM532qTPYaoAfaAHYmRrLJYn0nHDzFcEX3Ue+/uDLHT6kp0ul6epLO tPdb+TMC+02mob1yycyeO9P/C/h8CdMl0A== X-Google-Smtp-Source: ABdhPJwMItBwQ17tPDYvXGFSFJ08i/nt0Li0/rgsCQkdvt+AcLK+106Lo3AQhDfCd1YPCnXUkyZE5g== X-Received: by 2002:a05:6512:1095:: with SMTP id j21mr5206727lfg.309.1606564803783; Sat, 28 Nov 2020 04:00:03 -0800 (PST) Received: from localhost.localdomain (88-114-211-119.elisa-laajakaista.fi. [88.114.211.119]) by smtp.gmail.com with ESMTPSA id w28sm1055145lfk.8.2020.11.28.04.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2020 04:00:03 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 3/4] dl-sysdep: disable remaining calls to sbrk() Date: Sat, 28 Nov 2020 13:59:44 +0200 Message-Id: <20201128115945.42732-4-toiwoton@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201128115945.42732-1-toiwoton@gmail.com> References: <20201128115945.42732-1-toiwoton@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 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 --- 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