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

perf test: Skip wp modify test on old kernels

It uses PERF_EVENT_IOC_MODIFY_ATTRIBUTES ioctl. The kernel would return
ENOTTY if it's not supported. Update the skip reason in that case.

Committer notes:

On s/390 the args aren't used, so need to be marked __maybe_unused.

Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20220914183338.546357-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
e1dda48e babd0438

+8 -2
+8 -2
tools/perf/tests/wp.c
··· 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 4 #include <unistd.h> 5 + #include <errno.h> 5 6 #include <sys/ioctl.h> 7 + #include <linux/compiler.h> 6 8 #include <linux/hw_breakpoint.h> 7 9 #include <linux/kernel.h> 8 10 #include "tests.h" ··· 139 137 #endif 140 138 } 141 139 142 - static int test__wp_modify(struct test_suite *test __maybe_unused, 143 - int subtest __maybe_unused) 140 + static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 144 141 { 145 142 #if defined(__s390x__) 146 143 return TEST_SKIP; ··· 161 160 new_attr.disabled = 1; 162 161 ret = ioctl(fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr); 163 162 if (ret < 0) { 163 + if (errno == ENOTTY) { 164 + test->test_cases[subtest].skip_reason = "missing kernel support"; 165 + ret = TEST_SKIP; 166 + } 167 + 164 168 pr_debug("ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) failed\n"); 165 169 close(fd); 166 170 return ret;