John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_THREAD_H |
| 2 | #define __PERF_THREAD_H |
| 3 | |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 4 | #include <linux/rbtree.h> |
Frederic Weisbecker | 1902efe | 2013-09-11 16:56:44 +0200 | [diff] [blame] | 5 | #include <linux/list.h> |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 6 | #include <unistd.h> |
Arnaldo Carvalho de Melo | 9d2f8e2 | 2012-10-06 15:43:20 -0300 | [diff] [blame] | 7 | #include <sys/types.h> |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 8 | #include "symbol.h" |
David Ahern | 1f3878c | 2013-11-18 13:32:47 -0700 | [diff] [blame] | 9 | #include <strlist.h> |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 10 | |
Adrian Hunter | 00447cc | 2014-10-30 16:09:42 +0200 | [diff] [blame] | 11 | struct thread_stack; |
| 12 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 13 | struct thread { |
Arnaldo Carvalho de Melo | 720a3ae | 2010-06-17 08:37:44 -0300 | [diff] [blame] | 14 | union { |
| 15 | struct rb_node rb_node; |
| 16 | struct list_head node; |
| 17 | }; |
Arnaldo Carvalho de Melo | 93d5731 | 2014-03-21 17:57:01 -0300 | [diff] [blame] | 18 | struct map_groups *mg; |
Adrian Hunter | 99d725f | 2013-08-26 16:00:19 +0300 | [diff] [blame] | 19 | pid_t pid_; /* Not all tools update this */ |
Adrian Hunter | 3805123 | 2013-07-04 16:20:31 +0300 | [diff] [blame] | 20 | pid_t tid; |
David Ahern | 70c57ef | 2013-05-25 22:47:10 -0600 | [diff] [blame] | 21 | pid_t ppid; |
Adrian Hunter | bf49c35 | 2014-07-22 16:17:24 +0300 | [diff] [blame] | 22 | int cpu; |
Ingo Molnar | 0ec04e1 | 2009-09-16 17:40:48 +0200 | [diff] [blame] | 23 | char shortname[3]; |
Arnaldo Carvalho de Melo | faa5c5c | 2010-02-19 23:02:07 -0200 | [diff] [blame] | 24 | bool comm_set; |
David Ahern | 236a3bb | 2013-08-14 08:49:27 -0600 | [diff] [blame] | 25 | bool dead; /* if set thread has exited */ |
Frederic Weisbecker | 1902efe | 2013-09-11 16:56:44 +0200 | [diff] [blame] | 26 | struct list_head comm_list; |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 27 | int comm_len; |
Adrian Hunter | 0db15b1 | 2014-10-23 13:45:13 +0300 | [diff] [blame] | 28 | u64 db_id; |
Xiao Guangrong | bcf6edc | 2012-09-17 16:31:15 +0800 | [diff] [blame] | 29 | |
| 30 | void *priv; |
Adrian Hunter | 00447cc | 2014-10-30 16:09:42 +0200 | [diff] [blame] | 31 | struct thread_stack *ts; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 32 | }; |
| 33 | |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 34 | struct machine; |
Namhyung Kim | 4dfced3 | 2013-09-13 16:28:57 +0900 | [diff] [blame] | 35 | struct comm; |
Arnaldo Carvalho de Melo | 4b8cf84 | 2010-03-25 19:58:58 -0300 | [diff] [blame] | 36 | |
Adrian Hunter | 99d725f | 2013-08-26 16:00:19 +0300 | [diff] [blame] | 37 | struct thread *thread__new(pid_t pid, pid_t tid); |
Jiri Olsa | cddcef6 | 2014-04-09 20:54:29 +0200 | [diff] [blame] | 38 | int thread__init_map_groups(struct thread *thread, struct machine *machine); |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 39 | void thread__delete(struct thread *thread); |
David Ahern | 236a3bb | 2013-08-14 08:49:27 -0600 | [diff] [blame] | 40 | static inline void thread__exited(struct thread *thread) |
| 41 | { |
| 42 | thread->dead = true; |
| 43 | } |
Arnaldo Carvalho de Melo | 591765f | 2010-07-30 18:28:42 -0300 | [diff] [blame] | 44 | |
Adrian Hunter | 65de51f | 2014-07-31 09:00:44 +0300 | [diff] [blame] | 45 | int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp, |
| 46 | bool exec); |
| 47 | static inline int thread__set_comm(struct thread *thread, const char *comm, |
| 48 | u64 timestamp) |
| 49 | { |
| 50 | return __thread__set_comm(thread, comm, timestamp, false); |
| 51 | } |
| 52 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 53 | int thread__comm_len(struct thread *thread); |
Namhyung Kim | 4dfced3 | 2013-09-13 16:28:57 +0900 | [diff] [blame] | 54 | struct comm *thread__comm(const struct thread *thread); |
Adrian Hunter | 65de51f | 2014-07-31 09:00:44 +0300 | [diff] [blame] | 55 | struct comm *thread__exec_comm(const struct thread *thread); |
Frederic Weisbecker | b9c5143 | 2013-09-11 14:46:56 +0200 | [diff] [blame] | 56 | const char *thread__comm_str(const struct thread *thread); |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 57 | void thread__insert_map(struct thread *thread, struct map *map); |
Frederic Weisbecker | 162f0be | 2013-09-11 16:18:24 +0200 | [diff] [blame] | 58 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); |
Arnaldo Carvalho de Melo | 3f067dc | 2012-12-07 17:39:39 -0300 | [diff] [blame] | 59 | size_t thread__fprintf(struct thread *thread, FILE *fp); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 60 | |
Arnaldo Carvalho de Melo | bb871a9 | 2014-10-23 12:50:25 -0300 | [diff] [blame] | 61 | void thread__find_addr_map(struct thread *thread, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 62 | u8 cpumode, enum map_type type, u64 addr, |
Adrian Hunter | 326f59b | 2013-08-08 14:32:27 +0300 | [diff] [blame] | 63 | struct addr_location *al); |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 64 | |
Arnaldo Carvalho de Melo | bb871a9 | 2014-10-23 12:50:25 -0300 | [diff] [blame] | 65 | void thread__find_addr_location(struct thread *thread, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 66 | u8 cpumode, enum map_type type, u64 addr, |
Adrian Hunter | 61710bd | 2013-08-08 14:32:26 +0300 | [diff] [blame] | 67 | struct addr_location *al); |
David Ahern | ba58041 | 2013-06-07 16:22:12 -0600 | [diff] [blame] | 68 | |
Arnaldo Carvalho de Melo | 52a3cb8 | 2014-03-11 16:16:49 -0300 | [diff] [blame] | 69 | void thread__find_cpumode_addr_location(struct thread *thread, |
Arnaldo Carvalho de Melo | 52a3cb8 | 2014-03-11 16:16:49 -0300 | [diff] [blame] | 70 | enum map_type type, u64 addr, |
| 71 | struct addr_location *al); |
| 72 | |
David Ahern | ba58041 | 2013-06-07 16:22:12 -0600 | [diff] [blame] | 73 | static inline void *thread__priv(struct thread *thread) |
| 74 | { |
| 75 | return thread->priv; |
| 76 | } |
| 77 | |
| 78 | static inline void thread__set_priv(struct thread *thread, void *p) |
| 79 | { |
| 80 | thread->priv = p; |
| 81 | } |
David Ahern | 1f3878c | 2013-11-18 13:32:47 -0700 | [diff] [blame] | 82 | |
| 83 | static inline bool thread__is_filtered(struct thread *thread) |
| 84 | { |
| 85 | if (symbol_conf.comm_list && |
| 86 | !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) { |
| 87 | return true; |
| 88 | } |
| 89 | |
| 90 | return false; |
| 91 | } |
| 92 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 93 | #endif /* __PERF_THREAD_H */ |