zephyr/kernel/include
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
..
gen_offset.h arch: remove the use of z_arch_esf_t completely from internal 2024-06-04 14:02:51 -05:00
ipi.h kernel: Add CONFIG_IPI_OPTIMIZE 2024-06-04 22:35:54 -04:00
kernel_arch_interface.h arch: add interface to dump privileged stack in coredump 2024-09-21 11:29:39 +02:00
kernel_internal.h riscv: pmp: enable stackguard without multithreading 2024-11-20 08:25:49 -05:00
kernel_offsets.h arch: riscv: fill all IRQ stacks with 0xAA 2024-09-13 09:17:34 +02:00
kernel_tls.h linker: Round TLS sizes up in linker script 2024-02-25 22:28:56 -05:00
ksched.h kernel: Begin abstracting out _sched_spinlock 2024-10-21 18:38:00 -05:00
kswap.h arch: add new interfaces to set/get the current thread of current CPU 2024-11-23 20:12:24 -05:00
kthread.h kernel: make z_is_idle_thread_entry take code ptr 2024-11-18 14:02:56 -05:00
mmu.h kernel: mm: rename z_num_pagefaults_get to k_mem_num_* 2024-06-12 21:13:26 -04:00
offsets_short.h build: namespace the generated headers with zephyr/ 2024-05-28 22:03:55 +02:00
priority_q.h kernel: Move run queue initialization 2024-11-16 15:20:15 -05:00
timeout_q.h kernel: add closing comments to config endifs 2024-03-25 18:03:31 -04:00
wait_q.h kernel: move priority queue handling to own file/header 2024-03-02 15:06:45 +01:00