Message ID | 20241010143152.19071-1-adrian.hunter@intel.com |
---|---|
State | Superseded |
Headers | show |
On Thu, Oct 10, 2024 at 05:31:48PM +0300, Adrian Hunter wrote: > Display "feature is not supported" error message if aux_start_paused, > aux_pause or aux_resume result in a perf_event_open() error. > > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > Acked-by: Ian Rogers <irogers@google.com> > Reviewed-by: Andi Kleen <ak@linux.intel.com> This patch looks good to me. A case is the Linux kernel has supported aux_pause_resume feature, but the PMU event does not support it. So we might consider to add a extra patch in perf: diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 927aa61e7b14..9a3191df2ec5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3373,6 +3373,10 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, return scnprintf(msg, size, "%s: PMU Hardware doesn't support 'aux_output' feature", evsel__name(evsel)); + if (evsel->core.attr.aux_action) + return scnprintf(msg, size, + "%s: PMU Hardware doesn't support 'aux_action' feature", + evsel__name(evsel)); if (evsel->core.attr.sample_period != 0) return scnprintf(msg, size, "%s: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'", Thanks, Leo > --- > tools/perf/util/evsel.c | 10 +++++++++- > tools/perf/util/evsel.h | 1 + > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index d34ceab9e454..927aa61e7b14 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -2147,7 +2147,13 @@ bool evsel__detect_missing_features(struct evsel *evsel) > * Must probe features in the order they were added to the > * perf_event_attr interface. > */ > - if (!perf_missing_features.branch_counters && > + if (!perf_missing_features.aux_pause_resume && > + (evsel->core.attr.aux_pause || evsel->core.attr.aux_resume || > + evsel->core.attr.aux_start_paused)) { > + perf_missing_features.aux_pause_resume = true; > + pr_debug2_peo("Kernel has no aux_pause/aux_resume support, bailing out\n"); > + return false; > + } else if (!perf_missing_features.branch_counters && > (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS)) { > perf_missing_features.branch_counters = true; > pr_debug2("switching off branch counters support\n"); > @@ -3397,6 +3403,8 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, > return scnprintf(msg, size, "clockid feature not supported."); > if (perf_missing_features.clockid_wrong) > return scnprintf(msg, size, "wrong clockid (%d).", clockid); > + if (perf_missing_features.aux_pause_resume) > + return scnprintf(msg, size, "The 'aux_pause / aux_resume' feature is not supported, update the kernel."); > if (perf_missing_features.aux_output) > return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel."); > if (!target__has_cpu(target)) > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h > index 15e745a9a798..778fcdb8261f 100644 > --- a/tools/perf/util/evsel.h > +++ b/tools/perf/util/evsel.h > @@ -221,6 +221,7 @@ struct perf_missing_features { > bool weight_struct; > bool read_lost; > bool branch_counters; > + bool aux_pause_resume; > }; > > extern struct perf_missing_features perf_missing_features; > -- > 2.43.0 > >
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 0c557f0a17b3..05dcc43f11bb 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -369,6 +369,22 @@ enum perf_event_read_format { PERF_FORMAT_MAX = 1U << 5, /* non-ABI */ }; +enum { + PERF_AUX_ACTION_START_PAUSED = 1U << 0, + PERF_AUX_ACTION_PAUSE = 1U << 1, + PERF_AUX_ACTION_RESUME = 1U << 2, + PERF_AUX_ACTION_EMIT = 1U << 3, + PERF_AUX_ACTION_NR = 0x1f << 4, + PERF_AUX_ACTION_NO_IP = 1U << 9, + PERF_AUX_ACTION_PAUSE_ON_EVT = 1U << 10, + PERF_AUX_ACTION_RESUME_ON_EVT = 1U << 11, + PERF_AUX_ACTION_EMIT_ON_EVT = 1U << 12, + PERF_AUX_ACTION_NR_ON_EVT = 0x1f << 13, + PERF_AUX_ACTION_NO_IP_ON_EVT = 1U << 18, + PERF_AUX_ACTION_MASK = ~PERF_AUX_ACTION_START_PAUSED, + PERF_AUX_PAUSE_RESUME_MASK = PERF_AUX_ACTION_PAUSE | PERF_AUX_ACTION_RESUME, +}; + #define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ #define PERF_ATTR_SIZE_VER1 72 /* add: config2 */ #define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */ @@ -515,10 +531,19 @@ struct perf_event_attr { union { __u32 aux_action; struct { - __u32 aux_start_paused : 1, /* start AUX area tracing paused */ - aux_pause : 1, /* on overflow, pause AUX area tracing */ - aux_resume : 1, /* on overflow, resume AUX area tracing */ - __reserved_3 : 29; + __u32 aux_start_paused : 1, /* start AUX area tracing paused */ + aux_pause : 1, /* on overflow, pause AUX area tracing */ + aux_resume : 1, /* on overflow, resume AUX area tracing */ + aux_emit : 1, /* generate AUX records instead of events */ + aux_nr : 5, /* AUX area tracing reference number */ + aux_no_ip : 1, /* suppress IP in AUX records */ + /* Following apply to event occurrence not overflows */ + aux_pause_on_evt : 1, /* on event, pause AUX area tracing */ + aux_resume_on_evt : 1, /* on event, resume AUX area tracing */ + aux_emit_on_evt : 1, /* generate AUX records instead of events */ + aux_nr_on_evt : 5, /* AUX area tracing reference number */ + aux_no_ip_on_evt : 1, /* suppress IP in AUX records */ + __reserved_3 : 13; }; };