Skip to contentSkip to conversation

perf dsos: Move the dsos struct and its methods to separate source files

tip: perf/core tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Sep 2, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     4a3cec84949d14dc3ef7fb8a51b8949af93cac13
Gitweb:        https://git.kernel.org/tip/4a3cec84949d14dc3ef7fb8a51b8949af93cac13
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Fri, 30 Aug 2019 11:11:01 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:24:10 -03:00

perf dsos: Move the dsos struct and its methods to separate source files

So that we can reduce the header dependency tree further, in the process noticed that lots of places were getting even things like build-id routines and 'struct perf_tool' definition indirectly, so fix all those too.

---
 tools/perf/builtin-annotate.c                          |   1 +-
 tools/perf/builtin-buildid-cache.c                     |   1 +-
 tools/perf/builtin-buildid-list.c                      |   1 +-
 tools/perf/builtin-inject.c                            |   1 +-
 tools/perf/builtin-kallsyms.c                          |   1 +-
 tools/perf/builtin-kmem.c                              |   1 +-
 tools/perf/builtin-kvm.c                               |   1 +-
 tools/perf/builtin-mem.c                               |   1 +-
 tools/perf/builtin-report.c                            |   1 +-
 tools/perf/builtin-script.c                            |   1 +-
 tools/perf/builtin-top.c                               |   1 +-
 tools/perf/builtin-trace.c                             |   2 +-
 tools/perf/tests/code-reading.c                        |   1 +-
 tools/perf/tests/dso-data.c                            |   1 +-
 tools/perf/tests/dwarf-unwind.c                        |   1 +-
 tools/perf/tests/event_update.c                        |   1 +-
 tools/perf/tests/hists_common.c                        |   1 +-
 tools/perf/tests/hists_cumulate.c                      |   1 +-
 tools/perf/tests/hists_output.c                        |   1 +-
 tools/perf/tests/vmlinux-kallsyms.c                    |   1 +-
 tools/perf/ui/browsers/annotate.c                      |   1 +-
 tools/perf/ui/browsers/hists.c                         |   1 +-
 tools/perf/util/Build                                  |   1 +-
 tools/perf/util/bpf-event.c                            |   1 +-
 tools/perf/util/callchain.c                            |   1 +-
 tools/perf/util/cs-etm.c                               |   2 +-
 tools/perf/util/db-export.c                            |   1 +-
 tools/perf/util/dso.c                                  | 235 +--------
 tools/perf/util/dso.h                                  |  25 +-
 tools/perf/util/dsos.c                                 | 232 ++++++++-
 tools/perf/util/dsos.h                                 |  44 +-
 tools/perf/util/event.c                                |   2 +-
 tools/perf/util/header.c                               |   1 +-
 tools/perf/util/hist.c                                 |   1 +-
 tools/perf/util/intel-bts.c                            |   1 +-
 tools/perf/util/jitdump.c                              |   1 +-
 tools/perf/util/machine.c                              |   1 +-
 tools/perf/util/machine.h                              |   3 +-
 tools/perf/util/map.c                                  |   1 +-
 tools/perf/util/parse-events.c                         |   1 +-
 tools/perf/util/probe-event.c                          |   2 +-
 tools/perf/util/s390-cpumsf.c                          |   1 +-
 tools/perf/util/scripting-engines/trace-event-perl.c   |   1 +-
 tools/perf/util/scripting-engines/trace-event-python.c |   2 +-
 tools/perf/util/sort.c                                 |   1 +-
 tools/perf/util/thread.c                               |   1 +-
 tools/perf/util/unwind-libdw.c                         |   1 +-
 tools/perf/util/unwind-libunwind.c                     |   1 +-
 tools/perf/util/vdso.c                                 |   1 +-
 49 files changed, 331 insertions(+), 257 deletions(-)
 create mode 100644 tools/perf/util/dsos.c
 create mode 100644 tools/perf/util/dsos.h
tools/perf/builtin-annotate.c +1 -0
index 9bb6371..738471a 100644
@@ -27,6 +27,7 @@
 #include "util/thread.h"
 #include "util/sort.h"
 #include "util/hist.h"
