lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP-5=fUYO2ebkQ_1=Wn50MouymbJ4DFHogG-JcM-XT4uaD-CGw@mail.gmail.com>
Date:   Mon, 29 Nov 2021 23:57:19 -0800
From:   Ian Rogers <irogers@...gle.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Jiri Olsa <jolsa@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        linux-perf-users <linux-perf-users@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 2/2] perf evsel: Improve error message for uncore events

On Mon, Nov 29, 2021 at 10:55 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> Hi Ian,
>
> On Mon, Nov 29, 2021 at 3:48 PM Ian Rogers <irogers@...gle.com> wrote:
> >
> > On Sun, Nov 28, 2021 at 8:58 AM Jiri Olsa <jolsa@...hat.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@...gle.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 :-) I'm not sure having !target__has_cpu is intention
revealing. Perhaps changing the error to say that an
invalid/unsupported event can't be the group leader, unless it is the
only event, and then suggest system wide mode.

Thanks,
Ian

> 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
> > > >
> > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