casaroli opened a new pull request, #21826:
URL: https://github.com/apache/nuttx/pull/21826

   depends-on: apache/nuttx/pull/21819
   
   ## Summary
   
   #21722 replaced `mm_malloc(config->heap, ...)` in `mm_initialize_heap()` 
with `lib_memalign(MM_ALIGN, sizeof(struct mm_heap_s))` for 
`config->allocheap`. The call links `memalign()` and `mm_memalign()` into every 
image that does not use them already, also when no caller sets `allocheap` 
(rptun is the only one in the tree). weact-stm32h750:sdcard with clang became 
448 bytes larger, and is one of the two configurations that #21819 makes fit 
again.
   
   `struct mm_heap_s` needs only its natural alignment, which `malloc()` gives. 
This PR uses `lib_malloc()`, as the code did before #21722 with `mm_malloc()`.
   
   ## Impact
   
   - The same alignment in every case that builds this file 
(`CONFIG_MM_DEFAULT_MANAGER`):
     - `mm_malloc()` returns `MM_ALIGN`-aligned blocks, also when 
`CONFIG_MM_DEFAULT_ALIGNMENT` makes `MM_ALIGN` larger (16 to 64). 
`mm_memalign()` with an alignment of `MM_ALIGN` or less calls `mm_malloc()` 
(`mm_memalign.c` asserts the result).
     - `lib_malloc()` and `lib_memalign()` use the same heap: `kmm_*` in the 
kernel (`__KERNEL__`), the user heap otherwise. This is true for flat, 
protected and kernel builds.
     - `CONFIG_MM_UMM_CUSTOMIZE_MANAGER` (sim host heap): `memalign(MM_ALIGN, 
...)` takes the same path as `malloc()` in `sim_ummheap.c`.
     - `CONFIG_MM_HEAP_MEMPOOL`: a block from the pool can have less than 
`MM_ALIGN` alignment, but the structure does not need more than its natural 
alignment (pointers, `size_t`, a mutex).
   - The TLSF manager (`mm/tlsf/mm_tlsf.c`) is not changed: it used 
`mm_memalign()` before #21722 too.
   - weact-stm32h750:sdcard (clang): 448 bytes less flash. Other images that 
link `memalign()` for other reasons do not change.
   - No API change. Documentation/ does not describe this, so there is no 
documentation change.
   
   ## Testing
   
   | Configuration | Build | Result |
   |---|---|---|
   | weact-stm32h750:sdcard, clang 17.0.1, CI docker image | Make | `flash` 
131584 B (master, overflow) -> 131136 B (this PR): 448 bytes less; with #21819 
too: 129088 B, links |
   | lm3s6965-ek:qemu-protected (protected), arm-none-eabi-gcc 13.2, CI docker 
image | Make | no warnings; `kflash` overflows as on master (#21819); with 
#21819 too: 129736 B, links (#21819 alone: 129752 B) |
   | mps2-an500:knsh (kernel), CI docker image | Make, `-Werror` | no warnings |
   | sim:nsh, CI docker image | Make, `-Werror` | no warnings |
   | qemu-armv8a:nsh (flat), aarch64-none-elf-gcc 14.2.1 | Make, `-Werror` | no 
warnings; ostest: `Exiting with status 0` (QEMU, HVF) |
   | qemu-armv8a:knsh (kernel), aarch64-none-elf-gcc 14.2.1 | Make, `-Werror` | 
no warnings; ostest: `Exiting with status 0` (QEMU, HVF) |
   | sim:rpserver + sim:rpproxy, CI docker image | Make, `-Werror` | master and 
this PR give the same result: server `rpmsg dump all`, `rpmsg ping all 10 1024 
3 0` pass, `/proc/meminfo` lists the carveout heaps `rng0_shm` and `rng1_shm` 
(65680 bytes each); proxy (over `cu /dev/ttyproxy`): `uname -a`, `rpmsg ping` 
pass |
   | sim:rpserver + sim:rpproxy with `MM_UMM_CUSTOMIZE_MANAGER=y` | Make, 
`-Werror` | server: `rpmsg dump all`, `rpmsg ping all 10 1024 3 0` pass, 
`/proc/meminfo` lists the carveout heaps `rng0_shm` and `rng1_shm`; proxy (over 
`cu /dev/ttyproxy`): `uname -a`, `rpmsg ping` pass |
   
   rptun creates a heap with `allocheap` set for each carveout 
(`rptun_init_carveout()`), so the sim rpmsg pair runs the changed line. No test 
in nuttx-apps calls `mm_initialize_heap()` with `allocheap`, and CI builds the 
rpmsg configurations but does not run them. The sim:rpserver runs disable 
`SIM_NETDEV` (no TAP device in the container).
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to