Skip to contentSkip to conversation

perf tools: Move event synthesizing routines to separate header

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

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/urgent branch of tip:

Commit-ID:     ea49e01cfabd73c94a61649cd04fa524a2beff3c
Gitweb:        https://git.kernel.org/tip/ea49e01cfabd73c94a61649cd04fa524a2beff3c
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Wed, 18 Sep 2019 11:36:13 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Fri, 20 Sep 2019 09:19:22 -03:00

perf tools: Move event synthesizing routines to separate header

Those are the only routines using the perf_event__handler_t typedef and are all related, so move to a separate header to reduce the header dependency tree, lots of places were getting event.h and even stdio.h, limits.h indirectly, so fix those as well.

---
 tools/perf/arch/x86/util/archinsn.c   |   1 +-
 tools/perf/arch/x86/util/event.c      |   2 +-
 tools/perf/arch/x86/util/machine.c    |   1 +-
 tools/perf/arch/x86/util/tsc.c        |   2 +-
 tools/perf/builtin-inject.c           |   1 +-
 tools/perf/builtin-kvm.c              |   1 +-
 tools/perf/builtin-record.c           |   1 +-
 tools/perf/builtin-stat.c             |   1 +-
 tools/perf/builtin-top.c              |   1 +-
 tools/perf/builtin-trace.c            |   1 +-
 tools/perf/tests/code-reading.c       |   1 +-
 tools/perf/tests/cpumap.c             |   1 +-
 tools/perf/tests/dwarf-unwind.c       |   1 +-
 tools/perf/tests/event_update.c       |   1 +-
 tools/perf/tests/hists_common.c       |   2 +-
 tools/perf/tests/mmap-thread-lookup.c |   2 +-
 tools/perf/tests/sample-parsing.c     |   1 +-
 tools/perf/tests/stat.c               |   1 +-
 tools/perf/tests/thread-map.c         |   1 +-
 tools/perf/ui/stdio/hist.c            |   1 +-
 tools/perf/util/auxtrace.c            |   1 +-
 tools/perf/util/auxtrace.h            |  17 +----
 tools/perf/util/bpf-event.c           |   1 +-
 tools/perf/util/bpf-event.h           |  15 +---
 tools/perf/util/callchain.c           |   1 +-
 tools/perf/util/event.c               |   1 +-
 tools/perf/util/event.h               | 118 +-------------------------
 tools/perf/util/evsel.c               |   1 +-
 tools/perf/util/header.c              |   1 +-
 tools/perf/util/intel-bts.c           |   1 +-
 tools/perf/util/intel-pt.c            |   1 +-
 tools/perf/util/machine.c             |  10 ++-
 tools/perf/util/machine.h             |  15 +---
 tools/perf/util/session.c             |   1 +-
 tools/perf/util/session.h             |   5 +-
 tools/perf/util/stat.c                |   1 +-
 tools/perf/util/synthetic-events.h    | 103 ++++++++++++++++++++++-
 tools/perf/util/tsc.h                 |  14 +---
 38 files changed, 154 insertions(+), 177 deletions(-)
 create mode 100644 tools/perf/util/synthetic-events.h
tools/perf/arch/x86/util/archinsn.c +1 -0
index 9876c7a..3e67915 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "../../../../arch/x86/include/asm/insn.h"
 #include "archinsn.h"
+#include "event.h"
 #include "machine.h"
 #include "thread.h"
 #include "symbol.h"
tools/perf/arch/x86/util/event.c +2 -0
index a3a0b68..d357c62 100644
@@ -3,6 +3,8 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
+#include "../../util/event.h"
+#include "../../util/synthetic-events.h"
 #include "../../util/machine.h"
 #include "../../util/tool.h"
 #include "../../util/map.h"
tools/perf/arch/x86/util/machine.c +1 -0
index 4241804..f0c2898 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
 #include <linux/string.h>
+#include <limits.h>
 #include <stdlib.h>
 
 #include "../../util/util.h" // page_size
