xref: /linux/include/linux/unwind_deferred_types.h (revision 6c26fbe8c9d3e932dce6afe2505b19b4b261cae9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_UNWIND_USER_DEFERRED_TYPES_H
3 #define _LINUX_UNWIND_USER_DEFERRED_TYPES_H
4 
5 #include <linux/types.h>
6 #include <linux/atomic.h>
7 
8 struct unwind_cache {
9 	unsigned long		unwind_completed;
10 	unsigned int		nr_entries;
11 	unsigned long		entries[];
12 };
13 
14 /*
15  * The unwind_task_id is a unique identifier that maps to a user space
16  * stacktrace. It is generated the first time a deferred user space
17  * stacktrace is requested after a task has entered the kerenl and
18  * is cleared to zero when it exits. The mapped id will be a non-zero
19  * number.
20  *
21  * To simplify the generation of the 64 bit number, 32 bits will be
22  * the CPU it was generated on, and the other 32 bits will be a per
23  * cpu counter that gets incremented by two every time a new identifier
24  * is generated. The LSB will always be set to keep the value
25  * from being zero.
26  */
27 union unwind_task_id {
28 	struct {
29 		u32		cpu;
30 		u32		cnt;
31 	};
32 	u64			id;
33 };
34 
35 struct unwind_task_info {
36 	atomic_long_t		unwind_mask;
37 	struct unwind_cache	*cache;
38 	struct callback_head	work;
39 	union unwind_task_id	id;
40 };
41 
42 struct unwind_work;
43 struct unwind_stacktrace;
44 
45 typedef void (*unwind_callback_t)(struct unwind_work *work,
46 				  struct unwind_stacktrace *trace,
47 				  u64 cookie);
48 
49 struct unwind_work {
50 	struct list_head		list;
51 	unwind_callback_t		func;
52 	int				bit;
53 };
54 
55 #endif /* _LINUX_UNWIND_USER_DEFERRED_TYPES_H */
56