mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>
Subject: Re: [PATCH perf,bpf 2/2] perf, bpf: show BPF program name in print_bpf_prog_info()
Date: Thu, 14 Mar 2019 18:29:14 +0000	[thread overview]
Message-ID: <852EEAFE-328D-491F-A907-58B18EE02265@fb.com> (raw)
In-Reply-To: <20190314182538.1294526-3-songliubraving@fb.com>



> On Mar 14, 2019, at 11:25 AM, Song Liu <songliubraving@fb.com> wrote:
> 
> This patch enables showing bpf program name 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
>  # bpf_prog_info 10: bpf_prog_2a142ef67aaad174
>  # bpf_prog_info 13: bpf_prog_47368425825d7384_task__task_newt
> 
> Signed-off-by: Song Liu <songliubraving@fb.com>

Please ignore this patch, and use the other PATCH 2/2 with address and 
size information instead. 

Thanks,
Song

> ---
> tools/perf/util/bpf-event.c | 36 ++++++++++++++++++++++++++++++++++++
> tools/perf/util/bpf-event.h | 10 +++++++++-
> tools/perf/util/header.c    |  5 +++--
> 3 files changed, 48 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index 6e035e08aa2d..dde35a36e2de 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -433,3 +433,39 @@ int bpf_event__add_sb_event(struct perf_evlist **evlist,
> 
> 	return perf_evlist__add_sb_event(evlist, &attr, bpf_event__sb_cb, env);
> }
> +
> +void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
> +				    struct perf_env *env,
> +				    FILE *fp)
> +{
> +	char name[KSYM_NAME_LEN];
> +	struct btf *btf = NULL;
> +	u32 sub_prog_cnt, i;
> +
> +	sub_prog_cnt = info->nr_jited_ksyms;
> +	if (sub_prog_cnt != info->nr_prog_tags ||
> +	    sub_prog_cnt != info->nr_jited_func_lens)
> +		return;
> +
> +	if (info->btf_id) {
> +		struct btf_node *node;
> +
> +		node = perf_env__find_btf(env, info->btf_id);
> +		if (node)
> +			btf = btf__new((__u8 *)(node->data),
> +				       node->data_size);
> +	}
> +
> +	if (sub_prog_cnt == 1) {
> +		synthesize_bpf_prog_name(name, KSYM_NAME_LEN, info, btf, 0);
> +		fprintf(fp, "# bpf_prog_info %u: %s\n", info->id, name);
> +		return;
> +	}
> +
> +	fprintf(fp, "# bpf_prog_info %u:\n", info->id);
> +	for (i = 0; i < sub_prog_cnt; i++) {
> +		synthesize_bpf_prog_name(name, KSYM_NAME_LEN, info, btf, i);
> +
> +		fprintf(fp, "# \tsub_prog %u: %s\n", i, name);
> +	}
> +}
> diff --git a/tools/perf/util/bpf-event.h b/tools/perf/util/bpf-event.h
> index 249909c826e7..4270dfd9cde9 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 int bpf_event__add_sb_event(struct perf_evlist **evlist __maybe_unused,
> 	return 0;
> }
> 
> +void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
> +				    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 7decd2d1dbda..588a80bdd500 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -1434,8 +1434,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
> 


      reply	other threads:[~2019-03-14 18:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 18:25 [PATCH perf,bpf 0/2] show bpf program info from perf.data header Song Liu
2019-03-14 18:25 ` [PATCH perf,bpf 1/2] perf, bpf: refactor perf_event__synthesize_one_bpf_prog() Song Liu
2019-03-14 18:25 ` [PATCH perf,bpf 2/2] perf, bpf: show BPF program name in print_bpf_prog_info() Song Liu
2019-03-14 18:29   ` Song Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=852EEAFE-328D-491F-A907-58B18EE02265@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®