Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
8b40f521 JK |
2 | #ifndef __PERF_THREAD_H |
3 | #define __PERF_THREAD_H | |
4 | ||
e34f5b11 | 5 | #include <linux/refcount.h> |
6baa0a5a | 6 | #include <linux/rbtree.h> |
1902efe7 | 7 | #include <linux/list.h> |
6baa0a5a | 8 | #include <unistd.h> |
9d2f8e22 | 9 | #include <sys/types.h> |
6baa0a5a | 10 | #include "symbol.h" |
1f3878c1 | 11 | #include <strlist.h> |
e03eaa40 | 12 | #include <intlist.h> |
6baa0a5a | 13 | |
00447ccd | 14 | struct thread_stack; |
f83c0415 | 15 | struct unwind_libunwind_ops; |
00447ccd | 16 | |
9958e1f0 | 17 | struct thread { |
720a3aeb ACM |
18 | union { |
19 | struct rb_node rb_node; | |
20 | struct list_head node; | |
21 | }; | |
93d5731d | 22 | struct map_groups *mg; |
99d725fc | 23 | pid_t pid_; /* Not all tools update this */ |
38051234 | 24 | pid_t tid; |
70c57efb | 25 | pid_t ppid; |
bf49c35f | 26 | int cpu; |
e34f5b11 | 27 | refcount_t refcnt; |
0ec04e16 | 28 | char shortname[3]; |
faa5c5c3 | 29 | bool comm_set; |
86066064 | 30 | int comm_len; |
236a3bbd | 31 | bool dead; /* if set thread has exited */ |
f3b3614a | 32 | struct list_head namespaces_list; |
1902efe7 | 33 | struct list_head comm_list; |
0db15b1e | 34 | u64 db_id; |
bcf6edcd XG |
35 | |
36 | void *priv; | |
00447ccd | 37 | struct thread_stack *ts; |
843ff37b | 38 | struct nsinfo *nsinfo; |
e583d70c | 39 | #ifdef HAVE_LIBUNWIND_SUPPORT |
f83c0415 HK |
40 | void *addr_space; |
41 | struct unwind_libunwind_ops *unwind_libunwind_ops; | |
e583d70c | 42 | #endif |
6baa0a5a FW |
43 | }; |
44 | ||
743eb868 | 45 | struct machine; |
f3b3614a | 46 | struct namespaces; |
4dfced35 | 47 | struct comm; |
4b8cf846 | 48 | |
99d725fc | 49 | struct thread *thread__new(pid_t pid, pid_t tid); |
cddcef60 | 50 | int thread__init_map_groups(struct thread *thread, struct machine *machine); |
316c7136 | 51 | void thread__delete(struct thread *thread); |
f3b623b8 ACM |
52 | |
53 | struct thread *thread__get(struct thread *thread); | |
54 | void thread__put(struct thread *thread); | |
55 | ||
56 | static inline void __thread__zput(struct thread **thread) | |
57 | { | |
58 | thread__put(*thread); | |
59 | *thread = NULL; | |
60 | } | |
61 | ||
62 | #define thread__zput(thread) __thread__zput(&thread) | |
63 | ||
236a3bbd DA |
64 | static inline void thread__exited(struct thread *thread) |
65 | { | |
66 | thread->dead = true; | |
67 | } | |
591765fd | 68 | |
f3b3614a HB |
69 | struct namespaces *thread__namespaces(const struct thread *thread); |
70 | int thread__set_namespaces(struct thread *thread, u64 timestamp, | |
71 | struct namespaces_event *event); | |
72 | ||
65de51f9 AH |
73 | int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp, |
74 | bool exec); | |
75 | static inline int thread__set_comm(struct thread *thread, const char *comm, | |
76 | u64 timestamp) | |
77 | { | |
78 | return __thread__set_comm(thread, comm, timestamp, false); | |
79 | } | |
80 | ||
2f3027ac ACM |
81 | int thread__set_comm_from_proc(struct thread *thread); |
82 | ||
316c7136 | 83 | int thread__comm_len(struct thread *thread); |
4dfced35 | 84 | struct comm *thread__comm(const struct thread *thread); |
65de51f9 | 85 | struct comm *thread__exec_comm(const struct thread *thread); |
b9c5143a | 86 | const char *thread__comm_str(const struct thread *thread); |
8132a2a8 | 87 | int thread__insert_map(struct thread *thread, struct map *map); |
162f0bef | 88 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); |
3f067dca | 89 | size_t thread__fprintf(struct thread *thread, FILE *fp); |
8b40f521 | 90 | |
480ca357 AK |
91 | struct thread *thread__main_thread(struct machine *machine, struct thread *thread); |
92 | ||
bb871a9c | 93 | void thread__find_addr_map(struct thread *thread, |
743eb868 | 94 | u8 cpumode, enum map_type type, u64 addr, |
326f59bf | 95 | struct addr_location *al); |
59ee68ec | 96 | |
bb871a9c | 97 | void thread__find_addr_location(struct thread *thread, |
743eb868 | 98 | u8 cpumode, enum map_type type, u64 addr, |
61710bde | 99 | struct addr_location *al); |
ba58041a | 100 | |
52a3cb8c | 101 | void thread__find_cpumode_addr_location(struct thread *thread, |
52a3cb8c ACM |
102 | enum map_type type, u64 addr, |
103 | struct addr_location *al); | |
104 | ||
ba58041a DA |
105 | static inline void *thread__priv(struct thread *thread) |
106 | { | |
107 | return thread->priv; | |
108 | } | |
109 | ||
110 | static inline void thread__set_priv(struct thread *thread, void *p) | |
111 | { | |
112 | thread->priv = p; | |
113 | } | |
1f3878c1 DA |
114 | |
115 | static inline bool thread__is_filtered(struct thread *thread) | |
116 | { | |
117 | if (symbol_conf.comm_list && | |
118 | !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) { | |
119 | return true; | |
120 | } | |
121 | ||
e03eaa40 DA |
122 | if (symbol_conf.pid_list && |
123 | !intlist__has_entry(symbol_conf.pid_list, thread->pid_)) { | |
124 | return true; | |
125 | } | |
126 | ||
127 | if (symbol_conf.tid_list && | |
128 | !intlist__has_entry(symbol_conf.tid_list, thread->tid)) { | |
129 | return true; | |
130 | } | |
131 | ||
1f3878c1 DA |
132 | return false; |
133 | } | |
134 | ||
8b40f521 | 135 | #endif /* __PERF_THREAD_H */ |