perf tools: Move event synthesizing routines to separate header
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 18 Sep 2019 14:36:13 +0000 (11:36 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 20 Sep 2019 12:19:22 +0000 (09:19 -0300)
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.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-yvx9u1mf7baq6cu1abfhbqgs@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
38 files changed:
tools/perf/arch/x86/util/archinsn.c
tools/perf/arch/x86/util/event.c
tools/perf/arch/x86/util/machine.c
tools/perf/arch/x86/util/tsc.c
tools/perf/builtin-inject.c
tools/perf/builtin-kvm.c
tools/perf/builtin-record.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/tests/code-reading.c
tools/perf/tests/cpumap.c
tools/perf/tests/dwarf-unwind.c
tools/perf/tests/event_update.c
tools/perf/tests/hists_common.c
tools/perf/tests/mmap-thread-lookup.c
tools/perf/tests/sample-parsing.c
tools/perf/tests/stat.c
tools/perf/tests/thread-map.c
tools/perf/ui/stdio/hist.c
tools/perf/util/auxtrace.c
tools/perf/util/auxtrace.h
tools/perf/util/bpf-event.c
tools/perf/util/bpf-event.h
tools/perf/util/callchain.c
tools/perf/util/event.c
tools/perf/util/event.h
tools/perf/util/evsel.c
tools/perf/util/header.c
tools/perf/util/intel-bts.c
tools/perf/util/intel-pt.c
tools/perf/util/machine.c
tools/perf/util/machine.h
tools/perf/util/session.c
tools/perf/util/session.h
tools/perf/util/stat.c
tools/perf/util/synthetic-events.h [new file with mode: 0644]
tools/perf/util/tsc.h

index 9876c7a7ed7cc654a3c2445b5728c94f7ca4f645..3e6791531ca5a1799f92f7db8c11c9b3b107439b 100644 (file)
@@ -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"
index a3a0b688477992e52a4521c654fbfceddcb28931..d357c625c09ffb0e9ae6ea8a90f05a0425b5d4ee 100644 (file)
@@ -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"
index 42418040bc07a2818d1be150be7f2ef6d2637c1d..f0c289862f9f5cff476ca6c9ffc96051c6a9a412 100644 (file)
@@ -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
index c5197a15119b075fafe144efa49323c62522b238..2f55afb14e1f5711495bae30def8d2802a1e54b7 100644 (file)
@@ -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,
index c14f40b858bc760c1b9dc632fb4db617a19887b4..23a76cf3846f4605834af2d405296a898e0869f5 100644 (file)
@@ -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>
index 0a4fcbe32bf6434efd406a95db4be018e16a35ea..ac6d6e061dc57e34dc278b1e19bde9f573e9486f 100644 (file)
@@ -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"
index 1447004eee8accfc57aa161d7a87b477f63f0b6b..907d4d4677a3d0aa80058f7b3aaccd5eb7a06127 100644 (file)
@@ -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"
index b55e8060810b5345b28675790c13f46f353e1874..eece3d1e429ab8de6e409e74f0cff1c69c6fc96c 100644 (file)
@@ -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"
index 726e3f2dd8c7dae819028f218495c279b2659272..b052470f89b419bc4b9cedbc190308ce076c75f5 100644 (file)
@@ -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>
index 0f633f0d6be8dd0f25e3c0297647cded23745483..f0f735093e2179ad1c6518e03bc8dae78eb34af1 100644 (file)
@@ -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>
index 8d9020c46ca97698baec3f8c041e30a7d4dca8bd..fd02c1f1d976f20204449b91ea747f0454292f1e 100644 (file)
@@ -24,6 +24,7 @@
 #include "symbol.h"
 #include "event.h"
 #include "record.h"
+#include "util/synthetic-events.h"
 #include "thread.h"
 
 #include "tests.h"
index 39493de50117be335c315f0b518a07e5db2b25b4..8a0d236202b05ba179199b2709080b949c5d52d3 100644 (file)
@@ -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>
index 4125255ff637a362cb4f67564e4b0203ebb4b959..4f4ecbcbe87e7c9538bcd30d873ec009ad13c035 100644 (file)
@@ -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"
index 317eb8c5ccd49de132c18e2f8517cb2699dd6262..4bb772e2b73de1c9e1e7ab7882c0954519b7d513 100644 (file)
@@ -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"
index de110d8f169b3fa52c8813201571dc3bc65342a3..6f34d08b84e5e48a82b408bc7a1933fa902eb605 100644 (file)
@@ -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;
index f72889c1353840ac2e0aca5fce03ae8bd3589a10..33b496d194f495e059543bd0b01341d86306edf0 100644 (file)
@@ -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
 
index e3b965e7a2335802b7fcc941fc3a4b97e61abec8..3a02426db9a6399e868577d4c9c42a26d1dbec4a 100644 (file)
@@ -12,6 +12,7 @@
 #include "event.h"
 #include "evsel.h"
 #include "debug.h"
+#include "util/synthetic-events.h"
 
 #include "tests.h"
 
index cc10b4116c9f960153d3427491b9290442b14a1e..c1911501c39c303091dad21bcc9f8f03c308b4f8 100644 (file)
@@ -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)
index 39168c57943b2b6a573f35046e8bf9b0d656915d..28f51c4bd373c3d0de18e271c5266174594c0e0a 100644 (file)
@@ -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>
 
