From 3e971d2e6d753519985a3e044d4dd21026ec1d12 Mon Sep 17 00:00:00 2001 From: wangbowen6 Date: Mon, 6 Mar 2023 16:10:31 +0800 Subject: [PATCH] mm_heap: double malloced memory default alignment (4 -> 8, 8 -> 16) Base on the gnu libc standard: https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html Change the default memory aligment to 8 bytes for 32-bit system and 16 bytes for 64-bit system. Signed-off-by: wangbowen6 --- mm/Kconfig | 2 +- mm/mm_heap/mm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 71a95c80fa..6d702f7629 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -63,7 +63,7 @@ config MM_KERNEL_HEAPSIZE config MM_DFAULT_ALIGNMENT int "Memory default alignment in bytes" - default 8 + default 0 range 0 64 ---help--- The memory default alignment in bytes, if this value is 0, the real diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index adc6f24d28..c787ace6af 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -111,7 +111,7 @@ #define MM_NNODES (MM_MAX_SHIFT - MM_MIN_SHIFT + 1) #if CONFIG_MM_DFAULT_ALIGNMENT == 0 -# define MM_ALIGN sizeof(uintptr_t) +# define MM_ALIGN (2 * sizeof(uintptr_t)) #else # define MM_ALIGN CONFIG_MM_DFAULT_ALIGNMENT #endif