kernel: align thread stack size declaration

When thread stack is defined as an array, K_THREAD_STACK_LEN()
is used to calculate the size for each stack in the array.
However, standalone thread stack has its size calculated by
Z_THREAD_STACK_SIZE_ADJUST() instead. Depending on the arch
alignment requirement, they may not be the same... which
could cause some confusions. So align them both to use
K_THREAD_STACK_LEN().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2024-03-22 14:11:49 -07:00 committed by Anas Nashif
commit d34351d994
7 changed files with 12 additions and 12 deletions

View file

@ -384,7 +384,7 @@ static char *setup_thread_stack(struct k_thread *new_thread,
#ifdef CONFIG_USERSPACE
if (z_stack_is_user_capable(stack)) {
stack_obj_size = Z_THREAD_STACK_SIZE_ADJUST(stack_size);
stack_obj_size = K_THREAD_STACK_LEN(stack_size);
stack_buf_start = K_THREAD_STACK_BUFFER(stack);
stack_buf_size = stack_obj_size - K_THREAD_STACK_RESERVED;
} else

View file

@ -59,13 +59,13 @@ static struct k_spinlock objfree_lock; /* k_object_free */
#if defined(CONFIG_ARM_MPU) || defined(CONFIG_ARC_MPU)
#define STACK_ELEMENT_DATA_SIZE(size) \
(sizeof(struct z_stack_data) + CONFIG_PRIVILEGED_STACK_SIZE + \
Z_THREAD_STACK_OBJ_ALIGN(size) + Z_THREAD_STACK_SIZE_ADJUST(size))
Z_THREAD_STACK_OBJ_ALIGN(size) + K_THREAD_STACK_LEN(size))
#else
#define STACK_ELEMENT_DATA_SIZE(size) (sizeof(struct z_stack_data) + \
Z_THREAD_STACK_SIZE_ADJUST(size))
K_THREAD_STACK_LEN(size))
#endif /* CONFIG_ARM_MPU || CONFIG_ARC_MPU */
#else
#define STACK_ELEMENT_DATA_SIZE(size) Z_THREAD_STACK_SIZE_ADJUST(size)
#define STACK_ELEMENT_DATA_SIZE(size) K_THREAD_STACK_LEN(size)
#endif /* CONFIG_GEN_PRIV_STACKS */
#endif /* CONFIG_DYNAMIC_OBJECTS */