xref: /linux/tools/perf/util/bpf_skel/lock_data.h (revision 824b18f607d82503a956d3e00f9e9c0b24efcbca)
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Data structures shared between BPF and tools. */
3 #ifndef UTIL_BPF_SKEL_LOCK_DATA_H
4 #define UTIL_BPF_SKEL_LOCK_DATA_H
5 
6 struct owner_tracing_data {
7 	u32 pid; // Who has the lock.
8 	u32 count; // How many waiters for this lock.
9 	u64 timestamp; // The time while the owner acquires lock and contention is going on.
10 	s32 stack_id; // Identifier for `owner_stat`, which stores as value in `owner_stacks`
11 };
12 
13 struct tstamp_data {
14 	u64 timestamp;
15 	u64 lock;
16 	u64 cgroup_id;
17 	u32 flags;
18 	s32 stack_id;
19 };
20 
21 struct contention_key {
22 	s32 stack_id;
23 	u32 pid;
24 	u64 lock_addr_or_cgroup;
25 };
26 
27 #define TASK_COMM_LEN  16
28 
29 struct contention_task_data {
30 	char comm[TASK_COMM_LEN];
31 };
32 
33 /* default buffer size */
34 #define MAX_ENTRIES  16384
35 
36 /*
37  * Upper bits of the flags in the contention_data are used to identify
38  * some well-known locks which do not have symbols (non-global locks).
39  */
40 #define LCD_F_MMAP_LOCK		(1U << 31)
41 #define LCD_F_SIGHAND_LOCK	(1U << 30)
42 
43 #define LCB_F_SLAB_ID_SHIFT	16
44 #define LCB_F_SLAB_ID_START	(1U << 16)
45 #define LCB_F_SLAB_ID_END	(1U << 26)
46 #define LCB_F_SLAB_ID_MASK	0x03FF0000U
47 
48 #define LCB_F_TYPE_MAX		(1U << 7)
49 #define LCB_F_TYPE_MASK		0x0000007FU
50 
51 #define SLAB_NAME_MAX  28
52 
53 struct contention_data {
54 	u64 total_time;
55 	u64 min_time;
56 	u64 max_time;
57 	u32 count;
58 	u32 flags;
59 };
60 
61 enum lock_aggr_mode {
62 	LOCK_AGGR_ADDR = 0,
63 	LOCK_AGGR_TASK,
64 	LOCK_AGGR_CALLER,
65 	LOCK_AGGR_CGROUP,
66 };
67 
68 enum lock_class_sym {
69 	LOCK_CLASS_NONE,
70 	LOCK_CLASS_RQLOCK,
71 	LOCK_CLASS_ZONE_LOCK,
72 };
73 
74 struct slab_cache_data {
75 	u32 id;
76 	char name[SLAB_NAME_MAX];
77 };
78 
79 #endif /* UTIL_BPF_SKEL_LOCK_DATA_H */
80