zephyr/arch
Yong Cong Sin d26c712258 arch: add new interfaces to set/get the current thread of current CPU
Add the following arch-specific APIs:
- arch_curr_thread()
- arch_set_curr_thread()

which allow SMP architectures to implement a faster "get current
thread pointer" than the default provided by the kernel. The 'set'
function is required for the 'get' to work, more on that later.

When `CONFIG_ARCH_HAS_CUSTOM_CURRENT_IMPL` is selected, calls to
`_current` & `k_sched_current_thread_query()` will be redirected to
`arch_curr_thread()`, which ideally should translate into a single
instruction read, avoiding the current
"lock > read CPU > read current thread > unlock" path in SMP
architectures and thus greatly improves the read performance.

However, since the kernel relies on a copy of the "current thread"s on
every CPU for certain operations (i.e. to compare the priority of the
currently scheduled thread on another CPU to determine if IPI should be
sent), we can't eliminate the copy of "current thread" (`current`) from
the `struct _cpu` and therefore the kernel now has to invoke
`arch_set_curr_thread()` in addition to what it has been doing. This
means that it will take slightly longer (most likely one instruction
write) to change the current thread pointer on the current
CPU.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-11-23 20:12:24 -05:00
..
arc llext: fix unaligned access for ARC 2024-11-21 14:46:08 +01:00
arm arch: arm: cleanup of soc flags in arch 2024-11-16 15:56:11 -05:00
arm64 init: support per-core init hook 2024-11-16 14:04:25 -05:00
common arch: common: fix copy for ramfunc region during XIP init 2024-11-06 10:19:08 -08:00
mips init: support per-core init hook 2024-11-16 14:04:25 -05:00
nios2 init: support per-core init hook 2024-11-16 14:04:25 -05:00
posix init: support per-core init hook 2024-11-16 14:04:25 -05:00
riscv riscv: pmp: don't reconfigure modes 2024-11-20 16:04:15 -05:00
sparc init: support per-core init hook 2024-11-16 14:04:25 -05:00
x86 init: support per-core init hook 2024-11-16 14:04:25 -05:00
xtensa LLEXT: fix advanced uses of detached sections 2024-11-16 15:28:00 -05:00
archs.yml hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00
CMakeLists.txt cmake: enable -Wshadow partially for in-tree code 2023-08-22 11:39:58 +02:00
Kconfig arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
Kconfig.v1 hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00
Kconfig.v2 hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00