+#include "util/dso.h"
 #include "util/map.h"
 #include "util/session.h"
 #include "util/tool.h"
tools/perf/builtin-buildid-cache.c +1 -0
index 9e75600..b035911 100644
@@ -22,6 +22,7 @@
 #include "util/strlist.h"
 #include "util/build-id.h"
 #include "util/session.h"
+#include "util/dso.h"
 #include "util/symbol.h"
 #include "util/time-utils.h"
 #include "util/util.h"
tools/perf/builtin-buildid-list.c +1 -0
index 72bdc0e..38b2ec6 100644
@@ -12,6 +12,7 @@
 #include "util/build-id.h"
 #include "util/cache.h"
 #include "util/debug.h"
+#include "util/dso.h"
 #include <subcmd/parse-options.h>
 #include "util/session.h"
 #include "util/symbol.h"
tools/perf/builtin-inject.c +1 -0
index ae46de4..c14f40b 100644
@@ -9,6 +9,7 @@
 #include "builtin.h"
 
 #include "util/color.h"
+#include "util/dso.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/map.h"
tools/perf/builtin-kallsyms.c +1 -0
index c1a4467..c08ee81 100644
@@ -11,6 +11,7 @@
 #include <linux/compiler.h>
 #include <subcmd/parse-options.h>
 #include "debug.h"
+#include "dso.h"
 #include "machine.h"
 #include "map.h"
 #include "symbol.h"
tools/perf/builtin-kmem.c +1 -0
index 378b09c..b5682be 100644
@@ -2,6 +2,7 @@
 #include "builtin.h"
 #include "perf.h"
 
+#include "util/dso.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/config.h"
tools/perf/builtin-kvm.c +1 -0
index 69d16ac..474c479 100644
@@ -2,6 +2,7 @@
 #include "builtin.h"
 #include "perf.h"
 
+#include "util/build-id.h"
 #include "util/evsel.h"
 #include "util/evlist.h"
 #include "util/term.h"
tools/perf/builtin-mem.c +1 -0
index 9e60eda..c5f3b9e 100644
@@ -13,6 +13,7 @@
 #include "util/data.h"
 #include "util/mem-events.h"
 #include "util/debug.h"
+#include "util/dso.h"
 #include "util/map.h"
 #include "util/symbol.h"
 
tools/perf/builtin-report.c +1 -0
index 94e7e35..ba419ee 100644
@@ -12,6 +12,7 @@
 
 #include "util/annotate.h"
 #include "util/color.h"
+#include "util/dso.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <linux/err.h>
tools/perf/builtin-script.c +1 -0
index f3b31c6..1ff04b0 100644
@@ -4,6 +4,7 @@
 #include "util/cache.h"
 #include "util/counts.h"
 #include "util/debug.h"
+#include "util/dso.h"
 #include <subcmd/exec-cmd.h>
 #include "util/header.h"
 #include <subcmd/parse-options.h>
tools/perf/builtin-top.c +1 -0
index 5538b58..0b7b12c 100644
@@ -24,6 +24,7 @@
 #include "util/bpf-event.h"
 #include "util/config.h"
 #include "util/color.h"
+#include "util/dso.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/event.h"
tools/perf/builtin-trace.c +2 -0
index b1ec8ff..0f633f0 100644
@@ -25,6 +25,7 @@
 #include "util/color.h"
 #include "util/config.h"
 #include "util/debug.h"
+#include "util/dso.h"
 #include "util/env.h"
 #include "util/event.h"
 #include "util/evlist.h"
@@ -42,6 +43,7 @@
 #include "util/intlist.h"
 #include "util/thread_map.h"
 #include "util/stat.h"
+#include "util/tool.h"
 #include "util/util.h"
 #include "trace/beauty/beauty.h"
 #include "trace-event.h"
tools/perf/tests/code-reading.c +1 -0
index c4b73bb..7b2b89f 100644
@@ -12,6 +12,7 @@
 #include <perf/evlist.h>
 
 #include "debug.h"
