diff mbox series

[bpf-next,v2] selftests/bpf: skip the second half of get_branch_snapshot in vm

Message ID 20211007050231.728496-1-songliubraving@fb.com (mailing list archive)
State Accepted
Commit aa67fdb4643616f04cb59b6d090010c371ab1a80
Delegated to: BPF
Headers show
Series [bpf-next,v2] selftests/bpf: skip the second half of get_branch_snapshot in vm | expand

Checks

Context Check Description
netdev/cover_letter success Single patches do not need cover letters
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: john.fastabend@gmail.com; 7 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org kafai@fb.com yhs@fb.com memxor@gmail.com john.fastabend@gmail.com kpsingh@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Fixes tag looks correct
netdev/checkpatch warning CHECK: Comparison to NULL could be written "strstr"
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files
bpf/vmtest-bpf-next success VM_Test
bpf/vmtest-bpf-next-PR success PR summary

Commit Message

Song Liu Oct. 7, 2021, 5:02 a.m. UTC
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(+)

Comments

patchwork-bot+netdevbpf@kernel.org Oct. 8, 2021, 5 a.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed, 6 Oct 2021 22:02:31 -0700 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [bpf-next,v2] selftests/bpf: skip the second half of get_branch_snapshot in vm
    https://git.kernel.org/bpf/bpf-next/c/aa67fdb46436

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

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.