tools/perf/arch/x86/util/tsc.c +2 -0
index c5197a1..2f55afb 100644
@@ -8,6 +8,8 @@
 #include <linux/types.h>
 #include <asm/barrier.h>
 #include "../../../util/debug.h"
+#include "../../../util/event.h"
+#include "../../../util/synthetic-events.h"
 #include "../../../util/tsc.h"
 
 int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
tools/perf/builtin-inject.c +1 -0
index c14f40b..23a76cf 100644
@@ -21,6 +21,7 @@
 #include "util/auxtrace.h"
 #include "util/jit.h"
 #include "util/symbol.h"
+#include "util/synthetic-events.h"
 #include "util/thread.h"
 
 #include <subcmd/parse-options.h>
tools/perf/builtin-kvm.c +1 -0
index 0a4fcbe..ac6d6e0 100644
@@ -17,6 +17,7 @@
 #include "util/debug.h"
 #include "util/tool.h"
 #include "util/stat.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
 #include "util/data.h"
 #include "util/ordered-events.h"
tools/perf/builtin-record.c +1 -0
index 1447004..907d4d4 100644
@@ -38,6 +38,7 @@
 #include "util/trigger.h"
 #include "util/perf-hooks.h"
 #include "util/cpu-set-sched.h"
+#include "util/synthetic-events.h"
 #include "util/time-utils.h"
 #include "util/units.h"
 #include "util/bpf-event.h"
tools/perf/builtin-stat.c +1 -0
index b55e806..eece3d1 100644
@@ -61,6 +61,7 @@
 #include "util/tool.h"
 #include "util/string2.h"
 #include "util/metricgroup.h"
+#include "util/synthetic-events.h"
 #include "util/target.h"
 #include "util/time-utils.h"
 #include "util/top.h"
tools/perf/builtin-top.c +1 -0
index 726e3f2..b052470 100644
@@ -32,6 +32,7 @@
 #include "util/map.h"
 #include "util/session.h"
 #include "util/symbol.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
 #include "util/util.h"
 #include <linux/rbtree.h>
tools/perf/builtin-trace.c +1 -0
index 0f633f0..f0f7350 100644
@@ -28,6 +28,7 @@
 #include "util/dso.h"
 #include "util/env.h"
 #include "util/event.h"
+#include "util/synthetic-events.h"
 #include "util/evlist.h"
 #include "util/evswitch.h"
 #include <subcmd/pager.h>
tools/perf/tests/code-reading.c +1 -0
index 8d9020c..fd02c1f 100644
@@ -24,6 +24,7 @@
 #include "symbol.h"
 #include "event.h"
 #include "record.h"
+#include "util/synthetic-events.h"
 #include "thread.h"
 
 #include "tests.h"
tools/perf/tests/cpumap.c +1 -0
index 39493de..8a0d236 100644
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include "cpumap.h"
 #include "event.h"
+#include "util/synthetic-events.h"
 #include <string.h>
 #include <linux/bitops.h>
 #include <perf/cpumap.h>
tools/perf/tests/dwarf-unwind.c +1 -0
index 4125255..4f4ecbc 100644
@@ -15,6 +15,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include "callchain.h"
+#include "util/synthetic-events.h"
 
 #if defined (__x86_64__) || defined (__i386__) || defined (__powerpc__)
 #include "arch-tests.h"
tools/perf/tests/event_update.c +1 -0
index 317eb8c..4bb772e 100644
@@ -7,6 +7,7 @@
 #include "evsel.h"
 #include "header.h"
 #include "machine.h"
+#include "util/synthetic-events.h"
 #include "tool.h"
 #include "tests.h"
 #include "debug.h"
tools/perf/tests/hists_common.c +2 -0
index de110d8..6f34d08 100644
@@ -2,6 +2,7 @@
 #include <inttypes.h>
 #include "util/debug.h"
 #include "util/dso.h"
