Skip to contentSkip to conversation

perf test: Fix skipping branch stack sampling test

PATCH Applied James Clark 3 participants 4 messages Oct 28, 2022 – Nov 8, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Fix skipping branch stack sampling test

Commit f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter") added a skip if certain branch options aren't available. But the change added both -b (--branch-any) and --branch-filter options at the same time, which will always result in a failure on any platform because the arguments can't be used together.

Fix this by removing -b (--branch-any) and leaving --branch-filter which already specifies 'any'. Also add warning messages to the test and perf tool.

Output on x86 before this fix:

   $ sudo ./perf test branch
   108: Check branch stack sampling         : Skip

After:

   $ sudo ./perf test branch
   108: Check branch stack sampling         : Ok
Fixes f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter")
---
 tools/perf/tests/shell/test_brstack.sh | 5 ++++-
 tools/perf/util/parse-branch-options.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_brstack.sh +4 -1
index ec801cffae6b..d7ff5c4b4da4 100755
@@ -13,7 +13,10 @@ fi
 
 # skip the test if the hardware doesn't support branch stack sampling
 # and if the architecture doesn't support filter types: any,save_type,u
-perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2
+if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then
+	echo "skip: system doesn't support filter types: any,save_type,u"
+	exit 2
+fi
 
 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
 
tools/perf/util/parse-branch-options.c +3 -1
index 00588b9db474..31faf2bb49ff 100644
@@ -102,8 +102,10 @@ parse_branch_stack(const struct option *opt, const char *str, int unset)
 	/*
 	 * cannot set it twice, -b + --branch-filter for instance
 	 */
-	if (*mode)
+	if (*mode) {
+		pr_err("Error: Can't use --branch-any (-b) with --branch-filter (-j).\n");
 		return -1;
+	}
 
 	return parse_branch_str(str, mode);
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 11 lines · James Clark

Commit f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter") added a skip if certain branch options aren't available. But the change added both -b (--branch-any) and --branch-filter options at the same time, which will always result in a failure on any platform because the arguments can't be used together.

Fix this by removing -b (--branch-any) and leaving --branch-filter which already specifies 'any'. Also add warning messages to the test and perf tool.

Hi Athira,

Are you able to check if this still skips for you on PowerPC with this new change?

Thanks
James

Quoted 49 lines

Output on x86 before this fix:

   $ sudo ./perf test branch
   108: Check branch stack sampling         : Skip

After:

   $ sudo ./perf test branch
   108: Check branch stack sampling         : Ok
Fixes f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter")
---
 tools/perf/tests/shell/test_brstack.sh | 5 ++++-
 tools/perf/util/parse-branch-options.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_brstack.sh +4 -1
index ec801cffae6b..d7ff5c4b4da4 100755
@@ -13,7 +13,10 @@ fi
 
 # skip the test if the hardware doesn't support branch stack sampling
 # and if the architecture doesn't support filter types: any,save_type,u
-perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2
+if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then
+	echo "skip: system doesn't support filter types: any,save_type,u"
+	exit 2
+fi
 
 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
 
tools/perf/util/parse-branch-options.c +3 -1
index 00588b9db474..31faf2bb49ff 100644
@@ -102,8 +102,10 @@ parse_branch_stack(const struct option *opt, const char *str, int unset)
 	/*
 	 * cannot set it twice, -b + --branch-filter for instance
 	 */
-	if (*mode)
+	if (*mode) {
+		pr_err("Error: Can't use --branch-any (-b) with --branch-filter (-j).\n");
 		return -1;
+	}
 
 	return parse_branch_str(str, mode);
 }
Tested-by
#2 lore raw
Quoted 19 lines · James Clark
Quoted 11 lines · James Clark

Commit f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter") added a skip if certain branch options aren't available. But the change added both -b (--branch-any) and --branch-filter options at the same time, which will always result in a failure on any platform because the arguments can't be used together.

Fix this by removing -b (--branch-any) and leaving --branch-filter which already specifies 'any'. Also add warning messages to the test and perf tool.

