Messages in this thread | | | From | Namhyung Kim <> | Date | Mon, 29 Nov 2021 22:55:45 -0800 | Subject | Re: [PATCH 2/2] perf evsel: Improve error message for uncore events |
| |
Hi Ian,
On Mon, Nov 29, 2021 at 3:48 PM Ian Rogers <irogers@google.com> wrote: > > On Sun, Nov 28, 2021 at 8:58 AM Jiri Olsa <jolsa@redhat.com> wrote: > > > > On Mon, Nov 22, 2021 at 06:03:41PM -0800, Ian Rogers wrote: > > > When a group has multiple events and the leader fails it can yield > > > errors like: > > > > > > $ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true > > > Error: > > > The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/). > > > /bin/dmesg | grep -i perf may provide additional information. > > > > > > However, when not the group leader <not supported> is given: > > > > > > $ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true > > > ... > > > 1,619,057 instructions > > > <not supported> MiB uncore_imc/cas_count_read/ > > > > > > This is necessary because get_group_fd will fail if the leader fails and > > > is the direct result of the check on line 750 of builtin-stat.c in > > > stat_handle_error that returns COUNTER_SKIP for the latter case. > > > > > > This patch improves the error message to: > > > > > > $ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true > > > Error: > > > Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'. > > > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > > --- > > > tools/perf/util/evsel.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > > > index a59fb2ecb84e..48696ff4bddb 100644 > > > --- a/tools/perf/util/evsel.c > > > +++ b/tools/perf/util/evsel.c > > > @@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, > > > return scnprintf(msg, size, "wrong clockid (%d).", clockid); > > > if (perf_missing_features.aux_output) > > > return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel."); > > > + if ((evsel__leader(evsel) == evsel) && > > > + (evsel->core.leader->nr_members > 1)) > > > + return scnprintf(msg, size, > > > + "Invalid event (%s) in per-thread mode, enable system wide with '-a'.", > > > + evsel__name(evsel)); > > > > should we rather check 'target' pointer for the per-thread mode? > > I'm not sure that per-thread mode will always be the case for the failure > > Unfortunately the target isn't populated at that point:
It might be populated properly, as in this case it should have no target. I think you can use !target__has_cpu().
Thanks, Namhyung
> > gdb --args perf stat -e '{uncore_imc/cas_count_write/},instructions' /bin/true > (gdb) p *target > $2 = {pid = 0x0, tid = 0x0, cpu_list = 0x0, uid_str = 0x0, bpf_str = > 0x0, uid = 4294967295, system_wide = false, uses_mmap = false, > default_per_cpu = false, per_thread = false, use_bpf = false, hybrid > = false, attr_map = 0x0} > > #0 evsel__open_strerror (evsel=0x616000015680, target=0x5555586aa140 > <target>, err=22, msg=0x7fffffff78d0 "]k\264WUU", size=8192) > at util/evsel.c:2857 > #1 0x00005555561744e8 in stat_handle_error (counter=0x616000015680) > at builtin-stat.c:771 > #2 0x0000555556174f05 in __run_perf_stat (argc=1, > argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:852 > #3 0x00005555561763e1 in run_perf_stat (argc=1, argv=0x7fffffffe450, > run_idx=0) at builtin-stat.c:1048 > #4 0x000055555617df82 in cmd_stat (argc=1, argv=0x7fffffffe450) at > builtin-stat.c:2550 > #5 0x00005555562f36b8 in run_builtin (p=0x5555586bad00 > <commands+288>, argc=4, argv=0x7fffffffe450) at perf.c:313 > #6 0x00005555562f3c11 in handle_internal_command (argc=4, > argv=0x7fffffffe450) at perf.c:365 > #7 0x00005555562f3fce in run_argv (argcp=0x7fffffffe230, > argv=0x7fffffffe240) at perf.c:409 > #8 0x00005555562f47bd in main (argc=4, argv=0x7fffffffe450) at perf.c:539 > > Thanks, > Ian > > > jirka > > > > > break; > > > case ENODATA: > > > return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. " > > > -- > > > 2.34.0.rc2.393.gf8c9666880-goog > > > > >
| |