malloc: Add an option to disable mcheck-backtrace collection

Backtrace collection is relatively expensive and can significantly slow
down malloc()-heavy code when mcheck is enabled.

Add a new CONFIG_MCHECK_BACKTRACE option (default y) to allow disabling
backtrace collection while keeping the other mcheck features (canaries,
double-free detection, etc.) enabled. This allows using mcheck with less
overhead when caller information is not needed.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2026-01-02 06:43:34 -07:00
parent 7856369dc2
commit 1d306039ce
3 changed files with 25 additions and 0 deletions

View File

@@ -130,6 +130,13 @@ Main U-Boot (post-relocation)
``malloc dump``. This significantly increases memory overhead and should
only be used for debugging. Default: n
``CONFIG_MCHECK_BACKTRACE``
Bool to enable backtrace collection for mcheck caller information. When
enabled (the default), each allocation records a stack backtrace showing
where it was made. This is useful for debugging memory leaks but adds
overhead to every malloc call. Disable this to reduce mcheck overhead
while keeping the canary checks and double-free detection. Default: y
xPL Boot Phases
~~~~~~~~~~~~~~~