Commit 7d54a4ac authored by Naveen N. Rao's avatar Naveen N. Rao Committed by Arnaldo Carvalho de Melo

perf test: Skip watchpoint tests if no watchpoints available

On IBM Power9, perf watchpoint tests fail since no hardware breakpoints
are available. Detect this by checking the error returned by
perf_event_open() and skip the tests in that case.
Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: Kajol Jain<kjain@linux.ibm.com>
Tested-by: Kajol Jain<kjain@linux.ibm.com>
Link: https://lore.kernel.org/r/20221121102747.208289-1-naveen.n.rao@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
parent 8daf87f5
...@@ -59,8 +59,10 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len) ...@@ -59,8 +59,10 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
get__perf_event_attr(&attr, wp_type, wp_addr, wp_len); get__perf_event_attr(&attr, wp_type, wp_addr, wp_len);
fd = sys_perf_event_open(&attr, 0, -1, -1, fd = sys_perf_event_open(&attr, 0, -1, -1,
perf_event_open_cloexec_flag()); perf_event_open_cloexec_flag());
if (fd < 0) if (fd < 0) {
fd = -errno;
pr_debug("failed opening event %x\n", attr.bp_type); pr_debug("failed opening event %x\n", attr.bp_type);
}
return fd; return fd;
} }
...@@ -77,7 +79,7 @@ static int test__wp_ro(struct test_suite *test __maybe_unused, ...@@ -77,7 +79,7 @@ static int test__wp_ro(struct test_suite *test __maybe_unused,
fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1)); fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1));
if (fd < 0) if (fd < 0)
return -1; return fd == -ENODEV ? TEST_SKIP : -1;
tmp = data1; tmp = data1;
WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1); WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
...@@ -101,7 +103,7 @@ static int test__wp_wo(struct test_suite *test __maybe_unused, ...@@ -101,7 +103,7 @@ static int test__wp_wo(struct test_suite *test __maybe_unused,
fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1)); fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
if (fd < 0) if (fd < 0)
return -1; return fd == -ENODEV ? TEST_SKIP : -1;
tmp = data1; tmp = data1;
WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0); WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0);
...@@ -126,7 +128,7 @@ static int test__wp_rw(struct test_suite *test __maybe_unused, ...@@ -126,7 +128,7 @@ static int test__wp_rw(struct test_suite *test __maybe_unused,
fd = __event(HW_BREAKPOINT_R | HW_BREAKPOINT_W, (void *)&data1, fd = __event(HW_BREAKPOINT_R | HW_BREAKPOINT_W, (void *)&data1,
sizeof(data1)); sizeof(data1));
if (fd < 0) if (fd < 0)
return -1; return fd == -ENODEV ? TEST_SKIP : -1;
tmp = data1; tmp = data1;
WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1); WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1);
...@@ -150,7 +152,7 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _ ...@@ -150,7 +152,7 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _
fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1)); fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
if (fd < 0) if (fd < 0)
return -1; return fd == -ENODEV ? TEST_SKIP : -1;
data1 = tmp; data1 = tmp;
WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1); WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment