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

From: tip-bot2 for Leo Yan
Date: Mon Oct 21 2019 - 20:03:47 EST


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 <leo.yan@xxxxxxxxxx>
AuthorDate: Fri, 11 Oct 2019 17:19:42 +08:00
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
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.

Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Link: http://lore.kernel.org/lkml/20191011091942.29841-2-leo.yan@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/tests/task-exit.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 19fa7cb..adaff90 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -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;
}