From: Kajol Jain <kjain@linux.ibm.com>
To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: acme@kernel.org, peterz@infradead.org, songliubraving@fb.com,
daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com,
yhs@fb.com, john.fastabend@gmail.com, davem@davemloft.net,
kpsingh@kernel.org, hawk@kernel.org, kuba@kernel.org,
maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com,
linux-perf-users@vger.kernel.org, rnsastry@linux.ibm.com,
kjain@linux.ibm.com
Subject: [PATCH] bpf: Enable bpf support for reading branch records in powerpc
Date: Mon, 15 Nov 2021 10:14:37 +0530 [thread overview]
Message-ID: <20211115044437.12047-1-kjain@linux.ibm.com> (raw)
Branch data available to bpf programs can be very useful to get
stack traces out of userspace applications.
Commit fff7b64355ea ("bpf: Add bpf_read_branch_records() helper")
added bpf support to capture branch records in x86. Enable this feature
for powerpc as well.
Commit 67306f84ca78 ("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>
---
kernel/trace/bpf_trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index fdd14072fc3b..2b7343b64bb7 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1245,7 +1245,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);
--
2.27.0
next reply other threads:[~2021-11-15 4:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 4:44 Kajol Jain [this message]
2021-11-15 23:30 ` [PATCH] bpf: Enable bpf support for reading branch records in powerpc Daniel Borkmann
2021-11-16 8:34 ` Peter Zijlstra
2021-11-16 15:21 ` kajoljain
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=20211115044437.12047-1-kjain@linux.ibm.com \
--to=kjain@linux.ibm.com \
--cc=acme@kernel.org \
--cc=andrii@kernel.org \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=maddy@linux.ibm.com \
--cc=peterz@infradead.org \
--cc=rnsastry@linux.ibm.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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