app shared memory placeholders waste memory #13923
Labels
area: Memory Protection
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Uh oh!
There was an error while loading. Please reload this page.
For application shared memory partitions declared with K_APPMEM_PARTITION_DEFINE(), we insert a placeholder char symbol in each partition.
If a partition is declared with K_APPMEM_PARTITION, but never has any
data assigned to its contents, then no symbols with its prefix will end
up in the symbol table. This prevents gen_app_partitions.py from detecting
that the partition exists, and the linker symbols which specify partition
bounds will not be generated, resulting in build errors.
However, wasting a byte like this can actually waste a great deal more memory on power-of-two systems. If I declare a buffer of some power of two size and declare a partition for it, say 256 bytes, the extra char for the placeholder will push the section to 257 bytes, and a region of 512 bytes will be created instead.
Also, empty sections can take up a lot of room on MMU-based systems, since a section of size 1 results in an entire 4k page being consumed on x86.
We need to allow zero-sized partitions without wasting memory like this, and not increase the size of partitions that do have data in them. For example, depending on the C library and kernel configuration, z_libc_partition may be empty or z_malloc_partition may be empty.
The text was updated successfully, but these errors were encountered: