Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Fix skipping branch stack sampling test

Commit f4a2aade6809c657 ("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: f4a2aade6809c657 ("perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter")
Signed-off-by: James Clark <james.clark@arm.com>
Tested-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman.Khandual@arm.com
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20221028121913.745307-1-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
20ebc4a6 ad353b71

+7 -2
+4 -1
tools/perf/tests/shell/test_brstack.sh
··· 13 13 14 14 # skip the test if the hardware doesn't support branch stack sampling 15 15 # and if the architecture doesn't support filter types: any,save_type,u 16 - perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2 16 + if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then 17 + echo "skip: system doesn't support filter types: any,save_type,u" 18 + exit 2 19 + fi 17 20 18 21 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX) 19 22
+3 -1
tools/perf/util/parse-branch-options.c
··· 102 102 /* 103 103 * cannot set it twice, -b + --branch-filter for instance 104 104 */ 105 - if (*mode) 105 + if (*mode) { 106 + pr_err("Error: Can't use --branch-any (-b) with --branch-filter (-j).\n"); 106 107 return -1; 108 + } 107 109 108 110 return parse_branch_str(str, mode); 109 111 }