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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH0uvogkdEfp_X4Tzc+WGeeuByTDBG9eaHyfeWZ2MbHoMZd6cg@mail.gmail.com>
Date: Wed, 25 Sep 2024 00:07:11 -0700
From: Howard Chu <howardchu95@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Namhyung Kim <namhyung@...nel.org>, acme@...nel.org, adrian.hunter@...el.com, 
	jolsa@...nel.org, kan.liang@...ux.intel.com, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/9] perf evsel: Set BPF output to system-wide

Hello,

On Tue, Sep 24, 2024 at 7:53 PM Ian Rogers <irogers@...gle.com> wrote:
>
> On Wed, Aug 7, 2024 at 8:58 PM Howard Chu <howardchu95@...il.com> wrote:
> >
> > Hello,
> >
> > The event does open, but bpf_perf_event_output() in BPF will return
> > -95(-EOPNOTSUPP), so no output. I think this EOPNOTSUPP is not in
> > bpf_trace.c's __bpf_perf_event_output(), but in perf_event's
> > perf_event_output() called by BPF.
> >
> >           <idle>-0       [001] d..4. 154921.079230: bpf_trace_printk: err -95
> >
> > This is also a bug in perf trace -p <PID>.
> >
> > Thanks,
> > Howard
> >
> > On Thu, Aug 8, 2024 at 7:21 AM Namhyung Kim <namhyung@...nel.org> wrote:
> > >
> > > On Wed, Aug 07, 2024 at 11:38:35PM +0800, Howard Chu wrote:
> > > > pid = -1 for bpf-output event.
> > > >
> > > > This makes perf record -p <PID> --off-cpu work. Otherwise bpf-output
> > > > cannot be collected.
> > >
> > > I don't understand why it's necessary.  Why isn't it collected?
> > > Is it the kernel to reject the BPF output event to open?
> > >
> > > Thanks,
> > > Namhyung
> > >
> > > >
> > > > Signed-off-by: Howard Chu <howardchu95@...il.com>
> > > > ---
> > > >  tools/perf/util/evsel.c | 4 ++++
> > > >  1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > > > index bc603193c477..b961467133cf 100644
> > > > --- a/tools/perf/util/evsel.c
> > > > +++ b/tools/perf/util/evsel.c
> > > > @@ -2282,6 +2282,10 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
> > > >
> > > >                       test_attr__ready();
> > > >
> > > > +                     /* BPF output event can only be system-wide */
> > > > +                     if (evsel__is_bpf_output(evsel))
> > > > +                             pid = -1;
>
> This matches with libbpf:
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/bpf/libbpf.c#n11967

Thanks for pointing it out, that's a very good reference. Namhyung
actually came up with a very good solution and based on his idea I
posted this patch series:
https://lore.kernel.org/linux-perf-users/20240827092013.1596-1-howardchu95@gmail.com/

Thanks,
Howard
>
> Thanks,
> Ian
>
> > > > +
> > > >                       /* Debug message used by test scripts */
> > > >                       pr_debug2_peo("sys_perf_event_open: pid %d  cpu %d  group_fd %d  flags %#lx",
> > > >                               pid, perf_cpu_map__cpu(cpus, idx).cpu, group_fd, evsel->open_flags);
> > > > --
> > > > 2.45.2
> > > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