Repository navigation
mm: replace mm_heap_config_s.heap with an allocheap flag - #21722
Merged
Merged
Conversation
Add the blank line after declarations that tools/nxstyle requires, so later changes to this file pass checkpatch. No functional change. Signed-off-by: Bowen Wang <[email protected]>
When mm_heap_config_s.heap is set, mm_initialize_heap() allocates the struct mm_heap_s from that heap with mm_malloc()/mm_memalign(). With CONFIG_MM_UMM_CUSTOMIZE_MANAGER (e.g. sim), the user heap is managed by sim_ummheap and is not a struct mm_heap_s, so the caller cannot pass a usable heap pointer here. Replace the heap pointer with a bool allocheap and allocate the heap struct with lib_memalign(), which picks kmm_memalign() or memalign() depending on the build. Drop KRN_HEAP, whose only user was rptun. Signed-off-by: Bowen Wang <[email protected]>
xiaoxiang781216
approved these changes
Nov 11, 2026
|
GUIDINGLI
approved these changes
Nov 12, 2026
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mm_heap_config_s.heaplets the caller askmm_initialize_heap()toallocate the
struct mm_heap_sfrom another heap instead of carving itout of the new region. The struct is then allocated with
mm_malloc(config->heap, ...)(mm_memalign()in tlsf), so the callerhas to hand in a real
struct mm_heap_s *. WithCONFIG_MM_UMM_CUSTOMIZE_MANAGER(sim) the user heap is managed bysim_ummheap and there is no such struct to pass.
Replace the pointer with a
bool allocheapand allocate the struct withlib_memalign(), which resolves tokmm_memalign()in the kernel andmemalign()otherwise.KRN_HEAPexisted only to fill that field forrptun, so it is removed and rptun sets
allocheap = true.that master already has)
Impact
struct mm_heap_config_slosesheapand gainsallocheap;KRN_HEAPis removed. In tree the only user was drivers/rptun.Out-of-tree code that set
config.heapmust setallocheap = trueinstead.
in-region layout, unchanged.
Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
rptun is the only in-tree user of the allocate-the-struct path: each
carveout in the resource table gets its own heap through
rptun_init_carveout(). The rpmsg baseline exercises it on bothmanagers:
uname -a(server)rpmsg dump all(server)rpmsg ping all 10 1024 3 0(server)uname -a(proxy)rpmsg ping all 10 1024 3 0(proxy)mount -t rpmsgfs -o cpu=server,fs=/proc /sp(proxy)cat /sp/version(proxy)rpmsg dump all(proxy)uname -a(server)uname -a(proxy)rpmsg dump all(server)rpmsg ping all 10 1024 3 0(server)rpmsg ping all 10 1024 3 0(proxy)mount -t rpmsgfs -o cpu=server,fs=/proc /sp(proxy)cat /sp/version(proxy)Same baseline on sim:rpserver + sim:rpproxy with
CONFIG_MM_TLSF_MANAGER=y(CONFIG_MM_DEFAULT_MANAGERunset) on bothsides: 8/8 pass.
Before/after with the custom user heap manager: sim:rpserver +
sim:rpproxy, both with
CONFIG_MM_UMM_CUSTOMIZE_MANAGER=yadded, samebaseline cases.
On master
rptun_init_carveout()passesKRN_HEAP(g_mmheap) tomm_initialize_heap(), which callsmm_malloc()on it. Under the custommanager
g_mmheappoints to sim_ummheap's ownstruct mm_heap_s, somm_lock()takes a field of it as a mutex:master, gdb on sim:rpserver
Build only: sim:asan (
CONFIG_MM_UMM_CUSTOMIZE_MANAGER=yin itsdefconfig).
No regression in rpmsg: sim:rpserver/rpproxy and qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master needs for nxinit to start nsh there; unrelated to this change.