+#include "util/event.h" // struct perf_sample
 #include "util/map.h"
 #include "util/symbol.h"
 #include "util/sort.h"
@@ -10,6 +11,7 @@
 #include "util/thread.h"
 #include "tests/hists_common.h"
 #include <linux/kernel.h>
+#include <linux/perf_event.h>
 
 static struct {
 	u32 pid;
tools/perf/tests/mmap-thread-lookup.c +2 -0
index f72889c..33b496d 100644
@@ -8,11 +8,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "debug.h"
+#include "event.h"
 #include "tests.h"
 #include "machine.h"
 #include "thread_map.h"
 #include "map.h"
 #include "symbol.h"
+#include "util/synthetic-events.h"
 #include "thread.h"
 #include "util.h" // page_size
 
tools/perf/tests/sample-parsing.c +1 -0
index e3b965e..3a02426 100644
@@ -12,6 +12,7 @@
 #include "event.h"
 #include "evsel.h"
 #include "debug.h"
+#include "util/synthetic-events.h"
 
 #include "tests.h"
 
tools/perf/tests/stat.c +1 -0
index cc10b41..c191150 100644
@@ -5,6 +5,7 @@
 #include "stat.h"
 #include "counts.h"
 #include "debug.h"
+#include "util/synthetic-events.h"
 
 static bool has_term(struct perf_record_stat_config *config,
 		     u64 tag, u64 val)
tools/perf/tests/thread-map.c +1 -0
index 39168c5..28f51c4 100644
@@ -8,6 +8,7 @@
 #include "thread_map.h"
 #include "debug.h"
 #include "event.h"
+#include "util/synthetic-events.h"
 #include <linux/zalloc.h>
 #include <perf/event.h>
 
tools/perf/ui/stdio/hist.c +1 -0
index 832ca6c..5365606 100644
@@ -5,6 +5,7 @@
 
 #include "../../util/callchain.h"
 #include "../../util/debug.h"
+#include "../../util/event.h"
 #include "../../util/hist.h"
 #include "../../util/map.h"
 #include "../../util/map_groups.h"
tools/perf/util/auxtrace.c +1 -0
index 1c0ff5a..0e8c89c 100644
@@ -32,6 +32,7 @@
 #include "pmu.h"
 #include "evsel.h"
 #include "symbol.h"
+#include "util/synthetic-events.h"
 #include "thread_map.h"
 #include "asm/bug.h"
 #include "auxtrace.h"
tools/perf/util/auxtrace.h +2 -15
index 1ed902a..b110aec 100644
@@ -11,14 +11,13 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdio.h> // FILE
 #include <linux/list.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <asm/bitsperlong.h>
 #include <asm/barrier.h>
 
-#include "event.h"
-
 union perf_event;
 struct perf_session;
 struct evlist;
@@ -27,6 +26,7 @@ struct perf_mmap;
 struct perf_sample;
 struct option;
 struct record_opts;
+struct perf_record_auxtrace_error;
 struct perf_record_auxtrace_info;
 struct events_stats;
 
@@ -525,10 +525,6 @@ void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int
 			  int code, int cpu, pid_t pid, pid_t tid, u64 ip,
 			  const char *msg, u64 timestamp);
 
