Skip to content

Commit

Permalink
perf tools: Move event synthesizing routines to separate header
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Sep 20, 2019
1 parent bd23ac1 commit ea49e01
Show file tree
Hide file tree
Showing 38 changed files with 154 additions and 177 deletions.
1 change: 1 addition & 0 deletions tools/perf/arch/x86/util/archinsn.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/arch/x86/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/x86/util/machine.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/arch/x86/util/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/code-reading.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "symbol.h"
#include "event.h"
#include "record.h"
#include "util/synthetic-events.h"
#include "thread.h"

#include "tests.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/dwarf-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/event_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/tests/hists_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/tests/mmap-thread-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/sample-parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "event.h"
#include "evsel.h"
#include "debug.h"
#include "util/synthetic-events.h"

#include "tests.h"

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/thread-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/ui/stdio/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 2 additions & 15 deletions tools/perf/util/auxtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/bpf-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
15 changes: 1 addition & 14 deletions tools/perf/util/bpf-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "debug.h"
#include "dso.h"
#include "event.h"
#include "hist.h"
#include "sort.h"
#include "machine.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "stat.h"
#include "session.h"
#include "bpf-event.h"
#include "synthetic-events.h"
#include "tool.h"
#include "../perf.h"

Expand Down
Loading

0 comments on commit ea49e01

Please sign in to comment.