perf cs-etm: Improve missing sink warning message
authorJames Clark <james.clark@arm.com>
Tue, 24 Jan 2023 11:02:20 +0000 (11:02 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 27 Jan 2023 18:00:34 +0000 (15:00 -0300)
Make the sink error message more similar to the event error message that
reminds about missing kernel support. The available sinks are also
determined by the hardware so mention that too.

Also, usually it's not necessary to specify the sink, so add that as a
hint.

Now the error for a made up sink looks like this:

  $ perf record -e cs_etm/@abc/
  Couldn't find sink "abc" on event cs_etm/@abc/.
  Missing kernel or device support?

  Hint: An appropriate sink will be picked automatically if one isn't is specified.

For any error other than ENOENT, the same message as before is
displayed.

Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Suzuki Poulouse <suzuki.poulose@arm.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/ec7502e6-b406-3997-c2a5-24f98e5c4854@arm.com
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230124110220.460551-1-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/arm/util/cs-etm.c

index 481e170..7f71c8a 100644 (file)
@@ -283,9 +283,15 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
 
                ret = perf_pmu__scan_file(pmu, path, "%x", &hash);
                if (ret != 1) {
-                       pr_err("failed to set sink \"%s\" on event %s with %d (%s)\n",
-                              sink, evsel__name(evsel), errno,
-                              str_error_r(errno, msg, sizeof(msg)));
+                       if (errno == ENOENT)
+                               pr_err("Couldn't find sink \"%s\" on event %s\n"
+                                      "Missing kernel or device support?\n\n"
+                                      "Hint: An appropriate sink will be picked automatically if one isn't specified.\n",
+                                      sink, evsel__name(evsel));
+                       else
+                               pr_err("Failed to set sink \"%s\" on event %s with %d (%s)\n",
+                                      sink, evsel__name(evsel), errno,
+                                      str_error_r(errno, msg, sizeof(msg)));
                        return ret;
                }