kernel: add kconfig CONFIG_KERNEL_MEM_POOL

Adds a kconfig CONFIG_KERNEL_MEM_POOL to decide whether
kernel memory pool related code is compiled. This option
can be disabled to shrink code size. If k_heap is not
being used at all, kheap.c will also not be compiled,
resulting in further smaller code size.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2020-09-18 14:12:51 -07:00 committed by Anas Nashif
commit b5c2ff9397
2 changed files with 20 additions and 4 deletions

View file

@ -11,7 +11,6 @@ add_library(kernel
kheap.c
mailbox.c
mem_slab.c
mempool.c
msg_q.c
mutex.c
pipes.c
@ -42,9 +41,13 @@ target_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_C kernel PRIVATE atomic_c.c)
target_sources_ifdef(CONFIG_MMU kernel PRIVATE mmu.c)
target_sources_ifdef(CONFIG_POLL kernel PRIVATE poll.c)
if(${CONFIG_MEM_POOL_HEAP_BACKEND})
else()
target_sources(kernel PRIVATE mempool_sys.c)
if(${CONFIG_KERNEL_MEM_POOL})
target_sources(kernel PRIVATE mempool.c)
if(${CONFIG_MEM_POOL_HEAP_BACKEND})
else()
target_sources(kernel PRIVATE mempool_sys.c)
endif()
endif()
# The last 2 files inside the target_sources_ifdef should be

View file

@ -444,6 +444,16 @@ config NUM_PIPE_ASYNC_MSGS
Setting this option to 0 disables support for asynchronous
pipe messages.
config KERNEL_MEM_POOL
bool "Use Kernel Memory Pool"
default y
help
Enable the use of kernel memory pool.
Say y if unsure.
if KERNEL_MEM_POOL
config MEM_POOL_HEAP_BACKEND
bool "Use k_heap as the backend for k_mem_pool"
default y
@ -472,6 +482,9 @@ config HEAP_MEM_POOL_MIN_SIZE
This option specifies the size of the smallest block in the pool.
Option must be a power of 2 and lower than or equal to the size
of the entire pool.
endif # KERNEL_MEM_POOL
endmenu
config ARCH_HAS_CUSTOM_SWAP_TO_MAIN