zephyr/kernel
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
..
include arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
paging
atomic_c.c
banner.c
busy_wait.c
CMakeLists.txt
compiler_stack_protect.c arch: kernel: lib: toolchain: Standardize TLS keyword 2024-09-23 10:01:48 +02:00
condvar.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
cpu_mask.c kernel: Simplify k_thread_cpu_pin() 2024-09-20 09:02:38 +02:00
device.c
dynamic_disabled.c
dynamic.c
errno.c arch: kernel: lib: toolchain: Standardize TLS keyword 2024-09-23 10:01:48 +02:00
events.c
fatal.c
float.c
futex.c
idle.c
init_static.c
init.c zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY 2024-10-03 17:06:52 +01:00
ipi.c
irq_offload.c
Kconfig Revert "kernel: banner: Expose tainted builds" 2024-10-29 14:17:21 -05:00
Kconfig.device
Kconfig.init init: support per-core init hook 2024-11-16 14:04:25 -05:00
Kconfig.mem_domain
Kconfig.obj_core
Kconfig.smp kernel: remove CONFIG_MP_NUM_CPUS 2024-09-19 18:28:37 +01:00
Kconfig.vm
kheap.c
mailbox.c
main_weak.c
mem_domain.c
mem_slab.c kernel: mem_slab: always validate memory address on free 2024-11-16 15:54:56 -05:00
mempool.c
mmu.c arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
msg_q.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
mutex.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
nothread.c kernel: fix k_sleep in no multi-threading mode 2024-11-16 14:07:41 -05:00
obj_core.c
pipes.c
poll.c
priority_queues.c
queue.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
sched.c arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
sem.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
smp.c
spinlock_validate.c
stack.c kernel: Apply 'unlikely' attribute 2024-10-15 04:06:32 -04:00
system_work_q.c
thread_monitor.c style: kernel: comply with MISRA C:2012 Rule 15.6 2024-09-11 07:40:35 -04:00
thread.c arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
timeout.c
timer.c
timeslicing.c
usage.c
userspace_handler.c
userspace.c sys: util: use BITS_PER_BYTE macro instead of the magic number 8 2024-11-16 15:22:35 -05:00
version.c
work.c kernel: workq: Fix function format to avoid CI Warning 2024-11-20 10:15:20 +00:00
xip.c arch: common: fix copy for ramfunc region during XIP init 2024-11-06 10:19:08 -08:00