2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-09-24 18:02:18 +02:00
|
|
|
#ifndef __PERF_THREAD_H
|
|
|
|
|
#define __PERF_THREAD_H
|
|
|
|
|
|
2017-02-21 17:35:02 +02:00
|
|
|
#include <linux/refcount.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
#include <linux/rbtree.h>
|
2013-09-11 16:56:44 +02:00
|
|
|
#include <linux/list.h>
|
2019-01-28 00:07:40 +01:00
|
|
|
#include <stdio.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
#include <unistd.h>
|
2012-10-06 15:43:20 -03:00
|
|
|
#include <sys/types.h>
|
2019-01-27 11:31:39 +01:00
|
|
|
#include "srccode.h"
|
2019-01-28 00:07:40 +01:00
|
|
|
#include "symbol_conf.h"
|
2013-11-18 13:32:47 -07:00
|
|
|
#include <strlist.h>
|
2015-03-24 09:52:41 -06:00
|
|
|
#include <intlist.h>
|
2017-09-29 07:47:52 -07:00
|
|
|
#include "rwsem.h"
|
2020-03-19 13:25:10 -07:00
|
|
|
#include "event.h"
|
2020-03-19 13:25:11 -07:00
|
|
|
#include "callchain.h"
|
2009-08-14 12:21:53 +02:00
|
|
|
|
2019-01-28 00:07:40 +01:00
|
|
|
struct addr_location;
|
|
|
|
|
struct map;
|
2019-08-26 19:02:31 -03:00
|
|
|
struct perf_record_namespaces;
|
2014-10-30 16:09:42 +02:00
|
|
|
struct thread_stack;
|
2016-06-03 03:33:12 +00:00
|
|
|
struct unwind_libunwind_ops;
|
2014-10-30 16:09:42 +02:00
|
|
|
|
2020-03-19 13:25:10 -07:00
|
|
|
struct lbr_stitch {
|
2020-03-19 13:25:12 -07:00
|
|
|
struct list_head lists;
|
|
|
|
|
struct list_head free_lists;
|
2020-03-19 13:25:10 -07:00
|
|
|
struct perf_sample prev_sample;
|
2020-03-19 13:25:11 -07:00
|
|
|
struct callchain_cursor_node *prev_lbr_cursor;
|
2020-03-19 13:25:10 -07:00
|
|
|
};
|
|
|
|
|
|
2009-12-11 14:50:36 -02:00
|
|
|
struct thread {
|
2010-06-17 08:37:44 -03:00
|
|
|
union {
|
|
|
|
|
struct rb_node rb_node;
|
|
|
|
|
struct list_head node;
|
|
|
|
|
};
|
2019-11-25 22:07:43 -03:00
|
|
|
struct maps *maps;
|
2013-08-26 16:00:19 +03:00
|
|
|
pid_t pid_; /* Not all tools update this */
|
2013-07-04 16:20:31 +03:00
|
|
|
pid_t tid;
|
2013-05-25 22:47:10 -06:00
|
|
|
pid_t ppid;
|
2014-07-22 16:17:24 +03:00
|
|
|
int cpu;
|
2017-02-21 17:35:02 +02:00
|
|
|
refcount_t refcnt;
|
2010-02-19 23:02:07 -02:00
|
|
|
bool comm_set;
|
2015-05-15 17:29:56 -03:00
|
|
|
int comm_len;
|
2013-08-14 08:49:27 -06:00
|
|
|
bool dead; /* if set thread has exited */
|
2017-03-08 02:11:43 +05:30
|
|
|
struct list_head namespaces_list;
|
2017-09-29 07:47:52 -07:00
|
|
|
struct rw_semaphore namespaces_lock;
|
2013-09-11 16:56:44 +02:00
|
|
|
struct list_head comm_list;
|
2017-09-29 07:47:52 -07:00
|
|
|
struct rw_semaphore comm_lock;
|
2014-10-23 13:45:13 +03:00
|
|
|
u64 db_id;
|
2012-09-17 16:31:15 +08:00
|
|
|
|
|
|
|
|
void *priv;
|
2014-10-30 16:09:42 +02:00
|
|
|
struct thread_stack *ts;
|
2017-07-05 18:48:08 -07:00
|
|
|
struct nsinfo *nsinfo;
|
2018-12-03 16:18:48 -08:00
|
|
|
struct srccode_state srccode_state;
|
2018-09-20 11:05:39 -07:00
|
|
|
bool filter;
|
|
|
|
|
int filter_entry_depth;
|
2020-03-19 13:25:09 -07:00
|
|
|
|
|
|
|
|
/* LBR call stack stitch */
|
|
|
|
|
bool lbr_stitch_enable;
|
2020-03-19 13:25:10 -07:00
|
|
|
struct lbr_stitch *lbr_stitch;
|
2009-08-14 12:21:53 +02:00
|
|
|
};
|
|
|
|
|
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine;
|
2017-03-08 02:11:43 +05:30
|
|
|
struct namespaces;
|
2013-09-13 16:28:57 +09:00
|
|
|
struct comm;
|
2010-03-25 19:58:58 -03:00
|
|
|
|
2013-08-26 16:00:19 +03:00
|
|
|
struct thread *thread__new(pid_t pid, pid_t tid);
|
2019-11-25 21:58:33 -03:00
|
|
|
int thread__init_maps(struct thread *thread, struct machine *machine);
|
2013-11-05 15:32:36 -03:00
|
|
|
void thread__delete(struct thread *thread);
|
2015-03-02 22:21:35 -03:00
|
|
|
|
|
|
|
|
struct thread *thread__get(struct thread *thread);
|
|
|
|
|
void thread__put(struct thread *thread);
|
|
|
|
|
|
|
|
|
|
static inline void __thread__zput(struct thread **thread)
|
|
|
|
|
{
|
|
|
|
|
thread__put(*thread);
|
|
|
|
|
*thread = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define thread__zput(thread) __thread__zput(&thread)
|
|
|
|
|
|
2013-08-14 08:49:27 -06:00
|
|
|
static inline void thread__exited(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
thread->dead = true;
|
|
|
|
|
}
|
2010-07-30 18:28:42 -03:00
|
|
|
|
2019-05-27 15:11:49 +09:00
|
|
|
struct namespaces *thread__namespaces(struct thread *thread);
|
2017-03-08 02:11:43 +05:30
|
|
|
int thread__set_namespaces(struct thread *thread, u64 timestamp,
|
2019-08-26 19:02:31 -03:00
|
|
|
struct perf_record_namespaces *event);
|
2017-03-08 02:11:43 +05:30
|
|
|
|
2014-07-31 09:00:44 +03:00
|
|
|
int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp,
|
|
|
|
|
bool exec);
|
|
|
|
|
static inline int thread__set_comm(struct thread *thread, const char *comm,
|
|
|
|
|
u64 timestamp)
|
|
|
|
|
{
|
|
|
|
|
return __thread__set_comm(thread, comm, timestamp, false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 12:32:50 -03:00
|
|
|
int thread__set_comm_from_proc(struct thread *thread);
|
|
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
int thread__comm_len(struct thread *thread);
|
2013-09-13 16:28:57 +09:00
|
|
|
struct comm *thread__comm(const struct thread *thread);
|
2014-07-31 09:00:44 +03:00
|
|
|
struct comm *thread__exec_comm(const struct thread *thread);
|
2019-05-27 15:11:49 +09:00
|
|
|
const char *thread__comm_str(struct thread *thread);
|
2016-06-03 03:33:13 +00:00
|
|
|
int thread__insert_map(struct thread *thread, struct map *map);
|
2018-10-30 22:24:04 -07:00
|
|
|
int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone);
|
2012-12-07 17:39:39 -03:00
|
|
|
size_t thread__fprintf(struct thread *thread, FILE *fp);
|
2009-09-24 18:02:18 +02:00
|
|
|
|
2016-05-23 17:52:24 -07:00
|
|
|
struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
|
|
|
|
|
|
2018-04-26 09:34:37 -03:00
|
|
|
struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
|
|
|
|
|
struct addr_location *al);
|
2018-11-06 23:07:10 +02:00
|
|
|
struct map *thread__find_map_fb(struct thread *thread, u8 cpumode, u64 addr,
|
|
|
|
|
struct addr_location *al);
|
2010-01-14 23:45:29 -02:00
|
|
|
|
2018-04-25 18:16:53 -03:00
|
|
|
struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode,
|
|
|
|
|
u64 addr, struct addr_location *al);
|
2018-11-06 23:07:10 +02:00
|
|
|
struct symbol *thread__find_symbol_fb(struct thread *thread, u8 cpumode,
|
|
|
|
|
u64 addr, struct addr_location *al);
|
2013-06-07 16:22:12 -06:00
|
|
|
|
2018-04-25 17:58:03 -03:00
|
|
|
void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
|
2014-03-11 16:16:49 -03:00
|
|
|
struct addr_location *al);
|
|
|
|
|
|
2019-03-06 17:55:35 -03:00
|
|
|
int thread__memcpy(struct thread *thread, struct machine *machine,
|
|
|
|
|
void *buf, u64 ip, int len, bool *is64bit);
|
|
|
|
|
|
2013-06-07 16:22:12 -06:00
|
|
|
static inline void *thread__priv(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
return thread->priv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void thread__set_priv(struct thread *thread, void *p)
|
|
|
|
|
{
|
|
|
|
|
thread->priv = p;
|
|
|
|
|
}
|
2013-11-18 13:32:47 -07:00
|
|
|
|
|
|
|
|
static inline bool thread__is_filtered(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
if (symbol_conf.comm_list &&
|
|
|
|
|
!strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 09:52:41 -06:00
|
|
|
if (symbol_conf.pid_list &&
|
|
|
|
|
!intlist__has_entry(symbol_conf.pid_list, thread->pid_)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (symbol_conf.tid_list &&
|
|
|
|
|
!intlist__has_entry(symbol_conf.tid_list, thread->tid)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-18 13:32:47 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 13:25:12 -07:00
|
|
|
void thread__free_stitch_list(struct thread *thread);
|
2020-03-19 13:25:10 -07:00
|
|
|
|
2009-09-24 18:02:18 +02:00
|
|
|
#endif /* __PERF_THREAD_H */
|