+#include "dso.h"
 #include "parse-events.h"
 #include "evlist.h"
 #include "evsel.h"
tools/perf/tests/dso-data.c +1 -0
index 946ab4b..a4874d4 100644
@@ -9,6 +9,7 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <api/fs/fs.h>
+#include "dso.h"
 #include "util.h"
 #include "machine.h"
 #include "symbol.h"
tools/perf/tests/dwarf-unwind.c +1 -0
index f33709a..4125255 100644
@@ -3,6 +3,7 @@
 #include <linux/types.h>
 #include <linux/zalloc.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <unistd.h>
 #include "tests.h"
 #include "debug.h"
tools/perf/tests/event_update.c +1 -0
index 1411155..4b68ec3 100644
@@ -4,6 +4,7 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "machine.h"
+#include "tool.h"
 #include "tests.h"
 #include "debug.h"
 
tools/perf/tests/hists_common.c +1 -0
index 96ad95d..cdde41c 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <inttypes.h>
 #include "util/debug.h"
+#include "util/dso.h"
 #include "util/map.h"
 #include "util/symbol.h"
 #include "util/sort.h"
tools/perf/tests/hists_cumulate.c +1 -0
index 93af420..fa55b7b 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "util/debug.h"
+#include "util/dso.h"
 #include "util/event.h"
 #include "util/map.h"
 #include "util/symbol.h"
tools/perf/tests/hists_output.c +1 -0
index 07f4ca0..3f6dfa2 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "util/debug.h"
+#include "util/dso.h"
 #include "util/event.h"
 #include "util/map.h"
 #include "util/symbol.h"
tools/perf/tests/vmlinux-kallsyms.c +1 -0
index 5e8834f..01f434c 100644
@@ -4,6 +4,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <stdlib.h>
+#include "dso.h"
 #include "map.h"
 #include "symbol.h"
 #include "util.h"
tools/perf/ui/browsers/annotate.c +1 -0
index 715601f..ac74ed2 100644
@@ -5,6 +5,7 @@
 #include "../util.h"
 #include "../../util/annotate.h"
 #include "../../util/debug.h"
+#include "../../util/dso.h"
 #include "../../util/hist.h"
 #include "../../util/sort.h"
 #include "../../util/map.h"
tools/perf/ui/browsers/hists.c +1 -0
index a14dda7..cf88574 100644
@@ -12,6 +12,7 @@
 #include <linux/zalloc.h>
 
 #include "../../util/debug.h"
+#include "../../util/dso.h"
 #include "../../util/callchain.h"
 #include "../../util/evsel.h"
 #include "../../util/evlist.h"
tools/perf/util/Build +1 -0
index 2e38564..0b4d8e0 100644
@@ -36,6 +36,7 @@ perf-y += strfilter.o
 perf-y += top.o
 perf-y += usage.o
 perf-y += dso.o
+perf-y += dsos.o
 perf-y += symbol.o
 perf-y += symbol_fprintf.o
 perf-y += color.o
tools/perf/util/bpf-event.c +1 -0
index 2d6d500..7a3d4b1 100644
@@ -8,6 +8,7 @@
 #include <linux/err.h>
 #include "bpf-event.h"
 #include "debug.h"
+#include "dso.h"
 #include "symbol.h"
 #include "machine.h"
 #include "env.h"
tools/perf/util/callchain.c +1 -0
index 76bf05b..c14646c 100644
@@ -22,6 +22,7 @@
 #include "asm/bug.h"
 
 #include "debug.h"
+#include "dso.h"
 #include "hist.h"
 #include "sort.h"
 #include "machine.h"
tools/perf/util/cs-etm.c +2 -0
index d6de383..3ed1d3b 100644
@@ -21,12 +21,14 @@
 #include "cs-etm.h"
 #include "cs-etm-decoder/cs-etm-decoder.h"
 #include "debug.h"
+#include "dso.h"
 #include "evlist.h"
 #include "intlist.h"
 #include "machine.h"
 #include "map.h"
 #include "perf.h"
 #include "symbol.h"
+#include "tool.h"
 #include "thread.h"
 #include "thread_map.h"
 #include "thread-stack.h"