index 832ca6cfbe305ccd7729c304a64d0221a4d3124f..5365606e9dad1453b1a3e7aed0ff090e78938ce8 100644 (file)
@@ -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"
index 1c0ff5acff8391b81fb9a6543d6abfba6f06e79f..0e8c89cf7cad3d531b283926d4704003e5f47d28 100644 (file)
@@ -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"
index 1ed902a24a390b6994366fbc41dba75e9f301d49..b110aec1da4d27cbc1edee1b9776286c53aabdf9 100644 (file)
 #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,
index 7a3d4b12532369fc537bbd7c02e1fb15a3d12511..f7ed5d122e229ace2200cf31022d60c5a192b572 100644 (file)
@@ -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))
 
index a01c2fd68c03b0619d6e3ca42b0562595529eab0..81fdc88e6c1a879062e8b36b4af013522bce7688 100644 (file)
@@ -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)
 {
index c14646c1f2eba471ba2f63abfab717538c150e6c..9a9b56ed3f0a4eb168ef0588a5d001b8f2abcb0a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "debug.h"
 #include "dso.h"
+#include "event.h"
 #include "hist.h"
 #include "sort.h"
 #include "machine.h"
index d65ae7cf9316d6a8c2c7117bf4260511d2165f9a..043a08fc7398b6fc94535880ff10e1aa863aa1d5 100644 (file)
@@ -32,6 +32,7 @@
 #include "stat.h"
 #include "session.h"
 #include "bpf-event.h"
+#include "synthetic-events.h"
 #include "tool.h"
 #include "../perf.h"
 
index 89a2404170a00c8ce453e6884c9aa53af92e1baa..a0a0c91cde4a6f728df129236f612c3860f536d0 100644 (file)
@@ -279,95 +279,13 @@ enum {
 
 void perf_event__print_totals(void);
 
-struct evlist;
-struct evsel;
-struct perf_session;
-struct perf_tool;
-struct perf_thread_map;
 struct perf_cpu_map;
+struct perf_record_stat_config;
 struct perf_stat_config;
-struct perf_counts_values;
-
-typedef int (*perf_event__handler_t)(struct perf_tool *tool,
-                                    union perf_event *event,
-                                    struct perf_sample *sample,
-                                    struct machine *machine);
+struct perf_tool;
 
-int perf_event__synthesize_stat_events(struct perf_stat_config *config,
-                                      struct perf_tool *tool,
-                                      struct evlist *evlist,
-                                      perf_event__handler_t process,
-                                      bool attrs);
-int perf_event__synthesize_attr(struct perf_tool *tool,
-                               struct perf_event_attr *attr, u32 ids, u64 *id,
-                               perf_event__handler_t process);
-int perf_event__synthesize_attrs(struct perf_tool *tool,
-                                struct evlist *evlist,
-                                perf_event__handler_t process);
-int perf_event__synthesize_build_id(struct perf_tool *tool,
-                                   struct dso *pos, u16 misc,
-                                   perf_event__handler_t process,
-                                   struct machine *machine);
-int perf_event__synthesize_extra_attr(struct perf_tool *tool,
-                                     struct evlist *evsel_list,
-                                     perf_event__handler_t process,
-                                     bool is_pipe);
-int perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
-                                            struct evsel *evsel,
-                                            perf_event__handler_t process);
-int perf_event__synthesize_event_update_name(struct perf_tool *tool,
-                                            struct evsel *evsel,
-                                            perf_event__handler_t process);
-int perf_event__synthesize_event_update_scale(struct perf_tool *tool,
-                                             struct evsel *evsel,
-                                             perf_event__handler_t process);
-int perf_event__synthesize_event_update_unit(struct perf_tool *tool,
-                                            struct evsel *evsel,
-                                            perf_event__handler_t process);
-int perf_event__synthesize_features(struct perf_tool *tool,
-                                   struct perf_session *session,
-                                   struct evlist *evlist,
-                                   perf_event__handler_t process);
-int perf_event__synthesize_tracing_data(struct perf_tool *tool,
-                                       int fd, struct evlist *evlist,
-                                       perf_event__handler_t process);
-int perf_event__synthesize_thread_map(struct perf_tool *tool,
-                                     struct perf_thread_map *threads,
-                                     perf_event__handler_t process,
-                                     struct machine *machine, bool mmap_data);
-int perf_event__synthesize_thread_map2(struct perf_tool *tool,
-                                     struct perf_thread_map *threads,
-                                     perf_event__handler_t process,
-                                     struct machine *machine);
-int perf_event__synthesize_cpu_map(struct perf_tool *tool,
-                                  struct perf_cpu_map *cpus,
-                                  perf_event__handler_t process,
-                                  struct machine *machine);
-int perf_event__synthesize_threads(struct perf_tool *tool,
-                                  perf_event__handler_t process,
-                                  struct machine *machine, bool mmap_data,
-                                  unsigned int nr_threads_synthesize);
-int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
-                                      perf_event__handler_t process,
-                                      struct machine *machine);
-int perf_event__synthesize_stat_config(struct perf_tool *tool,
-                                      struct perf_stat_config *config,
-                                      perf_event__handler_t process,
-                                      struct machine *machine);
 void perf_event__read_stat_config(struct perf_stat_config *config,
                                  struct perf_record_stat_config *event);
