diff mbox series

[v3,4/4] malloc: Enable SYS_MALLOC_RUNTIME_INIT by default in SPL

Message ID 20230928144458.2511087-5-sean.anderson@seco.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [v3,1/4] common: Only mark malloc initialized after mem_malloc_init | expand

Commit Message

Sean Anderson Sept. 28, 2023, 2:44 p.m. UTC
On boards with size restrictions, 1-2k can be a significant fraction of the
binary size. Add a new SPL version of SYS_MALLOC_RUNTIME_INIT. As this
trades text size for BSS size, enable it by default only for boards with at
least 16k of BSS.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v3:
- Don't enable SPL_SYS_MALLOC_RUNTIME_INIT if we are short on BSS

 Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Simon Glass Oct. 2, 2023, 1:16 a.m. UTC | #1
On Thu, 28 Sept 2023 at 08:45, Sean Anderson <sean.anderson@seco.com> wrote:
>
> On boards with size restrictions, 1-2k can be a significant fraction of the
> binary size. Add a new SPL version of SYS_MALLOC_RUNTIME_INIT. As this
> trades text size for BSS size, enable it by default only for boards with at
> least 16k of BSS.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> Changes in v3:
> - Don't enable SPL_SYS_MALLOC_RUNTIME_INIT if we are short on BSS
>
>  Kconfig | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 3967613b232..da5986e2fe8 100644
--- a/Kconfig
+++ b/Kconfig
@@ -414,6 +414,17 @@  config SYS_MALLOC_RUNTIME_INIT
          reduce the size of U-Boot by letting malloc's data reside in .bss
          instead of .data.
 
+config SPL_SYS_MALLOC_RUNTIME_INIT
+	bool "Initialize malloc's internal data at runtime in SPL"
+	default y if !SPL_BSS_LIMIT || SPL_BSS_MAX_SIZE >= 0x1000
+	depends on SPL
+	help
+	 Initialize malloc's internal data structures at SPL runtime, rather
+	 than at compile-time. This is necessary if relocating the malloc arena
+	 from a smaller static memory to a large DDR memory. It can also reduce
+	 the size of U-Boot by letting malloc's data reside in .bss instead of
+	 .data.
+
 config TOOLS_DEBUG
 	bool "Enable debug information for tools"
 	help