tools/perf/util/db-export.c +1 -0
index 701e9f8..752227b 100644
@@ -7,6 +7,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
+#include "dso.h"
 #include "evsel.h"
 #include "machine.h"
 #include "thread.h"
tools/perf/util/dso.c +3 -232

277 lines not on this page · raw message

tools/perf/util/dso.h +1 -24
index ff0b818..e4dddb7 100644
@@ -2,13 +2,13 @@
 #ifndef __PERF_DSO
 #define __PERF_DSO
 
+#include <pthread.h>
 #include <linux/refcount.h>
 #include <linux/types.h>
 #include <linux/rbtree.h>
 #include <sys/types.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include "rwsem.h"
 #include <linux/bitops.h>
 #include "build-id.h"
 
@@ -129,16 +129,6 @@ struct dso_cache {
 	char data[0];
 };
 
-/*
- * DSOs are put into both a list for fast iteration and rbtree for fast
- * long name lookup.
- */
-struct dsos {
-	struct list_head head;
-	struct rb_root	 root;	/* rbtree root sorted by long name */
-	struct rw_semaphore lock;
-};
-
 struct auxtrace_cache;
 
 struct dso {
@@ -347,21 +337,8 @@ struct map *dso__new_map(const char *name);
 struct dso *machine__findnew_kernel(struct machine *machine, const char *name,
 				    const char *short_name, int dso_type);
 
-void __dsos__add(struct dsos *dsos, struct dso *dso);
-void dsos__add(struct dsos *dsos, struct dso *dso);
-struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
-struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
-struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
-struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
-struct dso *dsos__findnew(struct dsos *dsos, const char *name);
-bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
-
 void dso__reset_find_symbol_cache(struct dso *dso);
 
-size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
-			       bool (skip)(struct dso *dso, int parm), int parm);
-size_t __dsos__fprintf(struct list_head *head, FILE *fp);
-
 size_t dso__fprintf_buildid(struct dso *dso, FILE *fp);
 size_t dso__fprintf_symbols_by_name(struct dso *dso, FILE *fp);
 size_t dso__fprintf(struct dso *dso, FILE *fp);
tools/perf/util/dsos.c new file +232 -0

232 lines not on this page · raw message

tools/perf/util/dsos.h new file +44 -0

44 lines not on this page · raw message

tools/perf/util/event.c +2 -0
index 54169ad..f4afbb8 100644
@@ -11,6 +11,7 @@
 #include <api/fs/fs.h>
 #include <linux/perf_event.h>
 #include <linux/zalloc.h>
+#include "dso.h"
 #include "event.h"
 #include "debug.h"
 #include "hist.h"
@@ -29,6 +30,7 @@
 #include "stat.h"
 #include "session.h"
 #include "bpf-event.h"
+#include "tool.h"
 #include "../perf.h"
 
 #define DEFAULT_PROC_MAP_PARSE_TIMEOUT 500
tools/perf/util/header.c +1 -0
index 20fb061..b0c34dd 100644
@@ -22,6 +22,7 @@
 #include <bpf/libbpf.h>
 #include <perf/cpumap.h>
 
+#include "dso.h"
 #include "evlist.h"
 #include "evsel.h"
 #include "header.h"
tools/perf/util/hist.c +1 -0
index 02ea2ee..b526ef3 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "callchain.h"
 #include "debug.h"
+#include "dso.h"
 #include "build-id.h"
 #include "hist.h"
 #include "map.h"
tools/perf/util/intel-bts.c +1 -0
index 99dddb6..a30427a 100644
@@ -22,6 +22,7 @@
 #include "map.h"
 #include "symbol.h"
 #include "session.h"
+#include "tool.h"
 #include "thread.h"
 #include "thread-stack.h"
 #include "debug.h"
tools/perf/util/jitdump.c +1 -0
index bbeac4f..b80f29b 100644
@@ -14,6 +14,7 @@
 #include <sys/mman.h>
 #include <linux/stringify.h>
 
+#include "build-id.h"
 #include "util.h"
 #include "event.h"
 #include "debug.h"
