hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/tools/perf/util/dso.h
....@@ -2,17 +2,22 @@
22 #ifndef __PERF_DSO
33 #define __PERF_DSO
44
5
+#include <pthread.h>
56 #include <linux/refcount.h>
67 #include <linux/types.h>
78 #include <linux/rbtree.h>
89 #include <sys/types.h>
910 #include <stdbool.h>
10
-#include "rwsem.h"
11
-#include <linux/types.h>
11
+#include <stdio.h>
1212 #include <linux/bitops.h>
13
-#include "map.h"
14
-#include "namespaces.h"
1513 #include "build-id.h"
14
+
15
+struct machine;
16
+struct map;
17
+struct perf_env;
18
+
19
+#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
20
+#define DSO__NAME_KCORE "[kernel.kcore]"
1621
1722 enum dso_binary_type {
1823 DSO_BINARY_TYPE__KALLSYMS = 0,
....@@ -35,13 +40,16 @@
3540 DSO_BINARY_TYPE__KCORE,
3641 DSO_BINARY_TYPE__GUEST_KCORE,
3742 DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
43
+ DSO_BINARY_TYPE__BPF_PROG_INFO,
44
+ DSO_BINARY_TYPE__BPF_IMAGE,
45
+ DSO_BINARY_TYPE__OOL,
3846 DSO_BINARY_TYPE__NOT_FOUND,
3947 };
4048
41
-enum dso_kernel_type {
42
- DSO_TYPE_USER = 0,
43
- DSO_TYPE_KERNEL,
44
- DSO_TYPE_GUEST_KERNEL
49
+enum dso_space_type {
50
+ DSO_SPACE__USER = 0,
51
+ DSO_SPACE__KERNEL,
52
+ DSO_SPACE__KERNEL_GUEST
4553 };
4654
4755 enum dso_swap_type {
....@@ -117,21 +125,21 @@
117125 #define DSO__DATA_CACHE_SIZE 4096
118126 #define DSO__DATA_CACHE_MASK ~(DSO__DATA_CACHE_SIZE - 1)
119127
128
+/*
129
+ * Data about backing storage DSO, comes from PERF_RECORD_MMAP2 meta events
130
+ */
131
+struct dso_id {
132
+ u32 maj;
133
+ u32 min;
134
+ u64 ino;
135
+ u64 ino_generation;
136
+};
137
+
120138 struct dso_cache {
121139 struct rb_node rb_node;
122140 u64 offset;
123141 u64 size;
124
- char data[0];
125
-};
126
-
127
-/*
128
- * DSOs are put into both a list for fast iteration and rbtree for fast
129
- * long name lookup.
130
- */
131
-struct dsos {
132
- struct list_head head;
133
- struct rb_root root; /* rbtree root sorted by long name */
134
- struct rw_semaphore lock;
142
+ char data[];
135143 };
136144
137145 struct auxtrace_cache;
....@@ -141,10 +149,10 @@
141149 struct list_head node;
142150 struct rb_node rb_node; /* rbtree node sorted by long name */
143151 struct rb_root *root; /* root of rbtree that rb_node is in */
144
- struct rb_root symbols;
145
- struct rb_root symbol_names;
146
- struct rb_root inlined_nodes;
147
- struct rb_root srclines;
152
+ struct rb_root_cached symbols;
153
+ struct rb_root_cached symbol_names;
154
+ struct rb_root_cached inlined_nodes;
155
+ struct rb_root_cached srclines;
148156 struct {
149157 u64 addr;
150158 struct symbol *symbol;
....@@ -152,7 +160,7 @@
152160 void *a2l;
153161 char *symsrc_filename;
154162 unsigned int a2l_fails;
155
- enum dso_kernel_type kernel;
163
+ enum dso_space_type kernel;
156164 enum dso_swap_type needs_swap;
157165 enum dso_binary_type symtab_type;
158166 enum dso_binary_type binary_type;
....@@ -168,7 +176,7 @@
168176 bool sorted_by_name;
169177 bool loaded;
170178 u8 rel;
171
- u8 build_id[BUILD_ID_SIZE];
179
+ struct build_id bid;
172180 u64 text_offset;
173181 const char *short_name;
174182 const char *long_name;
....@@ -189,14 +197,21 @@
189197 u64 debug_frame_offset;
190198 u64 eh_frame_hdr_offset;
191199 } data;
200
+ /* bpf prog information */
201
+ struct {
202
+ u32 id;
203
+ u32 sub_id;
204
+ struct perf_env *env;
205
+ } bpf_prog;
192206
193207 union { /* Tool specific area */
194208 void *priv;
195209 u64 db_id;
196210 };
197211 struct nsinfo *nsinfo;
212
+ struct dso_id id;
198213 refcount_t refcnt;
199
- char name[0];
214
+ char name[];
200215 };
201216
202217 /* dso__for_each_symbol - iterate over the symbols of given type
....@@ -213,9 +228,11 @@
213228 dso->loaded = true;
214229 }
215230
231
+struct dso *dso__new_id(const char *name, struct dso_id *id);
216232 struct dso *dso__new(const char *name);
217233 void dso__delete(struct dso *dso);
218234
235
+int dso__cmp_id(struct dso *a, struct dso *b);
219236 void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
220237 void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated);
221238
....@@ -236,15 +253,15 @@
236253
237254 static inline bool dso__has_symbols(const struct dso *dso)
238255 {
239
- return !RB_EMPTY_ROOT(&dso->symbols);
256
+ return !RB_EMPTY_ROOT(&dso->symbols.rb_root);
240257 }
241258
242259 bool dso__sorted_by_name(const struct dso *dso);
243260 void dso__set_sorted_by_name(struct dso *dso);
244261 void dso__sort_by_name(struct dso *dso);
245262
246
-void dso__set_build_id(struct dso *dso, void *build_id);
247
-bool dso__build_id_equal(const struct dso *dso, u8 *build_id);
263
+void dso__set_build_id(struct dso *dso, struct build_id *bid);
264
+bool dso__build_id_equal(const struct dso *dso, struct build_id *bid);
248265 void dso__read_running_kernel_build_id(struct dso *dso,
249266 struct machine *machine);
250267 int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
....@@ -284,6 +301,8 @@
284301 * dso__data_size
285302 * dso__data_read_offset
286303 * dso__data_read_addr
304
+ * dso__data_write_cache_offs
305
+ * dso__data_write_cache_addr
287306 *
288307 * Please refer to the dso.c object code for each function and
289308 * arguments documentation. Following text tries to explain the
....@@ -323,6 +342,7 @@
323342 void dso__data_put_fd(struct dso *dso);
324343 void dso__data_close(struct dso *dso);
325344
345
+int dso__data_file_size(struct dso *dso, struct machine *machine);
326346 off_t dso__data_size(struct dso *dso, struct machine *machine);
327347 ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
328348 u64 offset, u8 *data, ssize_t size);
....@@ -330,27 +350,18 @@
330350 struct machine *machine, u64 addr,
331351 u8 *data, ssize_t size);
332352 bool dso__data_status_seen(struct dso *dso, enum dso_data_status_seen by);
353
+ssize_t dso__data_write_cache_offs(struct dso *dso, struct machine *machine,
354
+ u64 offset, const u8 *data, ssize_t size);
355
+ssize_t dso__data_write_cache_addr(struct dso *dso, struct map *map,
356
+ struct machine *machine, u64 addr,
357
+ const u8 *data, ssize_t size);
333358
334359 struct map *dso__new_map(const char *name);
335360 struct dso *machine__findnew_kernel(struct machine *machine, const char *name,
336361 const char *short_name, int dso_type);
337362
338
-void __dsos__add(struct dsos *dsos, struct dso *dso);
339
-void dsos__add(struct dsos *dsos, struct dso *dso);
340
-struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
341
-struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
342
-struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
343
-struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
344
-struct dso *dsos__findnew(struct dsos *dsos, const char *name);
345
-bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
346
-
347363 void dso__reset_find_symbol_cache(struct dso *dso);
348364
349
-size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
350
- bool (skip)(struct dso *dso, int parm), int parm);
351
-size_t __dsos__fprintf(struct list_head *head, FILE *fp);
352
-
353
-size_t dso__fprintf_buildid(struct dso *dso, FILE *fp);
354365 size_t dso__fprintf_symbols_by_name(struct dso *dso, FILE *fp);
355366 size_t dso__fprintf(struct dso *dso, FILE *fp);
356367