-int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
-					 struct perf_tool *tool,
-					 struct perf_session *session,
-					 perf_event__handler_t process);
 int perf_event__process_auxtrace_info(struct perf_session *session,
 				      union perf_event *event);
 s64 perf_event__process_auxtrace(struct perf_session *session,
@@ -605,15 +601,6 @@ void auxtrace_record__free(struct auxtrace_record *itr __maybe_unused)
 {
 }
 
-static inline int
-perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
-				     struct perf_tool *tool __maybe_unused,
-				     struct perf_session *session __maybe_unused,
-				     perf_event__handler_t process __maybe_unused)
-{
-	return -EINVAL;
-}
-
 static inline
 int auxtrace_record__options(struct auxtrace_record *itr __maybe_unused,
 			     struct evlist *evlist __maybe_unused,
tools/perf/util/bpf-event.c +1 -0
index 7a3d4b1..f7ed5d1 100644
@@ -16,6 +16,7 @@
 #include "map.h"
 #include "evlist.h"
 #include "record.h"
+#include "util/synthetic-events.h"
 
 #define ptr_to_u64(ptr)    ((__u64)(unsigned long)(ptr))
 
tools/perf/util/bpf-event.h +1 -14
index a01c2fd..81fdc88 100644
@@ -6,9 +6,9 @@
 #include <linux/rbtree.h>
 #include <pthread.h>
 #include <api/fd/array.h>
-#include "event.h"
 #include <stdio.h>
 
+struct bpf_prog_info;
 struct machine;
 union perf_event;
 struct perf_env;
@@ -33,11 +33,6 @@ struct btf_node {
 #ifdef HAVE_LIBBPF_SUPPORT
 int machine__process_bpf(struct machine *machine, union perf_event *event,
 			 struct perf_sample *sample);
-
-int perf_event__synthesize_bpf_events(struct perf_session *session,
-				      perf_event__handler_t process,
-				      struct machine *machine,
-				      struct record_opts *opts);
 int bpf_event__add_sb_event(struct evlist **evlist,
 				 struct perf_env *env);
 void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
@@ -51,14 +46,6 @@ static inline int machine__process_bpf(struct machine *machine __maybe_unused,
 	return 0;
 }
 
-static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
-						    perf_event__handler_t process __maybe_unused,
-						    struct machine *machine __maybe_unused,
-						    struct record_opts *opts __maybe_unused)
-{
-	return 0;
-}
-
 static inline int bpf_event__add_sb_event(struct evlist **evlist __maybe_unused,
 					  struct perf_env *env __maybe_unused)
 {
tools/perf/util/callchain.c +1 -0
index c14646c..9a9b56e 100644
@@ -23,6 +23,7 @@
 
 #include "debug.h"
 #include "dso.h"
+#include "event.h"
 #include "hist.h"
 #include "sort.h"
 #include "machine.h"
tools/perf/util/event.c +1 -0
index d65ae7c..043a08f 100644
@@ -32,6 +32,7 @@
 #include "stat.h"
 #include "session.h"
 #include "bpf-event.h"
+#include "synthetic-events.h"
 #include "tool.h"
 #include "../perf.h"
 
tools/perf/util/event.h +2 -116

141 lines not on this page · raw message

tools/perf/util/evsel.c +1 -0
index 5b40b84..5af025c 100644
@@ -40,6 +40,7 @@
 #include "trace-event.h"
 #include "stat.h"
 #include "string2.h"
+#include "util/synthetic-events.h"
 #include "memswap.h"
 #include "util.h"
 #include "../perf-sys.h"
tools/perf/util/header.c +1 -0
index d85827d..a4a8342 100644
@@ -45,6 +45,7 @@
 #include "util.h" // page_size, perf_exe()
 #include "cputopo.h"
 #include "bpf-event.h"
+#include "util/synthetic-events.h"
 
 #include <linux/ctype.h>
 #include <internal/lib.h>
tools/perf/util/intel-bts.c +1 -0
index 15f87a0..3888d4c 100644
@@ -28,6 +28,7 @@
 #include "auxtrace.h"
 #include "intel-pt-decoder/intel-pt-insn-decoder.h"
 #include "intel-bts.h"
+#include "util/synthetic-events.h"
 
 #define MAX_TIMESTAMP (~0ULL)
 
tools/perf/util/intel-pt.c +1 -0
index 9b56fb7..bcdc035 100644
@@ -33,6 +33,7 @@
 #include "tsc.h"
 #include "intel-pt.h"
 #include "config.h"
+#include "util/synthetic-events.h"
 #include "time-utils.h"
 
 #include "../arch/x86/include/uapi/asm/perf_regs.h"
tools/perf/util/machine.c +10 -0
index b4749d3..132de5c 100644
@@ -20,6 +20,7 @@
 #include "symbol.h"
 #include "sort.h"
 #include "strlist.h"
+#include "util/synthetic-events.h"
 #include "target.h"
 #include "thread.h"
 #include "util.h"
@@ -2624,6 +2625,15 @@ int __machine__synthesize_threads(struct machine *machine, struct perf_tool *too
 	return 0;
 }
 
+int machine__synthesize_threads(struct machine *machine, struct target *target,
+				struct perf_thread_map *threads, bool data_mmap,
+				unsigned int nr_threads_synthesize)
+{
+	return __machine__synthesize_threads(machine, NULL, target, threads,
+					     perf_event__process, data_mmap,
+					     nr_threads_synthesize);
+}
+
 pid_t machine__get_current_tid(struct machine *machine, int cpu)
 {
 	int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
tools/perf/util/machine.h +0 -15
index ffd391a..18e13c0 100644
@@ -6,7 +6,6 @@
 #include <linux/rbtree.h>
 #include "map_groups.h"
 #include "dsos.h"
-#include "event.h"
 #include "rwsem.h"
 
 struct addr_location;
@@ -252,20 +251,6 @@ int machines__for_each_thread(struct machines *machines,
 			      int (*fn)(struct thread *thread, void *p),
 			      void *priv);
 
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-				  struct target *target, struct perf_thread_map *threads,
-				  perf_event__handler_t process, bool data_mmap,
-				  unsigned int nr_threads_synthesize);
-static inline
-int machine__synthesize_threads(struct machine *machine, struct target *target,
-				struct perf_thread_map *threads, bool data_mmap,
-				unsigned int nr_threads_synthesize)
-{
-	return __machine__synthesize_threads(machine, NULL, target, threads,
-					     perf_event__process, data_mmap,
-					     nr_threads_synthesize);
-}
-
 pid_t machine__get_current_tid(struct machine *machine, int cpu);
 int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
 			     pid_t tid);
tools/perf/util/session.c +1 -0
index 2b583e6..6267613 100644
@@ -29,6 +29,7 @@
 #include "thread-stack.h"
 #include "sample-raw.h"
 #include "stat.h"
+#include "util/synthetic-events.h"
 #include "util.h"
 #include "ui/progress.h"
 #include "../perf.h"
tools/perf/util/session.h +0 -5
index b7aa076..b4c9428 100644
@@ -138,9 +138,4 @@ int perf_session__deliver_synth_event(struct perf_session *session,
 int perf_event__process_id_index(struct perf_session *session,
 				 union perf_event *event);
 
-int perf_event__synthesize_id_index(struct perf_tool *tool,
-				    perf_event__handler_t process,
-				    struct evlist *evlist,
-				    struct machine *machine);
-
 #endif /* __PERF_SESSION_H */
tools/perf/util/stat.c +1 -0
index 2e318d9..46c8a50 100644
@@ -12,6 +12,7 @@
 #include "target.h"
 #include "evlist.h"
 #include "evsel.h"
+#include "util/synthetic-events.h"
 #include "thread_map.h"
 #include <linux/zalloc.h>
 
tools/perf/util/synthetic-events.h new file +103 -0

103 lines not on this page · raw message

tools/perf/util/tsc.h +2 -12
index e0c3af3..3c5a632 100644
@@ -4,13 +4,12 @@
 
 #include <linux/types.h>
 
-#include "event.h"
-
 struct perf_tsc_conversion {
 	u16 time_shift;
 	u32 time_mult;
 	u64 time_zero;
 };
+
 struct perf_event_mmap_page;
 
 int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
@@ -20,13 +19,4 @@ u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
 u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
 u64 rdtsc(void);
 
-struct perf_event_mmap_page;
-struct perf_tool;
-struct machine;
-
-int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc,
-				struct perf_tool *tool,
-				perf_event__handler_t process,
-				struct machine *machine);
-
-#endif
+#endif // __PERF_TSC_H