From: Puranjay Mohan <puranjay@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Cc: Puranjay Mohan <puranjay@kernel.org>,
bpf@vger.kernel.org,
Anshuman Khandual <anshuman.khandual@arm.com>,
Puranjay Mohan <puranjay12@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Leo Yan <leo.yan@arm.com>, Rob Herring <robh@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
James Clark <james.clark@linaro.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Shuah Khan <shuah@kernel.org>, Breno Leitao <leitao@debian.org>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Stephane Eranian <eranian@google.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Usama Arif <usama.arif@linux.dev>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: [PATCH v6 3/3] selftests/bpf: Adjust entry thresholds for ARM64 BRBE
Date: Mon, 10 Aug 2026 09:46:20 -0700 [thread overview]
Message-ID: <20260810164622.1829843-4-puranjay@kernel.org> (raw)
In-Reply-To: <20260810164622.1829843-1-puranjay@kernel.org>
The test bounds how many branch entries are spent reaching the snapshot
helper. The limit of 10 was calibrated on x86, which spends about 7.
arm64 spends up to 14: eight in the BPF trampoline, which makes
out-of-line calls and branches more than x86 does, and the rest in
masking exceptions before the branch buffer can be paused.
Raise the limit to 18 on arm64, leaving room for compiler and
configuration variation.
The skip threshold has to move with it. BRBE implements 8, 16, 32 or 64
records, so on a 16 record buffer the existing 'total_entries < 16'
check does not skip, but 14 wasted entries leave only 2 for the hit test
and it fails instead. Derive the minimum from the two limits it depends
on, so the arms cannot drift apart.
This leaves 8 and 16 record implementations skipped, since the required
hit count is absolute and does not scale with the buffer.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
.../bpf/prog_tests/get_branch_snapshot.c | 28 ++++++++++++-------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c b/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
index 0394a1156d99d..e06ae6798dbec 100644
--- a/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
+++ b/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
@@ -108,21 +108,29 @@ void serial_test_get_branch_snapshot(void)
trigger_module_test_read(100);
- if (skel->bss->total_entries < 16) {
+ /* Reaching the snapshot helper costs a few entries: about 7 on x86_64
+ * and about 14 on arm64, whose BPF trampoline branches more. Bound it
+ * so that a regression shows up here.
+ *
+ * Derive the buffer minimum from the two limits it depends on, so the
+ * arms cannot drift apart.
+ */
+#if defined(__aarch64__)
+#define WASTED_ENTRIES_MAX 18
+#else
+#define WASTED_ENTRIES_MAX 10
+#endif
+#define TEST1_HITS_MIN 7
+#define TOTAL_ENTRIES_MIN (WASTED_ENTRIES_MAX - 1 + TEST1_HITS_MIN)
+
+ if (skel->bss->total_entries < TOTAL_ENTRIES_MIN) {
/* too few entries for the hit/waste test */
test__skip();
goto cleanup;
}
- ASSERT_GT(skel->bss->test1_hits, 6, "find_looptest_in_lbr");
-
- /* Given we stop LBR in software, we will waste a few entries.
- * But we should try to waste as few as possible entries. We are at
- * about 7 on x86_64 systems.
- * Add a check for < 10 so that we get heads-up when something
- * changes and wastes too many entries.
- */
- ASSERT_LT(skel->bss->wasted_entries, 10, "check_wasted_entries");
+ ASSERT_GT(skel->bss->test1_hits, TEST1_HITS_MIN - 1, "find_looptest_in_lbr");
+ ASSERT_LT(skel->bss->wasted_entries, WASTED_ENTRIES_MAX, "check_wasted_entries");
cleanup:
get_branch_snapshot__destroy(skel);
--
2.53.0-Meta
prev parent reply other threads:[~2026-08-10 16:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 16:46 [PATCH v6 0/3] arm64: Add BRBE support for bpf_get_branch_snapshot() Puranjay Mohan
2026-08-10 16:46 ` [PATCH v6 1/3] arm64: Add raw variants of local_daif_save() and local_daif_restore() Puranjay Mohan
2026-08-10 16:46 ` [PATCH v6 2/3] perf/arm64: Add BRBE support for bpf_get_branch_snapshot() Puranjay Mohan
2026-08-10 16:56 ` sashiko-bot
2026-08-10 16:46 ` Puranjay Mohan [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=20260810164622.1829843-4-puranjay@kernel.org \
--to=puranjay@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=andrii@kernel.org \
--cc=anshuman.khandual@arm.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=puranjay12@gmail.com \
--cc=ravi.bangoria@amd.com \
--cc=robh@kernel.org \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=usama.arif@linux.dev \
--cc=will@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.