We want to handle syscall exit path differently so let's split the unaugmented exit BPF program. Currently it does nothing (same as sys_enter). Signed-off-by: Namhyung Kim --- tools/perf/builtin-trace.c | 8 +++++--- tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c | 8 +++++++- tools/perf/util/bpf_trace_augment.c | 9 +++++++-- tools/perf/util/trace_augment.h | 10 ++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fe737b3ac6e67d3b..1bc912273af2db66 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3770,13 +3770,15 @@ static void trace__init_syscall_bpf_progs(struct trace *trace, int e_machine, in static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int e_machine, int id) { struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, id); - return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(unaugmented_prog); + return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : + bpf_program__fd(augmented_syscalls__unaugmented_enter()); } static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int e_machine, int id) { struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, id); - return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(unaugmented_prog); + return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : + bpf_program__fd(augmented_syscalls__unaugmented_exit()); } static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int e_machine, int key, unsigned int *beauty_array) @@ -3977,7 +3979,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace, int e_m if (augmented_syscalls__get_map_fds(&map_enter_fd, &map_exit_fd, &beauty_map_fd) < 0) return -1; - unaugmented_prog = augmented_syscalls__unaugmented(); + unaugmented_prog = augmented_syscalls__unaugmented_enter(); for (int i = 0, num_idx = syscalltbl__num_idx(e_machine); i < num_idx; ++i) { int prog_fd, key = syscalltbl__id_at_idx(e_machine, i); diff --git a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c index 2c9bcc6b8cb0c06c..0016deb321fe0d97 100644 --- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c +++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c @@ -180,7 +180,13 @@ unsigned int augmented_arg__read_str(struct augmented_arg *augmented_arg, const } SEC("tp/raw_syscalls/sys_enter") -int syscall_unaugmented(struct trace_event_raw_sys_enter *args) +int sys_enter_unaugmented(struct trace_event_raw_sys_enter *args) +{ + return 1; +} + +SEC("tp/raw_syscalls/sys_exit") +int sys_exit_unaugmented(struct trace_event_raw_sys_exit *args) { return 1; } diff --git a/tools/perf/util/bpf_trace_augment.c b/tools/perf/util/bpf_trace_augment.c index 56ed17534caa4f3f..f2792ede0249ab89 100644 --- a/tools/perf/util/bpf_trace_augment.c +++ b/tools/perf/util/bpf_trace_augment.c @@ -115,9 +115,14 @@ int augmented_syscalls__get_map_fds(int *enter_fd, int *exit_fd, int *beauty_fd) return 0; } -struct bpf_program *augmented_syscalls__unaugmented(void) +struct bpf_program *augmented_syscalls__unaugmented_enter(void) { - return skel->progs.syscall_unaugmented; + return skel->progs.sys_enter_unaugmented; +} + +struct bpf_program *augmented_syscalls__unaugmented_exit(void) +{ + return skel->progs.sys_exit_unaugmented; } struct bpf_program *augmented_syscalls__find_by_title(const char *name) diff --git a/tools/perf/util/trace_augment.h b/tools/perf/util/trace_augment.h index 4f729bc6775304b4..70b11d3f52906c36 100644 --- a/tools/perf/util/trace_augment.h +++ b/tools/perf/util/trace_augment.h @@ -14,7 +14,8 @@ void augmented_syscalls__setup_bpf_output(void); int augmented_syscalls__set_filter_pids(unsigned int nr, pid_t *pids); int augmented_syscalls__get_map_fds(int *enter_fd, int *exit_fd, int *beauty_fd); struct bpf_program *augmented_syscalls__find_by_title(const char *name); -struct bpf_program *augmented_syscalls__unaugmented(void); +struct bpf_program *augmented_syscalls__unaugmented_enter(void); +struct bpf_program *augmented_syscalls__unaugmented_exit(void); void augmented_syscalls__cleanup(void); #else /* !HAVE_BPF_SKEL */ @@ -52,7 +53,12 @@ augmented_syscalls__find_by_title(const char *name __maybe_unused) return NULL; } -static inline struct bpf_program *augmented_syscalls__unaugmented(void) +static inline struct bpf_program *augmented_syscalls__unaugmented_enter(void) +{ + return NULL; +} + +static inline struct bpf_program *augmented_syscalls__unaugmented_exit(void) { return NULL; } -- 2.51.0.rc1.167.g924127e9c0-goog