Skip to contentSkip to conversation

perf test: Implement skip_reason callback for watchpoint tests

PATCH Applied Tommi Rantala 3 participants 3 messages Oct 16, 2020 – Oct 20, 2020 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Implement skip_reason callback for watchpoint tests

Currently reason for skipping the read only watchpoint test is only seen when running in verbose mode:

  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok
  $ perf test -v watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                :
  --- start ---
  test child forked, pid 60204
  Hardware does not support read only watchpoints.
  test child finished with -2

Implement skip_reason callback for the watchpoint tests, so that it's easy to see reason why the test is skipped:

  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip (missing hardware support)
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok
---
 tools/perf/tests/builtin-test.c |  1 +
 tools/perf/tests/tests.h        |  1 +
 tools/perf/tests/wp.c           | 21 +++++++++++++++------
 3 files changed, 17 insertions(+), 6 deletions(-)
tools/perf/tests/builtin-test.c +1 -0
index d328caaba45d..3bfad4ee31ae 100644
@@ -142,6 +142,7 @@ static struct test generic_tests[] = {
 			.skip_if_fail	= false,
 			.get_nr		= test__wp_subtest_get_nr,
 			.get_desc	= test__wp_subtest_get_desc,
+			.skip_reason    = test__wp_subtest_skip_reason,
 		},
 	},
 	{
tools/perf/tests/tests.h +1 -0
index 4447a516c689..0630301087a6 100644
@@ -66,6 +66,7 @@ int test__bp_signal_overflow(struct test *test, int subtest);
 int test__bp_accounting(struct test *test, int subtest);
 int test__wp(struct test *test, int subtest);
 const char *test__wp_subtest_get_desc(int subtest);
+const char *test__wp_subtest_skip_reason(int subtest);
 int test__wp_subtest_get_nr(void);
 int test__task_exit(struct test *test, int subtest);
 int test__mem(struct test *test, int subtest);
tools/perf/tests/wp.c +15 -6
index d262d6639829..9387fa76faa5 100644
@@ -174,10 +174,12 @@ static bool wp_ro_supported(void)
 #endif
 }
 
-static void wp_ro_skip_msg(void)
+static const char *wp_ro_skip_msg(void)
 {
 #if defined (__x86_64__) || defined (__i386__)
-	pr_debug("Hardware does not support read only watchpoints.\n");
+	return "missing hardware support";
+#else
+	return NULL;
 #endif
 }
 
@@ -185,7 +187,7 @@ static struct {
 	const char *desc;
 	int (*target_func)(void);
 	bool (*is_supported)(void);
-	void (*skip_msg)(void);
+	const char *(*skip_msg)(void);
 } wp_testcase_table[] = {
 	{
 		.desc = "Read Only Watchpoint",
@@ -219,16 +221,23 @@ const char *test__wp_subtest_get_desc(int i)
 	return wp_testcase_table[i].desc;
 }
 
+const char *test__wp_subtest_skip_reason(int i)
+{
+	if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
+		return NULL;
+	if (!wp_testcase_table[i].skip_msg)
+		return NULL;
+	return wp_testcase_table[i].skip_msg();
+}
+
 int test__wp(struct test *test __maybe_unused, int i)
 {
 	if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
 		return TEST_FAIL;
 
 	if (wp_testcase_table[i].is_supported &&
-	    !wp_testcase_table[i].is_supported()) {
-		wp_testcase_table[i].skip_msg();
+	    !wp_testcase_table[i].is_supported())
 		return TEST_SKIP;
-	}
 
 	return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
 }
Signature · 1 line
2.26.2
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 22 lines · Tommi Rantala

Currently reason for skipping the read only watchpoint test is only seen when running in verbose mode:

  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok
  $ perf test -v watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                :
  --- start ---
  test child forked, pid 60204
  Hardware does not support read only watchpoints.
  test child finished with -2

Implement skip_reason callback for the watchpoint tests, so that it's easy to see reason why the test is skipped:

Quoted 8 lines
  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip (missing hardware support)
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok

Thanks
Namhyung

Quoted 88 lines
---
 tools/perf/tests/builtin-test.c |  1 +
 tools/perf/tests/tests.h        |  1 +
 tools/perf/tests/wp.c           | 21 +++++++++++++++------
 3 files changed, 17 insertions(+), 6 deletions(-)
tools/perf/tests/builtin-test.c +1 -0
index d328caaba45d..3bfad4ee31ae 100644
@@ -142,6 +142,7 @@ static struct test generic_tests[] = {
                        .skip_if_fail   = false,
                        .get_nr         = test__wp_subtest_get_nr,
                        .get_desc       = test__wp_subtest_get_desc,
+                       .skip_reason    = test__wp_subtest_skip_reason,
                },
        },
        {
tools/perf/tests/tests.h +1 -0
index 4447a516c689..0630301087a6 100644
@@ -66,6 +66,7 @@ int test__bp_signal_overflow(struct test *test, int subtest);
 int test__bp_accounting(struct test *test, int subtest);
 int test__wp(struct test *test, int subtest);
 const char *test__wp_subtest_get_desc(int subtest);
+const char *test__wp_subtest_skip_reason(int subtest);
 int test__wp_subtest_get_nr(void);
 int test__task_exit(struct test *test, int subtest);
 int test__mem(struct test *test, int subtest);
tools/perf/tests/wp.c +15 -7
index d262d6639829..9387fa76faa5 100644
@@ -174,10 +174,12 @@ static bool wp_ro_supported(void)
 #endif
 }
 
