From: Song Liu <songliubraving@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<kernel-team@fb.com>, Song Liu <songliubraving@fb.com>
Subject: [PATCH bpf-next v2] selftests/bpf: skip the second half of get_branch_snapshot in vm
Date: Wed, 6 Oct 2021 22:02:31 -0700 [thread overview]
Message-ID: <20211007050231.728496-1-songliubraving@fb.com> (raw)
VMs running on latest kernel support LBR. However, bpf_get_branch_snapshot
couldn't stop the LBR before too many entries are flushed. Skip the
hit/waste test for VMs before we find a proper fix for LBR in VM.
Fixes: 025bd7c753aa ("selftests/bpf: Add test for bpf_get_branch_snapshot")
Signed-off-by: Song Liu <songliubraving@fb.com>
---
Changes v1 => v2:
1. Move the is_hypervisor() check to later in the test, so that we still
Run the first half of the test in vm
2. Use strncmp instead of strstr. (Andrii)
3. Fix the Fixes tag. (Andrii)
---
.../bpf/prog_tests/get_branch_snapshot.c | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
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 67e86f8d86775..e4f92feb7b32c 100644
--- a/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
+++ b/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
@@ -6,6 +6,30 @@
static int *pfd_array;
static int cpu_cnt;
+static bool is_hypervisor(void)
+{
+ char *line = NULL;
+ bool ret = false;
+ size_t len;
+ FILE *fp;
+
+ fp = fopen("/proc/cpuinfo", "r");
+ if (!fp)
+ return false;
+
+ while (getline(&line, &len, fp) != -1) {
+ if (!strncmp(line, "flags", 5)) {
+ if (strstr(line, "hypervisor") != NULL)
+ ret = true;
+ break;
+ }
+ }
+
+ free(line);
+ fclose(fp);
+ return ret;
+}
+
static int create_perf_events(void)
{
struct perf_event_attr attr = {0};
@@ -83,6 +107,16 @@ void test_get_branch_snapshot(void)
goto cleanup;
}
+ if (is_hypervisor()) {
+ /* As of today, LBR in hypervisor cannot be stopped before
+ * too many entries are flushed. Skip the hit/waste test
+ * for now in hypervisor until we optimize the LBR in
+ * hypervisor.
+ */
+ 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.
--
2.30.2
next reply other threads:[~2021-10-07 5:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 5:02 Song Liu [this message]
2021-10-08 5:00 ` [PATCH bpf-next v2] selftests/bpf: skip the second half of get_branch_snapshot in vm 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=20211007050231.728496-1-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.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).