1 #ifndef __PERF_MACHINE_H
2 #define __PERF_MACHINE_H
5 #include <linux/rbtree.h>
15 /* Native host kernel uses -1 as pid index in machine */
16 #define HOST_KERNEL_ID (-1)
17 #define DEFAULT_GUEST_KERNEL_ID (0)
20 struct rb_node rb_node;
24 struct rb_root threads;
25 struct list_head dead_threads;
26 struct thread *last_match;
27 struct list_head user_dsos;
28 struct list_head kernel_dsos;
29 struct map_groups kmaps;
30 struct map *vmlinux_maps[MAP__NR_TYPES];
34 struct map *machine__kernel_map(struct machine *machine, enum map_type type)
36 return machine->vmlinux_maps[type];
39 struct thread *machine__find_thread(struct machine *machine, pid_t pid);
41 int machine__process_comm_event(struct machine *machine, union perf_event *event);
42 int machine__process_exit_event(struct machine *machine, union perf_event *event);
43 int machine__process_fork_event(struct machine *machine, union perf_event *event);
44 int machine__process_lost_event(struct machine *machine, union perf_event *event);
45 int machine__process_mmap_event(struct machine *machine, union perf_event *event);
46 int machine__process_event(struct machine *machine, union perf_event *event);
48 typedef void (*machine__process_t)(struct machine *machine, void *data);
50 void machines__process(struct rb_root *machines,
51 machine__process_t process, void *data);
53 struct machine *machines__add(struct rb_root *machines, pid_t pid,
54 const char *root_dir);
55 struct machine *machines__find_host(struct rb_root *machines);
56 struct machine *machines__find(struct rb_root *machines, pid_t pid);
57 struct machine *machines__findnew(struct rb_root *machines, pid_t pid);
59 void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size);
60 char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
62 int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
63 void machine__exit(struct machine *machine);
64 void machine__delete(struct machine *machine);
67 struct branch_info *machine__resolve_bstack(struct machine *machine,
68 struct thread *thread,
69 struct branch_stack *bs);
70 int machine__resolve_callchain(struct machine *machine,
71 struct perf_evsel *evsel,
72 struct thread *thread,
73 struct perf_sample *sample,
74 struct symbol **parent);
77 * Default guest kernel is defined by parameter --guestkallsyms
80 static inline bool machine__is_default_guest(struct machine *machine)
82 return machine ? machine->pid == DEFAULT_GUEST_KERNEL_ID : false;
85 static inline bool machine__is_host(struct machine *machine)
87 return machine ? machine->pid == HOST_KERNEL_ID : false;
90 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
91 void machine__remove_thread(struct machine *machine, struct thread *th);
93 size_t machine__fprintf(struct machine *machine, FILE *fp);
96 struct symbol *machine__find_kernel_symbol(struct machine *machine,
97 enum map_type type, u64 addr,
99 symbol_filter_t filter)
101 return map_groups__find_symbol(&machine->kmaps, type, addr,
106 struct symbol *machine__find_kernel_function(struct machine *machine, u64 addr,
108 symbol_filter_t filter)
110 return machine__find_kernel_symbol(machine, MAP__FUNCTION, addr,
115 struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
118 symbol_filter_t filter)
120 return map_groups__find_function_by_name(&machine->kmaps, name, mapp,
124 struct map *machine__new_module(struct machine *machine, u64 start,
125 const char *filename);
127 int machine__load_kallsyms(struct machine *machine, const char *filename,
128 enum map_type type, symbol_filter_t filter);
129 int machine__load_vmlinux_path(struct machine *machine, enum map_type type,
130 symbol_filter_t filter);
132 size_t machine__fprintf_dsos_buildid(struct machine *machine, FILE *fp,
133 bool (skip)(struct dso *dso, int parm), int parm);
134 size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp);
135 size_t machines__fprintf_dsos_buildid(struct rb_root *machines, FILE *fp,
136 bool (skip)(struct dso *dso, int parm), int parm);
138 void machine__destroy_kernel_maps(struct machine *machine);
139 int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
140 int machine__create_kernel_maps(struct machine *machine);
142 int machines__create_kernel_maps(struct rb_root *machines, pid_t pid);
143 int machines__create_guest_kernel_maps(struct rb_root *machines);
144 void machines__destroy_guest_kernel_maps(struct rb_root *machines);
146 size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
148 #endif /* __PERF_MACHINE_H */