-int perf_event__synthesize_stat(struct perf_tool *tool,
-                               u32 cpu, u32 thread, u64 id,
-                               struct perf_counts_values *count,
-                               perf_event__handler_t process,
-                               struct machine *machine);
-int perf_event__synthesize_stat_round(struct perf_tool *tool,
-                                     u64 time, u64 type,
-                                     perf_event__handler_t process,
-                                     struct machine *machine);
-int perf_event__synthesize_modules(struct perf_tool *tool,
-                                  perf_event__handler_t process,
-                                  struct machine *machine);
 
 int perf_event__process_comm(struct perf_tool *tool,
                             union perf_event *event,
@@ -421,10 +339,6 @@ int perf_event__process_bpf(struct perf_tool *tool,
                            union perf_event *event,
                            struct perf_sample *sample,
                            struct machine *machine);
-int perf_tool__process_synth_event(struct perf_tool *tool,
-                                  union perf_event *event,
-                                  struct machine *machine,
-                                  perf_event__handler_t process);
 int perf_event__process(struct perf_tool *tool,
                        union perf_event *event,
                        struct perf_sample *sample,
@@ -446,34 +360,6 @@ void thread__resolve(struct thread *thread, struct addr_location *al,
 
 const char *perf_event__name(unsigned int id);
 
-size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
-                                    u64 read_format);
-int perf_event__synthesize_sample(union perf_event *event, u64 type,
-                                 u64 read_format,
-                                 const struct perf_sample *sample);
-
-pid_t perf_event__synthesize_comm(struct perf_tool *tool,
-                                 union perf_event *event, pid_t pid,
-                                 perf_event__handler_t process,
-                                 struct machine *machine);
-
-int perf_event__synthesize_namespaces(struct perf_tool *tool,
-                                     union perf_event *event,
-                                     pid_t pid, pid_t tgid,
-                                     perf_event__handler_t process,
-                                     struct machine *machine);
-
-int perf_event__synthesize_mmap_events(struct perf_tool *tool,
-                                      union perf_event *event,
-                                      pid_t pid, pid_t tgid,
-                                      perf_event__handler_t process,
-                                      struct machine *machine,
-                                      bool mmap_data);
-
-int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
-                                      perf_event__handler_t process,
-                                      struct machine *machine);
-
 size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
 size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
 size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp);
