mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
ed8d9adf35
This is very useful for some common things like 'get_current()' and 'get_thread_info()', which can be used multiple times in a function, and where the result is cacheable. tj: Added the magical undocumented "P" modifier to UP __percpu_arg() to force gcc to dereference the pointer value passed in via the "p" input constraint. Without this, percpu_read_stable() returns the address of the percpu variable. Also added comment explaining the difference between percpu_read() and percpu_read_stable(). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
22 lines
402 B
C
22 lines
402 B
C
#ifndef _ASM_X86_CURRENT_H
|
|
#define _ASM_X86_CURRENT_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <asm/percpu.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
struct task_struct;
|
|
|
|
DECLARE_PER_CPU(struct task_struct *, current_task);
|
|
|
|
static __always_inline struct task_struct *get_current(void)
|
|
{
|
|
return percpu_read_stable(current_task);
|
|
}
|
|
|
|
#define current get_current()
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_X86_CURRENT_H */
|