Re: [PATCH v2 perf,bpf 2/2] perf, bpf: show more BPF program info in print_bpf_prog_info()
From: Arnaldo Carvalho de Melo
Date: Tue Mar 19 2019 - 13:41:04 EST
Em Tue, Mar 19, 2019 at 09:54:54AM -0700, Song Liu escreveu:
> This patch enables showing bpf program name, address, and size in the
> header.
>
> Before the patch:
>
> perf report --header-only
> ...
> # bpf_prog_info of id 9
> # bpf_prog_info of id 10
> # bpf_prog_info of id 13
>
> After the patch:
>
> # bpf_prog_info 9: bpf_prog_7be49e3934a125ba addr 0xffffffffa0024947 size 229
> # bpf_prog_info 10: bpf_prog_2a142ef67aaad174 addr 0xffffffffa007c94d size 229
> # bpf_prog_info 13: bpf_prog_47368425825d7384_task__task_newt addr 0xffffffffa0251137 size 369
> index 8cb1189149ec..d9cb4170ae79 100644
> --- a/tools/perf/util/bpf-event.h
> +++ b/tools/perf/util/bpf-event.h
> @@ -38,7 +38,9 @@ int perf_event__synthesize_bpf_events(struct perf_session *session,
> struct record_opts *opts);
> int bpf_event__add_sb_event(struct perf_evlist **evlist,
> struct perf_env *env);
> -
> +void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
> + struct perf_env *env,
> + FILE *fp);
> #else
> static inline int machine__process_bpf_event(struct machine *machine __maybe_unused,
> union perf_event *event __maybe_unused,
> @@ -61,5 +63,11 @@ static inline int bpf_event__add_sb_event(struct perf_evlist **evlist __maybe_un
> return 0;
> }
>
> +void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
Missing static inline here, as well as the __maybe_unused, I'm fixing it
> + struct perf_env *env,
> + FILE *fp)
> +{
> +
> +}
> #endif // HAVE_LIBBPF_SUPPORT
> #endif
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 01dda2f65d36..b9e693825873 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -1468,8 +1468,9 @@ static void print_bpf_prog_info(struct feat_fd *ff, FILE *fp)
>
> node = rb_entry(next, struct bpf_prog_info_node, rb_node);
> next = rb_next(&node->rb_node);
> - fprintf(fp, "# bpf_prog_info of id %u\n",
> - node->info_linear->info.id);
> +
> + bpf_event__print_bpf_prog_info(&node->info_linear->info,
> + env, fp);
> }
>
> up_read(&env->bpf_progs.lock);
> --
> 2.17.1
--
- Arnaldo