Skip to contentSkip to conversation

perf tests: Add arch tests

PATCH In review Matt Fleming 4 participants 15 messages Sep 5, 2015 – Sep 15, 2015 perf events

lore
Share & tools
lore
#0 lore raw

cover perf tests: Add arch tests

From: Matt Fleming <[email protected]>

To encourage developers to contribute arch-specific tests without feeling guilty about messing up the generic perf tests, this patch series introduces "arch tests" and then adds a test for the Intel CQM perf code which was used to trigger a WARN_ON_ONCE(), fixed in commit 2c534c0da0a6 ("perf/x86/intel/cqm: Return cached counter value from IRQ context").

The concept of additional lists of tests, like the arch tests, can be taken further in the future, for instance Arnaldo has expressed interest in adding tests that require root permissions, etc.

The patch series is based on tip/perf/core.

The original patch that inspired this series can be found here,

https://lkml.kernel.org/r/[email protected]

Matt Fleming (3):
perf tests: Introduce iterator function for tests perf tests: Add arch tests
perf tests: Add Intel CQM test

 tools/perf/arch/x86/Build                    |   2 +-
 tools/perf/arch/x86/include/arch-tests.h     |  18 +++
 tools/perf/arch/x86/tests/Build              |   9 +-
 tools/perf/arch/x86/tests/arch-tests.c       |  28 +++++
 tools/perf/arch/x86/tests/dwarf-unwind.c     |   1 +
 tools/perf/arch/x86/tests/intel-cqm.c        | 124 +++++++++++++++++++
 tools/perf/arch/x86/tests/perf-time-to-tsc.c | 163 ++++++++++++++++++++++++
 tools/perf/arch/x86/tests/rdpmc.c            | 174 ++++++++++++++++++++++++++
 tools/perf/tests/Build                       |   3 -
 tools/perf/tests/builtin-test.c              |  76 ++++++------
 tools/perf/tests/dwarf-unwind.c              |   4 +
 tools/perf/tests/perf-time-to-tsc.c          | 162 ------------------------
 tools/perf/tests/rdpmc.c                     | 177 ---------------------------
 tools/perf/tests/tests.h                     |   9 +-
 14 files changed, 562 insertions(+), 388 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/arch-tests.h
 create mode 100644 tools/perf/arch/x86/tests/arch-tests.c
 create mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
 create mode 100644 tools/perf/arch/x86/tests/perf-time-to-tsc.c
 create mode 100644 tools/perf/arch/x86/tests/rdpmc.c
 delete mode 100644 tools/perf/tests/perf-time-to-tsc.c
 delete mode 100644 tools/perf/tests/rdpmc.c
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/3 perf tests: Introduce iterator function for tests

From: Matt Fleming <[email protected]>

In preparation for introducing more arrays of tests, e.g. "arch tests" (architecture-specific tests), abstract the code to iterate over the list of tests into a helper function.

This way, code that uses a 'struct test' doesn't need to worry about how the tests are grouped together and changes to the list of tests doesn't require changes to the code using it.

Cc Peter Zijlstra <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/tests/builtin-test.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
tools/perf/tests/builtin-test.c +16 -16
index 136cd934be66..8cf0601d1662 100644
@@ -183,7 +183,7 @@ static struct test {
 	},
 };
 
-static bool perf_test__matches(int curr, int argc, const char *argv[])
+static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;
 
@@ -200,7 +200,7 @@ static bool perf_test__matches(int curr, int argc, const char *argv[])
 			continue;
 		}
 
-		if (strstr(tests[curr].desc, argv[i]))
+		if (strstr(test->desc, argv[i]))
 			return true;
 	}
 
@@ -237,27 +237,28 @@ static int run_test(struct test *test)
 	return err;
 }
 
+#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
+	struct test *t;
 	int i = 0;
 	int width = 0;
 
