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#ifdef CONFIG_CALL_DEPTH_TRACKING 21 u64 call_depth; 22#endif 23 unsigned long top_of_stack; 24 void *hardirq_stack_ptr; 25 u16 softirq_pending; 26#ifdef CONFIG_X86_64 27 bool hardirq_stack_inuse; 28#else 29 void *softirq_stack_ptr; 30#endif 31 }; 32 u8 pad[64]; 33 }; 34}; 35static_assert(sizeof(struct pcpu_hot) == 64); 36 37DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot); 38 39static __always_inline struct task_struct *get_current(void) 40{ 41 return this_cpu_read_stable(pcpu_hot.current_task); 42} 43 44#define current get_current() 45 46#endif /* __ASSEMBLY__ */ 47 48#endif /* _ASM_X86_CURRENT_H */ 49