Current
static __always_inline struct task_struct *get_current(void)
{
if (IS_ENABLED(CONFIG_USE_X86_SEG_SUPPORT))
return this_cpu_read_const(const_pcpu_hot.current_task);
return this_cpu_read_stable(pcpu_hot.current_task);
}this_cpu_read() makes gcc load the percpu variable every time it is
accessed while this_cpu_read_stable() allows the value to be cached.
this_cpu_read_stable() is more efficient and can be used if its value
is guaranteed to be valid across cpus. The current users include
pcpu_hot.current_task and pcpu_hot.top_of_stack, both of which are
actually per-thread variables implemented as per-CPU variables and
thus stable for the duration of the respective task.Last updated