Skip to content

Commit

Permalink
bpf: Enable bpf support for reading branch records in powerpc
Browse files Browse the repository at this point in the history
Branch data available to bpf programs can be very useful to get
stack traces out of userspace applications.

Commit fff7b64 ("bpf: Add bpf_read_branch_records() helper")
added bpf support to capture branch records in x86. Enable this feature
for powerpc as well.

Commit 67306f8 ("selftests/bpf: Add bpf_read_branch_records()
selftest") adds selftest corresponding to bpf branch read
function bpf_read_branch_records(). Used this selftest to
test bpf support, for reading branch records in powerpc.

Selftest result in power9 box before this patch changes:

[command]# ./test_progs -t perf_branches
Failed to load bpf_testmod.ko into the kernel: -8
WARNING! Selftests relying on bpf_testmod.ko will be skipped.
test_perf_branches_common:PASS:test_perf_branches_load 0 nsec
test_perf_branches_common:PASS:attach_perf_event 0 nsec
test_perf_branches_common:PASS:set_affinity 0 nsec
check_good_sample:PASS:output not valid 0 nsec
check_good_sample:FAIL:read_branches_size err -2
check_good_sample:FAIL:read_branches_stack err -2
check_good_sample:FAIL:read_branches_stack stack bytes written=-2
not multiple of struct size=24
check_good_sample:FAIL:read_branches_global err -2
check_good_sample:FAIL:read_branches_global global bytes written=-2
not multiple of struct size=24
check_good_sample:PASS:read_branches_size 0 nsec
 #75/1 perf_branches_hw:FAIL
 #75/2 perf_branches_no_hw:OK
 #75 perf_branches:FAIL
Summary: 0/1 PASSED, 0 SKIPPED, 2 FAILED

Selftest result in power9 box after this patch changes:

[command]#: ./test_progs -t perf_branches
 #75/1 perf_branches_hw:OK
 #75/2 perf_branches_no_hw:OK
 #75 perf_branches:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Kajol Jain<kjain@linux.ibm.com>
  • Loading branch information
kjain101 authored and Nobody committed Nov 15, 2021
1 parent 3b47f71 commit 46012a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/trace/bpf_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ static const struct bpf_func_proto bpf_perf_prog_read_value_proto = {
BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx,
void *, buf, u32, size, u64, flags)
{
#ifndef CONFIG_X86
#if !(defined(CONFIG_X86) || defined(CONFIG_PPC64))
return -ENOENT;
#else
static const u32 br_entry_size = sizeof(struct perf_branch_entry);
Expand Down

0 comments on commit 46012a7

Please sign in to comment.