diff mbox series

[bpf] perf, bpf: Use subprog name when reporting subprog ksymbol

Message ID 20221114095733.158588-1-houtao@huaweicloud.com (mailing list archive)
State Accepted
Commit 47df8a2f78bc34ff170d147d05b121f84e252b85
Delegated to: BPF
Headers show
Series [bpf] perf, bpf: Use subprog name when reporting subprog ksymbol | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 42 this patch: 42
netdev/cc_maintainers fail 1 blamed authors not CCed: songliubraving@fb.com; 4 maintainers not CCed: mark.rutland@arm.com alexander.shishkin@linux.intel.com namhyung@kernel.org songliubraving@fb.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 42 this patch: 42
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-18 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-VM_Test-26 fail Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-PR fail PR summary
bpf/vmtest-bpf-VM_Test-11 success Logs for test_maps on s390x with gcc

Commit Message

Hou Tao Nov. 14, 2022, 9:57 a.m. UTC
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>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Olsa Nov. 14, 2022, 10:36 a.m. UTC | #1
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
>
patchwork-bot+netdevbpf@kernel.org Nov. 15, 2022, 2:40 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Mon, 14 Nov 2022 17:57:33 +0800 you 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:
> 
> [...]

Here is the summary with links:
  - [bpf] perf, bpf: Use subprog name when reporting subprog ksymbol
    https://git.kernel.org/bpf/bpf/c/47df8a2f78bc

You are awesome, thank you!
diff mbox series

Patch

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);
 		}
 	}
 }