-	while (tests[i].func) {
-		int len = strlen(tests[i].desc);
+	for_each_test(t) {
+		int len = strlen(t->desc);
 
 		if (width < len)
 			width = len;
-		++i;
 	}
 
-	i = 0;
-	while (tests[i].func) {
+	for_each_test(t) {
 		int curr = i++, err;
 
-		if (!perf_test__matches(curr, argc, argv))
+		if (!perf_test__matches(t, curr, argc, argv))
 			continue;
 
-		pr_info("%2d: %-*s:", i, width, tests[curr].desc);
+		pr_info("%2d: %-*s:", i, width, t->desc);
 
 		if (intlist__find(skiplist, i)) {
 			color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
@@ -265,8 +266,8 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 		}
 
 		pr_debug("\n--- start ---\n");
-		err = run_test(&tests[curr]);
-		pr_debug("---- end ----\n%s:", tests[curr].desc);
+		err = run_test(t);
+		pr_debug("---- end ----\n%s:", t->desc);
 
 		switch (err) {
 		case TEST_OK:
@@ -287,15 +288,14 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 
 static int perf_test__list(int argc, const char **argv)
 {
+	struct test *t;
 	int i = 0;
 
-	while (tests[i].func) {
-		int curr = i++;
-
-		if (argc > 1 && !strstr(tests[curr].desc, argv[1]))
+	for_each_test(t) {
+		if (argc > 1 && !strstr(t->desc, argv[1]))
 			continue;
 
-		pr_info("%2d: %s\n", i, tests[curr].desc);
+		pr_info("%2d: %s\n", ++i, t->desc);
 	}
 
 	return 0;
Signature · 1 line
2.1.0
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] perf tests: Introduce iterator function for tests

Quoted 6 lines · Matt Fleming

From: Matt Fleming <[email protected]>

In preparation for introducing more arrays of tests, e.g. "arch tests" (architecture-specific tests), abstract the code to iterate over the list of tests into a helper function.

Quoted 8 lines

This way, code that uses a 'struct test' doesn't need to worry about how the tests are grouped together and changes to the list of tests doesn't require changes to the code using it.

Cc Peter Zijlstra <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

thanks,
jirka

#3 lore raw

[tip:perf/core] perf tests: Introduce iterator function for tests

In reply to Matt Fleming
perf tests: Introduce iterator function for tests
Commit-ID:  e8210cefb7e1ec0760a6fe581ad0727a2dcf8dd1
Gitweb:     http://git.kernel.org/tip/e8210cefb7e1ec0760a6fe581ad0727a2dcf8dd1
Author:     Matt Fleming <[email protected]>
AuthorDate: Sat, 5 Sep 2015 20:02:20 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:18 -0300

perf tests: Introduce iterator function for tests

In preparation for introducing more arrays of tests, e.g. "arch tests" (architecture-specific tests), abstract the code to iterate over the list of tests into a helper function.

This way, code that uses a 'struct test' doesn't need to worry about how the tests are grouped together and changes to the list of tests doesn't require changes to the code using it.

---
 tools/perf/tests/builtin-test.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
tools/perf/tests/builtin-test.c +16 -16
index 98b0b24..d9bf51d 100644
@@ -195,7 +195,7 @@ static struct test {
 	},
 };
 
-static bool perf_test__matches(int curr, int argc, const char *argv[])
+static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;
 
@@ -212,7 +212,7 @@ static bool perf_test__matches(int curr, int argc, const char *argv[])
 			continue;
 		}
 
-		if (strstr(tests[curr].desc, argv[i]))
+		if (strstr(test->desc, argv[i]))
 			return true;
 	}
 
@@ -249,27 +249,28 @@ static int run_test(struct test *test)
 	return err;
 }
 
+#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
+	struct test *t;
 	int i = 0;
 	int width = 0;
 
-	while (tests[i].func) {
-		int len = strlen(tests[i].desc);
+	for_each_test(t) {
+		int len = strlen(t->desc);
 
 		if (width < len)
 			width = len;
-		++i;
 	}
 
-	i = 0;
-	while (tests[i].func) {
+	for_each_test(t) {
 		int curr = i++, err;
 
-		if (!perf_test__matches(curr, argc, argv))
+		if (!perf_test__matches(t, curr, argc, argv))
 			continue;
 
-		pr_info("%2d: %-*s:", i, width, tests[curr].desc);
+		pr_info("%2d: %-*s:", i, width, t->desc);
 
 		if (intlist__find(skiplist, i)) {
 			color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
@@ -277,8 +278,8 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 		}
 
 		pr_debug("\n--- start ---\n");
-		err = run_test(&tests[curr]);
-		pr_debug("---- end ----\n%s:", tests[curr].desc);
+		err = run_test(t);
+		pr_debug("---- end ----\n%s:", t->desc);
 
 		switch (err) {
 		case TEST_OK:
@@ -299,15 +300,14 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 
 static int perf_test__list(int argc, const char **argv)
 {
+	struct test *t;
 	int i = 0;
 
-	while (tests[i].func) {
-		int curr = i++;
-
-		if (argc > 1 && !strstr(tests[curr].desc, argv[1]))
+	for_each_test(t) {
+		if (argc > 1 && !strstr(t->desc, argv[1]))
 			continue;
 
-		pr_info("%2d: %s\n", i, tests[curr].desc);
+		pr_info("%2d: %s\n", ++i, t->desc);
 	}
 
 	return 0;
#4 lore raw

PATCH 2/3 perf tests: Add arch tests

In reply to Matt Fleming

From: Matt Fleming <[email protected]>

Tests that only make sense for some architectures currently live in the same place as the generic tests. Move out the x86-specific tests into tools/perf/arch/x86/tests and define an 'arch_tests' array, which is the list of tests that only apply to the build architecture.

The main idea is to encourage developers to add arch tests to build out perf's test coverage, without dumping everything in tools/perf/tests.

We can also now begin to get rid of some of the #ifdef code that is present in the generic perf tests.

Cc Peter Zijlstra <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/arch/x86/Build                    |   2 +-
 tools/perf/arch/x86/include/arch-tests.h     |  18 +++
 tools/perf/arch/x86/tests/Build              |   8 +-
 tools/perf/arch/x86/tests/arch-tests.c       |  24 ++++
 tools/perf/arch/x86/tests/dwarf-unwind.c     |   1 +
 tools/perf/arch/x86/tests/perf-time-to-tsc.c | 163 ++++++++++++++++++++++++
 tools/perf/arch/x86/tests/rdpmc.c            | 174 ++++++++++++++++++++++++++
 tools/perf/tests/Build                       |   3 -
 tools/perf/tests/builtin-test.c              |  46 ++++---
 tools/perf/tests/dwarf-unwind.c              |   4 +
 tools/perf/tests/perf-time-to-tsc.c          | 162 ------------------------
 tools/perf/tests/rdpmc.c                     | 177 ---------------------------
 tools/perf/tests/tests.h                     |   9 +-
 13 files changed, 418 insertions(+), 373 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/arch-tests.h
 create mode 100644 tools/perf/arch/x86/tests/arch-tests.c
 create mode 100644 tools/perf/arch/x86/tests/perf-time-to-tsc.c
 create mode 100644 tools/perf/arch/x86/tests/rdpmc.c
 delete mode 100644 tools/perf/tests/perf-time-to-tsc.c
 delete mode 100644 tools/perf/tests/rdpmc.c
tools/perf/arch/x86/Build +1 -1
index 41bf61da476a..db52fa22d3a1 100644
@@ -1,2 +1,2 @@
 libperf-y += util/
-libperf-$(CONFIG_DWARF_UNWIND) += tests/
+libperf-y += tests/
tools/perf/arch/x86/include/arch-tests.h new file +18 -0
new file mode 100644
index 000000000000..9e505c5f6947
@@ -0,0 +1,18 @@
+#ifndef ARCH_TESTS_H
+#define ARCH_TESTS_H
+
+/* Tests */
+int test__rdpmc(void);
+int test__perf_time_to_tsc(void);
+int test__intel_cqm_count_nmi_context(void);
+
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+struct thread;
+struct perf_sample;
+int test__arch_unwind_sample(struct perf_sample *sample,
+			     struct thread *thread);
+#endif
+
+extern struct test arch_tests[];
+
+#endif
tools/perf/arch/x86/tests/Build +6 -2
index b30eff9bcc83..1381525dae06 100644
@@ -1,2 +1,6 @@
-libperf-y += regs_load.o
-libperf-y += dwarf-unwind.o
+libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
+libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
+
+libperf-y += arch-tests.o
+libperf-y += rdpmc.o
+libperf-y += perf-time-to-tsc.o
tools/perf/arch/x86/tests/arch-tests.c new file +24 -0
new file mode 100644
index 000000000000..0004fe48dc7e
@@ -0,0 +1,24 @@
+#include <string.h>
+#include "tests/tests.h"
+#include "arch-tests.h"
+
+struct test arch_tests[] = {
+	{
+		.desc = "x86 rdpmc test",
+		.func = test__rdpmc,
+	},
+	{
+		.desc = "Test converting perf time to TSC",
+		.func = test__perf_time_to_tsc,
+	},
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+	{
+		.desc = "Test dwarf unwind",
+		.func = test__dwarf_unwind,
+	},
+#endif
+	{
+		.func = NULL,
+	},
+
+};
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index d8bbf7ad1681..7f209ce827bf 100644
@@ -5,6 +5,7 @@
 #include "event.h"
 #include "debug.h"
 #include "tests/tests.h"
+#include "arch-tests.h"
 
 #define STACK_SIZE 8192
 
tools/perf/arch/x86/tests/perf-time-to-tsc.c new file +163 -0

163 lines not on this page · raw message

tools/perf/arch/x86/tests/rdpmc.c new file +174 -0

174 lines not on this page · raw message

tools/perf/tests/Build +0 -3
index c1518bdd0f1b..fa41e4f265fe 100644
@@ -8,7 +8,6 @@ perf-y += openat-syscall-all-cpus.o
 perf-y += openat-syscall-tp-fields.o
 perf-y += mmap-basic.o
 perf-y += perf-record.o
-perf-y += rdpmc.o
 perf-y += evsel-roundtrip-name.o
 perf-y += evsel-tp-sched.o
 perf-y += fdarray.o
@@ -34,8 +33,6 @@ perf-y += kmod-path.o
 perf-y += thread-map.o
 perf-y += llvm.o
 
-perf-$(CONFIG_X86) += perf-time-to-tsc.o
-
 ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64))
 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 endif
tools/perf/tests/builtin-test.c +21 -25

82 lines not on this page · raw message

tools/perf/tests/dwarf-unwind.c +4 -0
index 40b36c462427..07221793a3ac 100644
@@ -11,6 +11,10 @@
 #include "thread.h"
 #include "callchain.h"
 
+#if defined (__x86_64__) || defined (__i386__)
+#include "arch-tests.h"
+#endif
+
 /* For bsearch. We try to unwind functions in shared object. */
 #include <stdlib.h>
 
tools/perf/tests/perf-time-to-tsc.c deleted +0 -162

162 lines not on this page · raw message

tools/perf/tests/rdpmc.c deleted +0 -177

177 lines not on this page · raw message

tools/perf/tests/tests.h +6 -3
index bf113a247987..cad677d202bb 100644
@@ -24,13 +24,17 @@ enum {
 	TEST_SKIP = -2,
 };
 
+struct test {
+	const char *desc;
+	int (*func)(void);
+};
+
 /* Tests */
 int test__vmlinux_matches_kallsyms(void);
 int test__openat_syscall_event(void);
 int test__openat_syscall_event_on_all_cpus(void);
 int test__basic_mmap(void);
 int test__PERF_RECORD(void);
-int test__rdpmc(void);
 int test__perf_evsel__roundtrip_name_test(void);
 int test__perf_evsel__tp_sched_test(void);
 int test__syscall_openat_tp_fields(void);
@@ -46,7 +50,6 @@ int test__bp_signal(void);
 int test__bp_signal_overflow(void);
 int test__task_exit(void);
 int test__sw_clock_freq(void);
-int test__perf_time_to_tsc(void);
 int test__code_reading(void);
 int test__sample_parsing(void);
 int test__keep_tracking(void);
@@ -64,7 +67,7 @@ int test__kmod_path__parse(void);
 int test__thread_map(void);
 int test__llvm(void);
 
-#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
 struct perf_sample;
Signature · 1 line
2.1.0
#5 lore raw

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 11 lines
tools/perf/tests/builtin-test.c +0 -3
index 8cf0601d1662..a1b2265eaf55 100644
@@ -14,10 +14,17 @@
 #include "parse-options.h"
 #include "symbol.h"
 
-static struct test {
-	const char *desc;
-	int (*func)(void);

tools/perf/tests/builtin-test.c line 25

Quoted 10 lines
tools/perf/tests/builtin-test.c +9 -1
-} tests[] = {
+#if defined(__x86_64__) || defined(__i386__)
+#include "arch-tests.h"
+#else
+static struct test arch_tests[] = {
+	{
+		.func = NULL,
+	},
+};
+#endif

this could be defined as __weak array so we dont need to have #if above

jirka

#6 lore raw
Quoted 12 lines · Jiri Olsa

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 8 lines
tools/perf/tests/builtin-test.c +0 -0
index 8cf0601d1662..a1b2265eaf55 100644
@@ -14,10 +14,17 @@
 #include "parse-options.h"
 #include "symbol.h"
 
Quoted 15 lines

tools/perf/tests/builtin-test.c line 25

Quoted 13 lines
tools/perf/tests/builtin-test.c +9 -4
-static struct test {
-	const char *desc;
-	int (*func)(void);
-} tests[] = {
+#if defined(__x86_64__) || defined(__i386__)
+#include "arch-tests.h"
+#else
+static struct test arch_tests[] = {
+	{
+		.func = NULL,
+	},
+};
+#endif

this could be defined as __weak array so we dont need to have #if above

Yeah, good idea. I'll make that change.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#7 lore raw
In reply to Matt Fleming

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 11 lines

};

tools/perf/tests/builtin-test.c +5 -0
+static struct test *tests[] = {
+	generic_tests,
+	arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;

tools/perf/tests/builtin-test.c static int run_test(struct test *test) · line 236

Quoted 9 lines
tools/perf/tests/builtin-test.c +5 -1
@@ -237,7 +229,11 @@ static int run_test(struct test *test)
 	return err;
 }
 
-#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+static unsigned int ___j;		/* This is obviously not thread-safe */
+
+#define for_each_test(t)	 				\
+	for (___j = 0; ___j < ARRAY_SIZE(tests); ___j++)	\
+		for (t = &tests[___j][0]; t->func; t++)

why not have ____j on stack and pas it into for_each_test

for_each_test(j, t)
...

jirka

#8 lore raw
Quoted 27 lines · Jiri Olsa

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 11 lines

};

tools/perf/tests/builtin-test.c +5 -0
+static struct test *tests[] = {
+	generic_tests,
+	arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;

tools/perf/tests/builtin-test.c static int run_test(struct test *test) · line 236

Quoted 9 lines
tools/perf/tests/builtin-test.c +5 -1
@@ -237,7 +229,11 @@ static int run_test(struct test *test)
 	return err;
 }
 
-#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+static unsigned int ___j;		/* This is obviously not thread-safe */
+
+#define for_each_test(t)	 				\
+	for (___j = 0; ___j < ARRAY_SIZE(tests); ___j++)	\
+		for (t = &tests[___j][0]; t->func; t++)

why not have ____j on stack and pas it into for_each_test

Quoted 2 lines

for_each_test(j, t)
...

Right, I made a conscious decision to not do that because I didn't want the caller to have to care about providing an iterator variable. It also makes the diff slightly bigger.

But I don't feel that strongly about it, so I'll make this change.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#9 lore raw
In reply to Matt Fleming

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 10 lines
tools/perf/tests/builtin-test.c +5 -0
+static struct test *tests[] = {
+	generic_tests,
+	arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;

tools/perf/tests/builtin-test.c static int run_test(struct test *test) · line 237

Quoted 10 lines
tools/perf/tests/builtin-test.c +5 -1
@@ -237,7 +229,11 @@ static int run_test(struct test *test)
 	return err;
 }
 
-#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+static unsigned int ___j;		/* This is obviously not thread-safe */
+
+#define for_each_test(t)	 				\
+	for (___j = 0; ___j < ARRAY_SIZE(tests); ___j++)	\
+		for (t = &tests[___j][0]; t->func; t++)
 

could you also split the change on adding support for arch_tests and another actually moving affected tests?

jirka

#10 lore raw
Quoted 17 lines · Jiri Olsa

On Sat, Sep 05, 2015 at 08:02:21PM +0100, Matt Fleming wrote:

SNIP

Quoted 13 lines
tools/perf/tests/builtin-test.c +5 -0
+static struct test *tests[] = {
+	generic_tests,
+	arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;
@@ -237,7 +229,11 @@ static int run_test(struct test *test)
 	return err;
 }
 
Quoted 10 lines

tools/perf/tests/builtin-test.c static int run_test(struct test *test) · line 237

Quoted 7 lines
tools/perf/tests/builtin-test.c +5 -1
-#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+static unsigned int ___j;		/* This is obviously not thread-safe */
+
+#define for_each_test(t)	 				\
+	for (___j = 0; ___j < ARRAY_SIZE(tests); ___j++)	\
+		for (t = &tests[___j][0]; t->func; t++)
 

could you also split the change on adding support for arch_tests and another actually moving affected tests?

Sure that makes sense.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#11 lore raw

PATCH 3/3 perf tests: Add Intel CQM test

In reply to Matt Fleming

From: Matt Fleming <[email protected]>

Peter reported that it's possible to trigger a WARN_ON_ONCE() in the Intel CQM code by combining a hardware event and an Intel CQM (software) event into a group, which was fixed in commit 2c534c0da0a6 ("perf/x86/intel/cqm: Return cached counter value from IRQ context"). Unfortunately, the perf tools were not able to create this bundle and we had to manually construct a test case.

For posterity, record Peter's proof of concept test case in tools/perf so that it presents a model for how we can perform architecture specific tests, or "arch tests", in perf in the future.

The particular issue triggered in the test case is that when the counter for the hardware event overflows and triggers a PMI we'll read both the hardware event and the software event counters. Unfortunately, for CQM that involves performing an IPI to read the CQM event counters on all sockets, which in NMI context triggers the WARN_ON_ONCE().

---
 tools/perf/arch/x86/tests/Build        |   1 +
 tools/perf/arch/x86/tests/arch-tests.c |   4 ++
 tools/perf/arch/x86/tests/intel-cqm.c  | 124 +++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+)
 create mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
tools/perf/arch/x86/tests/Build +1 -0
index 1381525dae06..32996f54e123 100644
@@ -4,3 +4,4 @@ libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 libperf-y += arch-tests.o
 libperf-y += rdpmc.o
 libperf-y += perf-time-to-tsc.o
+libperf-y += intel-cqm.o
tools/perf/arch/x86/tests/arch-tests.c +4 -0
index 0004fe48dc7e..3ab31adc283a 100644
@@ -18,6 +18,10 @@ struct test arch_tests[] = {
 	},
 #endif
 	{
+		.desc = "Test intel cqm nmi context read",
+		.func = test__intel_cqm_count_nmi_context,
+	},
+	{
 		.func = NULL,
 	},
 
tools/perf/arch/x86/tests/intel-cqm.c new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.1.0
#12 lore raw
In reply to Matt Fleming
Quoted 9 lines · Matt Fleming

From: Matt Fleming <[email protected]>

To encourage developers to contribute arch-specific tests without feeling guilty about messing up the generic perf tests, this patch series introduces "arch tests" and then adds a test for the Intel CQM perf code which was used to trigger a WARN_ON_ONCE(), fixed in commit 2c534c0da0a6 ("perf/x86/intel/cqm: Return cached counter value from IRQ context").

Quoted 5 lines

The concept of additional lists of tests, like the arch tests, can be taken further in the future, for instance Arnaldo has expressed interest in adding tests that require root permissions, etc.

The patch series is based on tip/perf/core.

please base this over Arnaldo's perf/core

jirka

#13 lore raw

Em Mon, Sep 07, 2015 at 02:58:18PM +0200, Jiri Olsa escreveu:

Quoted 10 lines · Matt Fleming
Quoted 9 lines

From: Matt Fleming <[email protected]>

To encourage developers to contribute arch-specific tests without feeling guilty about messing up the generic perf tests, this patch series introduces "arch tests" and then adds a test for the Intel CQM perf code which was used to trigger a WARN_ON_ONCE(), fixed in commit 2c534c0da0a6 ("perf/x86/intel/cqm: Return cached counter value from IRQ context").

Quoted 7 lines
Quoted 5 lines

The concept of additional lists of tests, like the arch tests, can be taken further in the future, for instance Arnaldo has expressed interest in adding tests that require root permissions, etc.

The patch series is based on tip/perf/core.

please base this over Arnaldo's perf/core

Yeah, that is better, sometimes, like now, the difference from tip/perf/core to acme/perf/core can grow as big as 50, 60 patches :-)

BTW I applied the first patch, with Jiri's ack, its in my perf/core branch now.

- Arnaldo

#14 lore raw
Quoted 6 lines · Arnaldo Carvalho de Melo

Em Mon, Sep 07, 2015 at 02:58:18PM +0200, Jiri Olsa escreveu:

Quoted 2 lines

please base this over Arnaldo's perf/core

Yeah, that is better, sometimes, like now, the difference from tip/perf/core to acme/perf/core can grow as big as 50, 60 patches :-)

OK, will do.

Quoted 1 line

BTW I applied the first patch, with Jiri's ack, its in my perf/core

Thanks!

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center