index 5b40b840624c184d6062e0170385319bff73bf1e..5af025c80ec5819937e98c1c6d6aa7a654c07b36 100644 (file)
@@ -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"
index d85827de1b600affece581dcd0edf323a22a7d58..a4a8342eba989dfc9cdc938e26024a3f1ba9379c 100644 (file)
@@ -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>
index 15f87a09f4fe1ff4189f824c208ab8b16cce4203..3888d4cd3ed1bd123dda38b5292c75b8eec3d0a1 100644 (file)
@@ -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)
 
index 9b56fb74bedf84f172c88d3dc7df0e8045e22199..bcdc0359f7cf27d2a94d13b6e237cf7ec0ec4306 100644 (file)
@@ -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"
index b4749d3eed08552ce19b304972be1140f3c5c2b5..132de5cfb9b976feee51e465a846ee31d37176f6 100644 (file)
@@ -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);
index ffd391a925a6e04f894d6aa084869b6b6711f418..18e13c0ccd6afd9c82c5e024993b2d43494ebc7c 100644 (file)
@@ -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);
index 2b583e6adb493df54db8f7964b1f7d7a907bb1ae..6267613b551d78ed7899799b840b88116f86df24 100644 (file)
@@ -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"
index b7aa076ab6fd6388b2f60348e882ca7b6d86eb14..b4c9428c18f0728445e462526d52c6bb380cdeac 100644 (file)
@@ -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 */
index 2e318d95c528d0e874e78d12b31a98772338d9a5..46c8a5027e124e87f9fbbc5daf034919b03ccede 100644 (file)
@@ -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>
 
diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic-events.h
new file mode 100644 (file)
index 0000000..baead0c
--- /dev/null
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PERF_SYNTHETIC_EVENTS_H
+#define __PERF_SYNTHETIC_EVENTS_H
+
+#include <stdbool.h>
+#include <sys/types.h> // pid_t
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+struct auxtrace_record;
+struct dso;
+struct evlist;
+struct evsel;
+struct machine;
+struct perf_counts_values;
+struct perf_cpu_map;
+struct perf_event_attr;
+struct perf_event_mmap_page;
+struct perf_sample;
+struct perf_session;
+struct perf_stat_config;
+struct perf_thread_map;
+struct perf_tool;
+struct record_opts;
+struct target;
+
+union perf_event;
+
+typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
+                                    struct perf_sample *sample, struct machine *machine);
+
+int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
+int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
+int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
+int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
+int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
+int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
+int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
+int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
+int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
+int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct machine *machine, bool mmap_data);
+int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_namespaces(struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
+int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attrs);
+int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_stat(struct perf_tool *tool, u32 cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
+int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, bool mmap_data);
+int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool mmap_data, unsigned int nr_threads_synthesize);
+int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
+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);
+pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine);
+
+int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
+
+size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
+
+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);
+int machine__synthesize_threads(struct machine *machine, struct target *target,
+                               struct perf_thread_map *threads, bool data_mmap,
+                               unsigned int nr_threads_synthesize);
+
+#ifdef HAVE_AUXTRACE_SUPPORT
+int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
+                                        struct perf_session *session, perf_event__handler_t process);
+
+#else // HAVE_AUXTRACE_SUPPORT
+
+#include <errno.h>
+
+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;
+}
+#endif // HAVE_AUXTRACE_SUPPORT
+
+#ifdef HAVE_LIBBPF_SUPPORT
+int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
+                                     struct machine *machine, struct record_opts *opts);
+#else // HAVE_LIBBPF_SUPPORT
+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;
+}
+#endif // HAVE_LIBBPF_SUPPORT
+
+#endif // __PERF_SYNTHETIC_EVENTS_H
index e0c3af34ac8dfc78ff21a7e594e5c30797ab6274..3c5a632ee57c56437a4ce66bd091189c9abd6f34 100644 (file)
@@ -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