mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf evsel: Add a check in the error path for the auxiliary event
@ 2021-02-03 22:37 kan.liang
  0 siblings, 0 replies; only message in thread
From: kan.liang @ 2021-02-03 22:37 UTC (permalink / raw)
  To: acme, linux-kernel
  Cc: mingo, peterz, eranian, namhyung, jolsa, ak, yao.jin, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

Current perf assumes that the ENODATA is a unique error code for the
auxiliary event on Sapphire Rapids. The assumption is good for now, but
this is fragile. In the future, someone may not remember that the
ENODATA is for the auxiliary event on Sapphire Rapids, and reuse it for
other purposes. The error message for the auxiliary event may be
mistakenly displayed.

Add a check to identify the auxiliary event case.

Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/util/evsel.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 844aebd..30b5452 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -48,6 +48,7 @@
 #include "util.h"
 #include "../perf-sys.h"
 #include "util/parse-branch-options.h"
+#include "pmu.h"
 #include <internal/xyarray.h>
 #include <internal/lib.h>
 
@@ -2735,8 +2736,10 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
 			return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
 		break;
 	case ENODATA:
-		return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
-				 "Please add an auxiliary event in front of the load latency event.");
+		if (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_SRC && pmu_have_event("cpu", "mem-loads-aux")) {
+			return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
+					 "Please add an auxiliary event in front of the load latency event.");
+		}
 	default:
 		break;
 	}
-- 
2.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-03 22:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 22:37 [PATCH] perf evsel: Add a check in the error path for the auxiliary event kan.liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®