From: Kan Liang <kan.li...@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 <a...@redhat.com>
Signed-off-by: Kan Liang <kan.li...@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

Reply via email to