• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2 /* Copyright (c) 2021 Hengqi Chen */
3 
4 #ifndef __CORE_FIXES_BPF_H
5 #define __CORE_FIXES_BPF_H
6 
7 #include <vmlinux.h>
8 #include <bpf/bpf_core_read.h>
9 
10 /**
11  * commit 2f064a59a1 ("sched: Change task_struct::state") changes
12  * the name of task_struct::state to task_struct::__state
13  * see:
14  *     https://github.com/torvalds/linux/commit/2f064a59a1
15  */
16 struct task_struct___x {
17 	unsigned int __state;
18 };
19 
get_task_state(void * task)20 static __s64 get_task_state(void *task)
21 {
22 	struct task_struct___x *t = task;
23 
24 	if (bpf_core_field_exists(t->__state))
25 		return t->__state;
26 	return ((struct task_struct *)task)->state;
27 }
28 
29 #endif /* __CORE_FIXES_BPF_H */
30