From: "Sascha Hauer" <s.hauer@pengutronix.de>
To: "Ahmad Fatoum" <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, "Ahmad Fatoum" <a.fatoum@pengutronix.de>
Subject: Re: [PATCH master 3/6] arch: introduce CONFIG_MALLOC_OFFSET
Date: Tue, 26 May 2026 06:17:21 +0000 [thread overview]
Message-ID: <E1wRl6P-0000000GF1E-191b@pty.whiteo.stw.pengutronix.de> (raw)
In-Reply-To: <20260522105852.2681680-4-a.fatoum@pengutronix.de>
On 2026-05-22 12:53, Ahmad Fatoum wrote:
> +config MALLOC_OFFSET
> + hex
> + default 0
> + prompt "relative malloc base offset (optional)"
> + depends on ARCH_HAS_MALLOC_OFFSET
> + help
> + Most boards should just leave this at the default zero and barebox
> + will dynamically determine the start of its eventual malloc area.
> + The currently employed heuristic is:
> +
> + - if the prebootloader reports 2GiB of initial memory or more,
> + start the malloc area at offset 1GiB from initial memory end.
> +
> + - otherwise, start the malloc area at middle of initial memory
> +
> + The malloc area is used for dynamic allocations by barebox, e.g.
> + to uncompress a kernel. The placement of final boot artifacts happens
> + outside of the malloc area and is not restricted to the initial
> + memory reported by the prebootloader.
> +
> + As this heuristic may not be suitable for devices with tight memory
> + constraints, setting a non-zero value here allows customizing the
> + offset used to start the malloc area.
> +
> + The MALLOC_OFFSET is calculated from end of initial memory to start
> + of the malloc area
I read the term offset as something added to the start of something, not
substracted from an end of something.
Maybe MALLOC_OFFSET should be exactly that: The offset between start of
DRAM and start of the malloc area. On a memory constrained hardware with
different DRAM sizes that's also likely the value you want to keep
constant as its given by your Kernel/initrd image size.
Other than that maybe the term we should talk about here is the area
that we use for barebox internal use and the area that's left for
placing the OS. Whether or not we start the malloc area at that boundary
isn't the point.
Something like BAREBOX_MEMORY_OFFSET:
config BAREBOX_MEMORY_OFFSET
hex "barebox runtime memory offset"
default 0x0
help
Offset from the start of DRAM at which the barebox runtime
region begins. DRAM below this offset is reserved as the OS
load region, used for staging the kernel, initrd and device
tree before boot. barebox itself — the relocated binary, BSS,
stack and malloc arena — lives at and above this offset and
will not allocate into the OS load region.
Set this large enough to hold the biggest OS image you expect
to boot, plus initrd and DTB.
A value of 0 selects the default split, which divides DRAM
into two equal halves: the lower half for the OS load region
and the upper half for the barebox runtime region. This is
suitable for most boards with modern DRAM sizes.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2026-05-26 6:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 10:53 [PATCH master 0/6] ARM: unify pbl and proper malloc area start Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 1/6] arch: introduce new CONFIG_ARCH_HAS_MALLOC_SIZE Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 2/6] ARM: explicitly state CONFIG_MALLOC_SIZE in defconfigs Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 3/6] arch: introduce CONFIG_MALLOC_OFFSET Ahmad Fatoum
2026-05-26 6:17 ` Sascha Hauer [this message]
2026-05-22 10:53 ` [PATCH master 4/6] ARM: switch to CONFIG_MALLOC_OFFSET Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 5/6] ARM: configs: drop CONFIG_MALLOC_SIZE=0x0 as it's now the default Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 6/6] ARM: place PBL malloc area at start of barebox proper malloc area Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1wRl6P-0000000GF1E-191b@pty.whiteo.stw.pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox