Skip to contentSkip to conversation

perf test: Report failure for mmap events

PATCH Applied Leo Yan 3 participants 8 messages Oct 11, 2019 – Oct 22, 2019 perf events

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH 1/2 perf test: Report failure for mmap events

When fail to mmap events in task exit case, it misses to set 'err' to -1; thus the testing will not report failure for it.

This patch sets 'err' to -1 when fails to mmap events, thus Perf tool can report correct result.

---
 tools/perf/tests/task-exit.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/tests/task-exit.c +1 -0
index bce3a4cb4c89..ca0a6ca43b13 100644
@@ -110,6 +110,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	if (evlist__mmap(evlist, 128) < 0) {
 		pr_debug("failed to mmap events: %d (%s)\n", errno,
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		err = -1;
 		goto out_delete_evlist;
 	}
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 perf test: Avoid infinite loop for task exit case

When execute task exit testing case, Perf tool stucks in this case and doesn't return back on Arm64 Juno board.

After dig into this issue, since Juno board has Arm's big.LITTLE CPUs, thus the PMUs are not compatible between the big CPUs and little CPUs. This leads to PMU event cannot be enabled properly when the traced task is migrated from one variant's CPU to another variant. Finally, the test case runs into infinite loop for cannot read out any event data after return from polling.

Eventually, we need to work out formal solution to allow PMU events can be freely migrated from one CPU variant to another, but this is a difficult task and a different topic. This patch tries to fix the Perf test case to avoid infinite loop, when the testing detects 1000 times retrying for reading empty events, it will directly bail out and return failure. This allows the Perf tool can continue its other test cases.

---
 tools/perf/tests/task-exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/perf/tests/task-exit.c +8 -0
index ca0a6ca43b13..d85c9f608564 100644
@@ -53,6 +53,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	struct perf_cpu_map *cpus;
 	struct perf_thread_map *threads;
 	struct mmap *md;
+	int retry_count = 0;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -132,6 +133,13 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 out_init:
 	if (!exited || !nr_exit) {
 		evlist__poll(evlist, -1);
+
+		if (retry_count++ > 1000) {
+			pr_debug("Failed after retrying 1000 times\n");
+			err = -1;
+			goto out_free_maps;
+		}
+
 		goto retry;
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v1 2/2] perf test: Avoid infinite loop for task exit case

Em Fri, Oct 11, 2019 at 05:19:42PM +0800, Leo Yan escreveu:

Quoted 9 lines

When execute task exit testing case, Perf tool stucks in this case and doesn't return back on Arm64 Juno board.

After dig into this issue, since Juno board has Arm's big.LITTLE CPUs, thus the PMUs are not compatible between the big CPUs and little CPUs. This leads to PMU event cannot be enabled properly when the traced task is migrated from one variant's CPU to another variant. Finally, the test case runs into infinite loop for cannot read out any event data after return from polling.

Thanks, I'll go over this after I finish the current pull request,

- Arnaldo

Quoted 40 lines

Eventually, we need to work out formal solution to allow PMU events can be freely migrated from one CPU variant to another, but this is a difficult task and a different topic. This patch tries to fix the Perf test case to avoid infinite loop, when the testing detects 1000 times retrying for reading empty events, it will directly bail out and return failure. This allows the Perf tool can continue its other test cases.

---
 tools/perf/tests/task-exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/perf/tests/task-exit.c +8 -0
index ca0a6ca43b13..d85c9f608564 100644
@@ -53,6 +53,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	struct perf_cpu_map *cpus;
 	struct perf_thread_map *threads;
 	struct mmap *md;
+	int retry_count = 0;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -132,6 +133,13 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 out_init:
 	if (!exited || !nr_exit) {
 		evlist__poll(evlist, -1);
+
+		if (retry_count++ > 1000) {
+			pr_debug("Failed after retrying 1000 times\n");
+			err = -1;
+			goto out_free_maps;
+		}
+
 		goto retry;
 	}
 
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
#3 lore raw

Re: [PATCH v1 2/2] perf test: Avoid infinite loop for task exit case

In reply to Leo Yan

Em Fri, Oct 11, 2019 at 05:19:42PM +0800, Leo Yan escreveu:

Quoted 10 lines

When execute task exit testing case, Perf tool stucks in this case and doesn't return back on Arm64 Juno board.

After dig into this issue, since Juno board has Arm's big.LITTLE CPUs, thus the PMUs are not compatible between the big CPUs and little CPUs. This leads to PMU event cannot be enabled properly when the traced task is migrated from one variant's CPU to another variant. Finally, the test case runs into infinite loop for cannot read out any event data after return from polling.

Quoted 6 lines

Eventually, we need to work out formal solution to allow PMU events can be freely migrated from one CPU variant to another, but this is a difficult task and a different topic. This patch tries to fix the Perf test case to avoid infinite loop, when the testing detects 1000 times retrying for reading empty events, it will directly bail out and return failure. This allows the Perf tool can continue its other test cases.

Thanks, applied.

- Arnaldo

Quoted 33 lines
---
 tools/perf/tests/task-exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/perf/tests/task-exit.c +8 -0
index ca0a6ca43b13..d85c9f608564 100644
@@ -53,6 +53,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	struct perf_cpu_map *cpus;
 	struct perf_thread_map *threads;
 	struct mmap *md;
+	int retry_count = 0;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -132,6 +133,13 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 out_init:
 	if (!exited || !nr_exit) {
 		evlist__poll(evlist, -1);
+
+		if (retry_count++ > 1000) {
+			pr_debug("Failed after retrying 1000 times\n");
+			err = -1;
+			goto out_free_maps;
+		}
+
 		goto retry;
 	}
 
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
author
#4 lore raw

Re: [PATCH v1 2/2] perf test: Avoid infinite loop for task exit case

Quoted 11 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 11, 2019 at 05:19:42PM +0800, Leo Yan escreveu:

Quoted 10 lines

When execute task exit testing case, Perf tool stucks in this case and doesn't return back on Arm64 Juno board.

After dig into this issue, since Juno board has Arm's big.LITTLE CPUs, thus the PMUs are not compatible between the big CPUs and little CPUs. This leads to PMU event cannot be enabled properly when the traced task is migrated from one variant's CPU to another variant. Finally, the test case runs into infinite loop for cannot read out any event data after return from polling.

Quoted 8 lines
Quoted 6 lines

Eventually, we need to work out formal solution to allow PMU events can be freely migrated from one CPU variant to another, but this is a difficult task and a different topic. This patch tries to fix the Perf test case to avoid infinite loop, when the testing detects 1000 times retrying for reading empty events, it will directly bail out and return failure. This allows the Perf tool can continue its other test cases.

Thanks, applied.

Thanks a lot, Arnaldo.

merge bot Applied
#5 lore raw

[tip: perf/core] perf test: Avoid infinite loop for task exit case

In reply to Leo Yan
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     791ce9c48c79210d2ffcdbe69421e7783b32921f
Gitweb:        https://git.kernel.org/tip/791ce9c48c79210d2ffcdbe69421e7783b32921f
Author:        Leo Yan <[email protected]>
AuthorDate:    Fri, 11 Oct 2019 17:19:42 +08:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 15 Oct 2019 08:36:22 -03:00

perf test: Avoid infinite loop for task exit case

When executing the task exit testing case, perf gets stuck in an endless loop this case and doesn't return back on Arm64 Juno board.

After digging into this issue, since Juno board has Arm's big.LITTLE CPUs, thus the PMUs are not compatible between the big CPUs and little CPUs. This leads to a PMU event that cannot be enabled properly when the traced task is migrated from one variant's CPU to another variant. Finally, the test case runs into infinite loop for cannot read out any event data after return from polling.

Eventually, we need to work out formal solution to allow PMU events can be freely migrated from one CPU variant to another, but this is a difficult task and a different topic. This patch tries to fix the Perf test case to avoid infinite loop, when the testing detects 1000 times retrying for reading empty events, it will directly bail out and return failure. This allows the Perf tool can continue its other test cases.

---
 tools/perf/tests/task-exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/perf/tests/task-exit.c +8 -0
index 19fa7cb..adaff90 100644
@@ -54,6 +54,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	struct perf_cpu_map *cpus;
 	struct perf_thread_map *threads;
 	struct mmap *md;
+	int retry_count = 0;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -133,6 +134,13 @@ retry:
 out_init:
 	if (!exited || !nr_exit) {
 		evlist__poll(evlist, -1);
+
+		if (retry_count++ > 1000) {
+			pr_debug("Failed after retrying 1000 times\n");
+			err = -1;
+			goto out_free_maps;
+		}
+
 		goto retry;
 	}
 
#6 lore raw
In reply to Leo Yan

Em Fri, Oct 11, 2019 at 05:19:41PM +0800, Leo Yan escreveu:

Quoted 5 lines

When fail to mmap events in task exit case, it misses to set 'err' to -1; thus the testing will not report failure for it.

This patch sets 'err' to -1 when fails to mmap events, thus Perf tool can report correct result.

Thanks, applied and added:

Fixes d723a55096b8 ("perf test: Add test case for checking number of EXIT events")
Quoted 19 lines
---
 tools/perf/tests/task-exit.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/tests/task-exit.c +1 -0
index bce3a4cb4c89..ca0a6ca43b13 100644
@@ -110,6 +110,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	if (evlist__mmap(evlist, 128) < 0) {
 		pr_debug("failed to mmap events: %d (%s)\n", errno,
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		err = -1;
 		goto out_delete_evlist;
 	}
 
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
merge bot Applied
#7 lore raw
In reply to Leo Yan
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     6add129c5d9210ada25217abc130df0b7096ee02
Gitweb:        https://git.kernel.org/tip/6add129c5d9210ada25217abc130df0b7096ee02
Author:        Leo Yan <[email protected]>
AuthorDate:    Fri, 11 Oct 2019 17:19:41 +08:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 15 Oct 2019 08:36:22 -03:00

perf test: Report failure for mmap events

When fail to mmap events in task exit case, it misses to set 'err' to -1; thus the testing will not report failure for it.

This patch sets 'err' to -1 when fails to mmap events, thus Perf tool can report correct result.

Fixes d723a55096b8 ("perf test: Add test case for checking number of EXIT events")
Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/tests/task-exit.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/tests/task-exit.c +1 -0
index 4965f8b..19fa7cb 100644
@@ -111,6 +111,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	if (evlist__mmap(evlist, 128) < 0) {
 		pr_debug("failed to mmap events: %d (%s)\n", errno,
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		err = -1;
 		goto out_delete_evlist;
 	}