From f5a0d4cd263ab424fb2387a62cf711efda4ef280 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 2 May 2022 14:39:07 -0700 Subject: [PATCH] arch: xtensa: Optimize cache management for pinned threads When building with CONFIG_SCHED_CPU_MASK_PIN_ONLY we can assume that a thread will always be executed in a same CPU and consequently skip the cache invalidation. Signed-off-by: Flavio Ceolin --- arch/xtensa/include/kernel_arch_func.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/xtensa/include/kernel_arch_func.h b/arch/xtensa/include/kernel_arch_func.h index fec6ff1b467..2df42d4c91e 100644 --- a/arch/xtensa/include/kernel_arch_func.h +++ b/arch/xtensa/include/kernel_arch_func.h @@ -84,6 +84,14 @@ static ALWAYS_INLINE void arch_cohere_stacks(struct k_thread *old_thread, : "=r"(a0save)); } + /* The following option ensures that a living thread will never + * be executed in a different CPU so we can safely return without + * invalidate and/or flush threads cache. + */ + if (IS_ENABLED(CONFIG_SCHED_CPU_MASK_PIN_ONLY)) { + return; + } + /* The "live" area (the region between the switch handle, * which is the stack pointer, and the top of the stack * memory) of the inbound stack needs to be invalidated if we