-static void wp_ro_skip_msg(void)
+static const char *wp_ro_skip_msg(void)
 {
 #if defined (__x86_64__) || defined (__i386__)
-       pr_debug("Hardware does not support read only watchpoints.\n");
+       return "missing hardware support";
+#else
+       return NULL;
 #endif
 }
 
@@ -185,7 +187,7 @@ static struct {
        const char *desc;
        int (*target_func)(void);
        bool (*is_supported)(void);
-       void (*skip_msg)(void);
+       const char *(*skip_msg)(void);
 } wp_testcase_table[] = {
        {
                .desc = "Read Only Watchpoint",
@@ -219,16 +221,23 @@ const char *test__wp_subtest_get_desc(int i)
        return wp_testcase_table[i].desc;
 }
 
+const char *test__wp_subtest_skip_reason(int i)
+{
+       if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
+               return NULL;
+       if (!wp_testcase_table[i].skip_msg)
+               return NULL;
+       return wp_testcase_table[i].skip_msg();
+}
+
 int test__wp(struct test *test __maybe_unused, int i)
 {
        if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
                return TEST_FAIL;
 
        if (wp_testcase_table[i].is_supported &&
-           !wp_testcase_table[i].is_supported()) {
-               wp_testcase_table[i].skip_msg();
+           !wp_testcase_table[i].is_supported())
                return TEST_SKIP;
-       }
 
        return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
 }
--

2.26.2

maintainer Applied
#2 lore raw

Em Tue, Oct 20, 2020 at 03:07:15PM +0900, Namhyung Kim escreveu:

Quoted 32 lines

Hello,

Quoted 29 lines · Tommi Rantala

Currently reason for skipping the read only watchpoint test is only seen when running in verbose mode:

  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok
  $ perf test -v watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                :
  --- start ---
  test child forked, pid 60204
  Hardware does not support read only watchpoints.
  test child finished with -2

Implement skip_reason callback for the watchpoint tests, so that it's easy to see reason why the test is skipped:

  $ perf test watchpoint
  23: Watchpoint                                            :
  23.1: Read Only Watchpoint                                : Skip (missing hardware support)
  23.2: Write Only Watchpoint                               : Ok
  23.3: Read / Write Watchpoint                             : Ok
  23.4: Modify Watchpoint                                   : Ok
Quoted 3 lines
Quoted 1 line

Thanks, applied.

- Arnaldo

Quoted 93 lines

Thanks
Namhyung

Quoted 88 lines
---
 tools/perf/tests/builtin-test.c |  1 +
 tools/perf/tests/tests.h        |  1 +
 tools/perf/tests/wp.c           | 21 +++++++++++++++------
 3 files changed, 17 insertions(+), 6 deletions(-)
tools/perf/tests/builtin-test.c +1 -0
index d328caaba45d..3bfad4ee31ae 100644
@@ -142,6 +142,7 @@ static struct test generic_tests[] = {
                        .skip_if_fail   = false,
                        .get_nr         = test__wp_subtest_get_nr,
                        .get_desc       = test__wp_subtest_get_desc,
+                       .skip_reason    = test__wp_subtest_skip_reason,
                },
        },
        {
tools/perf/tests/tests.h +1 -0
index 4447a516c689..0630301087a6 100644
@@ -66,6 +66,7 @@ int test__bp_signal_overflow(struct test *test, int subtest);
 int test__bp_accounting(struct test *test, int subtest);
 int test__wp(struct test *test, int subtest);
 const char *test__wp_subtest_get_desc(int subtest);
+const char *test__wp_subtest_skip_reason(int subtest);
 int test__wp_subtest_get_nr(void);
 int test__task_exit(struct test *test, int subtest);
 int test__mem(struct test *test, int subtest);
tools/perf/tests/wp.c +15 -7
index d262d6639829..9387fa76faa5 100644
@@ -174,10 +174,12 @@ static bool wp_ro_supported(void)
 #endif
 }
 
-static void wp_ro_skip_msg(void)
+static const char *wp_ro_skip_msg(void)
 {
 #if defined (__x86_64__) || defined (__i386__)
-       pr_debug("Hardware does not support read only watchpoints.\n");
+       return "missing hardware support";
+#else
+       return NULL;
 #endif
 }
 
@@ -185,7 +187,7 @@ static struct {
        const char *desc;
        int (*target_func)(void);
        bool (*is_supported)(void);
-       void (*skip_msg)(void);
+       const char *(*skip_msg)(void);
 } wp_testcase_table[] = {
        {
                .desc = "Read Only Watchpoint",
@@ -219,16 +221,23 @@ const char *test__wp_subtest_get_desc(int i)
        return wp_testcase_table[i].desc;
 }
 
+const char *test__wp_subtest_skip_reason(int i)
+{
+       if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
+               return NULL;
+       if (!wp_testcase_table[i].skip_msg)
+               return NULL;
+       return wp_testcase_table[i].skip_msg();
+}
+
 int test__wp(struct test *test __maybe_unused, int i)
 {
        if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
                return TEST_FAIL;
 
        if (wp_testcase_table[i].is_supported &&
-           !wp_testcase_table[i].is_supported()) {
-               wp_testcase_table[i].skip_msg();
+           !wp_testcase_table[i].is_supported())
                return TEST_SKIP;
-       }
 
        return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
 }
--

2.26.2

Signature · 1 line
- Arnaldo