Quoted 5 lines

Hi Athira,

Are you able to check if this still skips for you on PowerPC with this new change?

Hi James,

Sorry for the late response. I was out on vacation couple of days.

I tested with the new change and verified it skips on powerpc.

Thanks
Athira

Quoted 52 lines

Thanks
James

Quoted 49 lines

Output on x86 before this fix:

  $ sudo ./perf test branch
  108: Check branch stack sampling         : Skip

After:

  $ sudo ./perf test branch
  108: Check branch stack sampling         : Ok
Fixes f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter")

---
tools/perf/tests/shell/test_brstack.sh | 5 ++++-
tools/perf/util/parse-branch-options.c | 4 +++-

2 files changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_brstack.sh +4 -1
index ec801cffae6b..d7ff5c4b4da4 100755
@@ -13,7 +13,10 @@ fi
 
 # skip the test if the hardware doesn't support branch stack sampling
 # and if the architecture doesn't support filter types: any,save_type,u
-perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2
+if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then
+	echo "skip: system doesn't support filter types: any,save_type,u"
+	exit 2
+fi
 
 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
 
tools/perf/util/parse-branch-options.c +3 -1
index 00588b9db474..31faf2bb49ff 100644
@@ -102,8 +102,10 @@ parse_branch_stack(const struct option *opt, const char *str, int unset)
 	/*
 	 * cannot set it twice, -b + --branch-filter for instance
 	 */
-	if (*mode)
+	if (*mode) {
+		pr_err("Error: Can't use --branch-any (-b) with --branch-filter (-j).\n");
 		return -1;
+	}
 
 	return parse_branch_str(str, mode);
 }
maintainer Applied
#3 lore raw

Em Wed, Nov 02, 2022 at 12:21:11PM +0530, Athira Rajeev escreveu:

Quoted 25 lines
Quoted 19 lines · James Clark
Quoted 11 lines · James Clark

Commit f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter") added a skip if certain branch options aren't available. But the change added both -b (--branch-any) and --branch-filter options at the same time, which will always result in a failure on any platform because the arguments can't be used together.

Fix this by removing -b (--branch-any) and leaving --branch-filter which already specifies 'any'. Also add warning messages to the test and perf tool.

Quoted 5 lines

Hi Athira,

Are you able to check if this still skips for you on PowerPC with this new change?

Quoted 7 lines

Hi James,

Sorry for the late response. I was out on vacation couple of days.

I tested with the new change and verified it skips on powerpc.

Thanks, applied.

- Arnaldo

Quoted 54 lines

Thanks
Athira

Quoted 52 lines

Thanks
James

Quoted 49 lines

Output on x86 before this fix:

  $ sudo ./perf test branch
  108: Check branch stack sampling         : Skip

After:

  $ sudo ./perf test branch
  108: Check branch stack sampling         : Ok
Fixes f4a2aade6809 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter")

---
tools/perf/tests/shell/test_brstack.sh | 5 ++++-
tools/perf/util/parse-branch-options.c | 4 +++-

2 files changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_brstack.sh +4 -1
index ec801cffae6b..d7ff5c4b4da4 100755
@@ -13,7 +13,10 @@ fi
 
 # skip the test if the hardware doesn't support branch stack sampling
 # and if the architecture doesn't support filter types: any,save_type,u
-perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2
+if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then
+	echo "skip: system doesn't support filter types: any,save_type,u"
+	exit 2
+fi
 
 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
 
tools/perf/util/parse-branch-options.c +3 -1
index 00588b9db474..31faf2bb49ff 100644
@@ -102,8 +102,10 @@ parse_branch_stack(const struct option *opt, const char *str, int unset)
 	/*
 	 * cannot set it twice, -b + --branch-filter for instance
 	 */
-	if (*mode)
+	if (*mode) {
+		pr_err("Error: Can't use --branch-any (-b) with --branch-filter (-j).\n");
 		return -1;
+	}
 
 	return parse_branch_str(str, mode);
 }
Signature · 1 line
- Arnaldo