tools/perf/util/machine.c +1 -0
index 6e9afe4..0030254 100644
@@ -5,6 +5,7 @@
 #include <regex.h>
 #include "callchain.h"
 #include "debug.h"
+#include "dso.h"
 #include "event.h"
 #include "evsel.h"
 #include "hist.h"
tools/perf/util/machine.h +2 -1
index 7d69119..ffd391a 100644
@@ -5,12 +5,13 @@
 #include <sys/types.h>
 #include <linux/rbtree.h>
 #include "map_groups.h"
-#include "dso.h"
+#include "dsos.h"
 #include "event.h"
 #include "rwsem.h"
 
 struct addr_location;
 struct branch_stack;
+struct dso;
 struct evsel;
 struct perf_sample;
 struct symbol;
tools/perf/util/map.c +1 -0
index c75b20b..623a63c 100644
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
+#include "dso.h"
 #include "map.h"
 #include "thread.h"
 #include "vdso.h"
tools/perf/util/parse-events.c +1 -0
index 5f1ba68..523af1b 100644
@@ -10,6 +10,7 @@
 #include <fcntl.h>
 #include <sys/param.h>
 #include "term.h"
+#include "build-id.h"
 #include "evlist.h"
 #include "evsel.h"
 #include <subcmd/parse-options.h>
tools/perf/util/probe-event.c +2 -0
index 8394d48..5d12a78 100644
@@ -19,11 +19,13 @@
 #include <limits.h>
 #include <elf.h>
 
+#include "build-id.h"
 #include "event.h"
 #include "namespaces.h"
 #include "strlist.h"
 #include "strfilter.h"
 #include "debug.h"
+#include "dso.h"
 #include "cache.h"
 #include "color.h"
 #include "map.h"
tools/perf/util/s390-cpumsf.c +1 -0
index 4f6c146..2ba4baa 100644
@@ -157,6 +157,7 @@
 #include "evlist.h"
 #include "machine.h"
 #include "session.h"
+#include "tool.h"
 #include "thread.h"
 #include "debug.h"
 #include "auxtrace.h"
tools/perf/util/scripting-engines/trace-event-perl.c +1 -0
index 800e82d..1596185 100644
@@ -35,6 +35,7 @@
 #include <perl.h>
 
 #include "../callchain.h"
+#include "../dso.h"
 #include "../machine.h"
 #include "../map.h"
 #include "../symbol.h"
tools/perf/util/scripting-engines/trace-event-python.c +2 -0
index abfde35..666a56e 100644
@@ -31,8 +31,10 @@
 #include <linux/compiler.h>
 #include <linux/time64.h>
 
+#include "../build-id.h"
 #include "../counts.h"
 #include "../debug.h"
+#include "../dso.h"
 #include "../callchain.h"
 #include "../evsel.h"
 #include "../util.h"
tools/perf/util/sort.c +1 -0
index 4650704..32ade5a 100644
@@ -5,6 +5,7 @@
 #include <linux/mman.h>
 #include <linux/time64.h>
 #include "debug.h"
+#include "dso.h"
 #include "sort.h"
 #include "hist.h"
 #include "cacheline.h"
tools/perf/util/thread.c +1 -0
index 5ba1601..b64e9e0 100644
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
+#include "dso.h"
 #include "session.h"
 #include "thread.h"
 #include "thread-stack.h"
tools/perf/util/unwind-libdw.c +1 -0
index 28f71ca..9ece188 100644
@@ -5,6 +5,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include "debug.h"
+#include "dso.h"
 #include "unwind.h"
 #include "unwind-libdw.h"
 #include "machine.h"
tools/perf/util/unwind-libunwind.c +1 -0
index 6499b22..a24fb57 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "unwind.h"
+#include "dso.h"
 #include "map.h"
 #include "thread.h"
 #include "session.h"
tools/perf/util/vdso.c +1 -0
index 7f427ba..e5e6599 100644
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 
 #include "vdso.h"
+#include "dso.h"
 #include "util.h"
 #include "map.h"
 #include "symbol.h"