From: Jiri Olsa <olsajiri@gmail.com>
To: Hou Tao <houtao@huaweicloud.com>
Cc: bpf@vger.kernel.org, Andrii Nakryiko <andrii@kernel.org>,
	Song Liu <song@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Stanislav Fomichev <sdf@google.com>,
	houtao1@huawei.com, linux-perf-users@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: Re: [PATCH bpf] perf, bpf: Use subprog name when reporting subprog ksymbol
Date: Mon, 14 Nov 2022 11:36:25 +0100	[thread overview]
Message-ID: <Y3IaKXuDcR7dr8vp@krava> (raw)
In-Reply-To: <20221114095733.158588-1-houtao@huaweicloud.com>
On Mon, Nov 14, 2022 at 05:57:33PM +0800, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Since commit bfea9a8574f3 ("bpf: Add name to struct bpf_ksym"), when
> reporting subprog ksymbol to perf, prog name instead of subprog name is
> used. The backtrace of bpf program with subprogs will be incorrect as
> shown below:
> 
>   ffffffffc02deace bpf_prog_e44a3057dcb151f8_overwrite+0x66
>   ffffffffc02de9f7 bpf_prog_e44a3057dcb151f8_overwrite+0x9f
>   ffffffffa71d8d4e trace_call_bpf+0xce
>   ffffffffa71c2938 perf_call_bpf_enter.isra.0+0x48
> 
> overwrite is the entry program and it invokes the overwrite_htab subprog
> through bpf_loop, but in above backtrace, overwrite program just jumps
> inside itself.
> 
> Fixing it by using subprog name when reporting subprog ksymbol. After
> the fix, the output of perf script will be correct as shown below:
> 
>   ffffffffc031aad2 bpf_prog_37c0bec7d7c764a4_overwrite_htab+0x66
>   ffffffffc031a9e7 bpf_prog_c7eb827ef4f23e71_overwrite+0x9f
>   ffffffffa3dd8d4e trace_call_bpf+0xce
>   ffffffffa3dc2938 perf_call_bpf_enter.isra.0+0x48
> 
> Fixes: bfea9a8574f3 ("bpf: Add name to struct bpf_ksym")
> Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
> ---
>  kernel/events/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 4ec3717003d5..8b50ef2569d9 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -9030,7 +9030,7 @@ static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,
>  				PERF_RECORD_KSYMBOL_TYPE_BPF,
>  				(u64)(unsigned long)subprog->bpf_func,
>  				subprog->jited_len, unregister,
> -				prog->aux->ksym.name);
> +				subprog->aux->ksym.name);
>  		}
>  	}
>  }
> -- 
> 2.29.2
> 
next prev parent reply	other threads:[~2022-11-14 10:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14  9:57 [PATCH bpf] perf, bpf: Use subprog name when reporting subprog ksymbol Hou Tao
2022-11-14 10:36 ` Jiri Olsa [this message]
2022-11-15 14:40 ` patchwork-bot+netdevbpf
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=Y3IaKXuDcR7dr8vp@krava \
    --to=olsajiri@gmail.com \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=houtao1@huawei.com \
    --cc=houtao@huaweicloud.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).