From patchwork Wed Dec 10 00:07:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 874 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325362; bh=w0oMNjr3PowbXP4pgadG3dPxL7ORfDW3XaW0COs6wQM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Yh/S+fcUpn8iKeAMx1woJab8+xwXLy2SY+ehlbSfaZTSLWEB9wgVIckzxyS+PEDnE Z/P9f2JVEYg4/TYtpDV70DieSJh2a3ykXkTJAQX1swPONrx92tJYJpm/2Q+AJLcid3 Y6ShQo7seRHuPHbi9V06ZH1jIy987jxZ3g52n0L+sgnmnp5JBO5LDTYwvgHbmgOKI4 +D2pZDcBX7F3BzDH3yW8kIPLJAkeyJk+PUbp7TKot8nOjxjkz5qZ8eCMT0ueUja4rI no59VWB3zy4UQPrQg0TPgONwrfDGso8+q+olLApRZp2xjDo+gXiTNixBbyD+AH86gL BjKW1AYCFOz7Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E413687A7 for ; Tue, 9 Dec 2025 17:09:22 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 30Vhs8OBfjG9 for ; Tue, 9 Dec 2025 17:09:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325362; bh=w0oMNjr3PowbXP4pgadG3dPxL7ORfDW3XaW0COs6wQM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Yh/S+fcUpn8iKeAMx1woJab8+xwXLy2SY+ehlbSfaZTSLWEB9wgVIckzxyS+PEDnE Z/P9f2JVEYg4/TYtpDV70DieSJh2a3ykXkTJAQX1swPONrx92tJYJpm/2Q+AJLcid3 Y6ShQo7seRHuPHbi9V06ZH1jIy987jxZ3g52n0L+sgnmnp5JBO5LDTYwvgHbmgOKI4 +D2pZDcBX7F3BzDH3yW8kIPLJAkeyJk+PUbp7TKot8nOjxjkz5qZ8eCMT0ueUja4rI no59VWB3zy4UQPrQg0TPgONwrfDGso8+q+olLApRZp2xjDo+gXiTNixBbyD+AH86gL BjKW1AYCFOz7Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D4D8689EA for ; Tue, 9 Dec 2025 17:09:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325360; bh=joBp36szA75SKBpJsZLY0Qg1qRXcVUcEwsFfoOIwbrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPyYze8yXDhPeYLKivSKw/LCUdg6te5SoA9xmQwCJzBDYmjE16CAl8jC9Kjpqn3it CV1rYslJiP0JNQ+zIHWupYcYbRtsZ969I0RkrJfo8o3CfgYWlgOWr5/SUxZTAzBTcG 7QysnayOWtN6k6dMY6dv2DWc69ZG/kFVEylAQgOjgMM5oP2oOXtmcXA2gotey2TGO3 3vvdS+9J08QTHrSlGGu7mK08TwSgnIWUfixSc2iLEnVzukFJjSREVvjOL1lqdXY7AY BNQFEJwnnaPWoGaH3d36zo07EavBQ1J+5l0WirtITu1fQFuOanczbHX0ZxKCxhCT0N Ex89aoqZMAX0g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79D8B687A7; Tue, 9 Dec 2025 17:09:20 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id jRbN9Ou0pgNL; Tue, 9 Dec 2025 17:09:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325356; bh=WZUQ9UwW8moXYCbV9p8KCowO8p4UsXnyuPqUiltaDPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHY3JNM+UhoZzKtxhgmtbfY1x4/ManfpgN4w490WTRdJmxDBbaacpI1TE3KQ0qhq3 ohuify1tTkNKo8SlW0V77ZGGNwH3VQI7x7i/3F0OZ5LM7CbuNE3QMTy7+tLJzACbof Qqd538pe5wXprAWuPEA0Wo/+zPgtykIbw7seKqIAScKo9oE9pSkkiVDkBDfeRlHOqM mJttMtawYhgu4pQFFL4PqUQnVC+W2S/kBuNw+T0g10Tp6FVAdqIfaFaUM5OyFL0Drk RCp9mbATPMCPQvl9apK7mpAKoMbcs87PoIUFwZxi4YoofmFVnLLXJ2ofZidruRmDnh 7p5TQAjQzbuFg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 129F66884F; Tue, 9 Dec 2025 17:09:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 9 Dec 2025 17:07:08 -0700 Message-ID: <20251210000737.180797-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251210000737.180797-1-sjg@u-boot.org> References: <20251210000737.180797-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: D7VBZAZIKAV6QXYEVZ7OYCT6XAPMCTZV X-Message-ID-Hash: D7VBZAZIKAV6QXYEVZ7OYCT6XAPMCTZV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/35] malloc: Enable stats if UNIT_TEST or MALLOC_DEBUG List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When debugging or running unit tests it is helpful to have information available from the malloc subsystem. Enable these features in those cases. Signed-off-by: Simon Glass --- common/dlmalloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index b5dc2b13dc6..b0845e6ea7c 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -599,12 +599,12 @@ static inline void MALLOC_COPY(void *dest, const void *src, size_t sz) { memcpy( #define MORECORE_CONTIGUOUS 1 #define MORECORE_CANNOT_TRIM 1 #define MORECORE_CLEARS 1 -#define NO_MALLOC_STATS 1 #define USE_LOCKS 0 #define USE_SPIN_LOCKS 0 -#if !CONFIG_IS_ENABLED(UNIT_TEST) +#if !CONFIG_IS_ENABLED(UNIT_TEST) && !IS_ENABLED(CONFIG_MALLOC_DEBUG) #define NO_MALLINFO 1 +#define NO_MALLOC_STATS 1 #endif #if !CONFIG_IS_ENABLED(SANDBOX) #define INSECURE 1 @@ -3690,6 +3690,9 @@ static struct mallinfo internal_mallinfo(mstate m) { return nm; } +#endif /* !NO_MALLINFO */ + +#if CONFIG_IS_ENABLED(MALLOC_DEBUG) int malloc_get_info(struct malloc_info *info) { struct mallinfo mi = internal_mallinfo(gm); @@ -3699,7 +3702,7 @@ int malloc_get_info(struct malloc_info *info) return 0; } -#endif /* !NO_MALLINFO */ +#endif #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) {