| Message ID | 20251201170529.3237986-34-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> 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=1764608988; bh=xy//ItUk5GDy7R8LdjbJaIt1IIK+Jzgg20lBBwQLRUM=; 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=D9+COQR1+fzOLQiscqMn6p8wEJz+9JZF1bqHEfOxMEOXEOixQWZJwvsO94eAPWpsE IT0H3xNOSWiwdJ5+10pcYjgkmboQr2QcYHjJY/A+sqNxVQa8AF6huuc8ZWHBWprDbD yl/AcetfaJKIwjvc65Os5Jw4iiUm0WZlpqYg01XeNTOO5g361Qk6g11uVtp937L1Xb AeteVL/+aEM5z/15Bx3kJdndt9uF7yj//iiU/W0Ek06+azCizyqPFZnbJ26ANmRpMp tmSXVCrYsukYeATkPVjvDziY1ghm5Ing9IfAXRagijdKW985Znk3xd+03mlkmnkXG0 4P45aJ3qgj7tA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15ABA688CB for <u-boot-concept@u-boot.org>; Mon, 1 Dec 2025 10:09:48 -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 T8aUHZecrHON for <u-boot-concept@u-boot.org>; Mon, 1 Dec 2025 10:09:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608988; bh=xy//ItUk5GDy7R8LdjbJaIt1IIK+Jzgg20lBBwQLRUM=; 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=D9+COQR1+fzOLQiscqMn6p8wEJz+9JZF1bqHEfOxMEOXEOixQWZJwvsO94eAPWpsE IT0H3xNOSWiwdJ5+10pcYjgkmboQr2QcYHjJY/A+sqNxVQa8AF6huuc8ZWHBWprDbD yl/AcetfaJKIwjvc65Os5Jw4iiUm0WZlpqYg01XeNTOO5g361Qk6g11uVtp937L1Xb AeteVL/+aEM5z/15Bx3kJdndt9uF7yj//iiU/W0Ek06+azCizyqPFZnbJ26ANmRpMp tmSXVCrYsukYeATkPVjvDziY1ghm5Ing9IfAXRagijdKW985Znk3xd+03mlkmnkXG0 4P45aJ3qgj7tA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 03F9B688A4 for <u-boot-concept@u-boot.org>; Mon, 1 Dec 2025 10:09:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608986; bh=m/cFPwsxxd2zgSt5m5yhXgmyIlXlaVAt76xRciFJaGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y86H3kkcvjaGCwbUlWjdnM+lx8Qj978x7I8h2nGtkaQgmx4+VkKp9lfe54wK063WZ ZrvtEorHnSPeUIFb2HhuQ0BeS5iZTMkJ9oxOWVUPMr7dbcpirshfkiET4Vw/3Lba7t X+O9g7aOw/rc2c9Lhtqm9Yy7nXKHj0okJ243clwlmWS79xNUhpmryjkP/mnmczgR3k C0dH9ag4DoDO5NgqsOEzQyZ0bx2L+u0pemHo9Tv8L8Kx2Ed7nSEvxM9dISHRXrG9yV D2sabc83TR+yJPIMF6FO6N4mKEAZ8DHoqCNm0ArZvz0gx7uCxoR/gjLnDd+KV16BFP dk5wKKczPm9QA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C930F68821; Mon, 1 Dec 2025 10:09:46 -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 JNmx-_wJ0CYi; Mon, 1 Dec 2025 10:09:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608980; bh=6iZhIrUpcIfY+hwed2an898olo376S6LZo5d2iQTtrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PK4xbDYmUL4OXOYjELqYPXPDLtaWpqZhqqsiHhaAnu3eCzpnGSFUKlsRo10ONk0+2 0b6PAj24mAngIeNVhx24TXzpVhC7t6Cq2UDi3lZEDF3JUc84loISClbo2wNF1gY9ZB QSsXu15IX2Qp3QIwF4Q2d4/Cp57coL6kLpmcsTSri/vwEWOea68vc1GIfSXZ7TCLQ9 PJ4wmj8I/gMpEJ/AISS3ouqbI0f+qzn4ZywaPp0txJmO9vm32lNjnfg0s/lOWuF5Wg 2RGG4G+vgplV/h4w/ObyEowSCmiejoMkdGTRsfSaWPYmRbMEt6HrL+TeeQyDneYQup J53UOkHhDRoXQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E04BC6881A; Mon, 1 Dec 2025 10:09:39 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Mon, 1 Dec 2025 10:05:12 -0700 Message-ID: <20251201170529.3237986-34-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251201170529.3237986-1-sjg@u-boot.org> References: <20251201170529.3237986-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2AB2RHURPCMNJZDW44BU36VZLXZOLGBX X-Message-ID-Hash: 2AB2RHURPCMNJZDW44BU36VZLXZOLGBX 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 <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com>, Claude <noreply@anthropic.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 33/37] malloc: Add SIMPLE_MEMALIGN to simplify memalign for code size List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/2AB2RHURPCMNJZDW44BU36VZLXZOLGBX/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
malloc: Import dlmalloc 2.8.6
|
|
Commit Message
Simon Glass
Dec. 1, 2025, 5:05 p.m. UTC
From: Simon Glass <simon.glass@canonical.com> Add a new SIMPLE_MEMALIGN to remove the fallback-retry logic from memalign(), to reduce code sizein SPL. The fallback mechanism attempts multiple allocation strategies: 1. Over-allocate to guarantee finding aligned space 2. If that fails, allocate exact size and check if aligned 3. If not aligned, free and retry with calculated extra space While this fallback is useful in low-memory situations, SPL typically has predictable memory usage and sufficient heap space for the initial over-allocation to succeed. The fallback adds code complexity without obvious practical benefit. This reduces code size on imx8mp_venice (for example) SPL by 74 bytes. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- common/dlmalloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 13ae0e10918..65bfb97e1db 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -597,9 +597,11 @@ static inline void MALLOC_COPY(void *dest, const void *src, size_t sz) { memcpy( #if CONFIG_IS_ENABLED(SYS_MALLOC_SMALL) #define NO_REALLOC_IN_PLACE 1 +#define SIMPLE_MEMALIGN 1 #define NO_TREE_BINS 1 #else #define NO_TREE_BINS 0 +#define SIMPLE_MEMALIGN 0 #endif /* Use simplified sys_alloc for non-sandbox builds */ @@ -5260,7 +5262,7 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); -#ifdef __UBOOT__ +#if defined(__UBOOT__) && !SIMPLE_MEMALIGN /* * The attempt to over-allocate (with a size large enough to guarantee the * ability to find an aligned region within allocated memory) failed.