current.h (7443b296e699e6922f5be243c8d2e316de8cacbe) current.h (c063a217bc0726c2560138229de5673dbb253a02)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_CURRENT_H
3#define _ASM_X86_CURRENT_H
4
5#include <linux/compiler.h>
6
7#ifndef __ASSEMBLY__
8
9#include <linux/cache.h>
10#include <asm/percpu.h>
11
12struct task_struct;
13
14struct pcpu_hot {
15 union {
16 struct {
17 struct task_struct *current_task;
18 int preempt_count;
19 int cpu_number;
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_CURRENT_H
3#define _ASM_X86_CURRENT_H
4
5#include <linux/compiler.h>
6
7#ifndef __ASSEMBLY__
8
9#include <linux/cache.h>
10#include <asm/percpu.h>
11
12struct task_struct;
13
14struct pcpu_hot {
15 union {
16 struct {
17 struct task_struct *current_task;
18 int preempt_count;
19 int cpu_number;
20 unsigned long top_of_stack;
20 };
21 u8 pad[64];
22 };
23};
24static_assert(sizeof(struct pcpu_hot) == 64);
25
26DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot);
27
28static __always_inline struct task_struct *get_current(void)
29{
30 return this_cpu_read_stable(pcpu_hot.current_task);
31}
32
33#define current get_current()
34
35#endif /* __ASSEMBLY__ */
36
37#endif /* _ASM_X86_CURRENT_H */
21 };
22 u8 pad[64];
23 };
24};
25static_assert(sizeof(struct pcpu_hot) == 64);
26
27DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot);
28
29static __always_inline struct task_struct *get_current(void)
30{
31 return this_cpu_read_stable(pcpu_hot.current_task);
32}
33
34#define current get_current()
35
36#endif /* __ASSEMBLY__ */
37
38#endif /* _ASM_X86_CURRENT_H */