lkml.org 
[lkml]   [2022]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [RFC PATCH v2 4/7] libperf: Introduce perf_{evsel, evlist}__open_opt with extensible struct opts
Date
Hi jirka

> On Fri, Mar 25, 2022 at 01:38:26PM +0900, Shunsuke Nakamura wrote:
> > Introduce perf_{evsel, evlist}__open_opt with extensible structure opts.
> > The mechanism of the extensible structure opts imitates
> > tools/lib/bpf/libbpf.h. This allows the user to set the open_flags
> > specified in perf_event_open and a signal handler to receive overflow
> > notifications for sampling events.
> >
> > Signed-off-by: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
> > ---
> > tools/lib/perf/Documentation/libperf.txt | 14 +++
> > tools/lib/perf/evlist.c | 20 +++++
> > tools/lib/perf/evsel.c | 105
> +++++++++++++++++++++++
> > tools/lib/perf/include/perf/evlist.h | 3 +
> > tools/lib/perf/include/perf/evsel.h | 26 ++++++
> > tools/lib/perf/internal.h | 44 ++++++++++
> > tools/lib/perf/libperf.map | 2 +
> > 7 files changed, 214 insertions(+)
> >
> > diff --git a/tools/lib/perf/Documentation/libperf.txt
> > b/tools/lib/perf/Documentation/libperf.txt
> > index ae55e62fc4ce..700c1ce15159 100644
> > --- a/tools/lib/perf/Documentation/libperf.txt
> > +++ b/tools/lib/perf/Documentation/libperf.txt
> > @@ -131,6 +131,20 @@ SYNOPSIS
> > };
> > };
> >
> > + struct perf_evsel_open_opts {
> > + /* size of this struct, for forward/backward compatibility */
> > + size_t sz;
> > +
> > + unsigned long open_flags; /* perf_event_open flags */
> > + int flags; /* fcntl flags */
> > + unsigned int signal;
> > + int owner_type;
> > + struct sigaction *sig;
> > + };
> > + #define perf_evsel_open_opts__last_field sig
> > +
> > + #define LIBPERF_OPTS(TYPE, NAME, ...)
> > +
>
> SNIP
>
> > +
> > +int perf_evsel__open_opts(struct perf_evsel *evsel, struct perf_cpu_map
> *cpus,
> > + struct perf_thread_map *threads,
> > + struct perf_evsel_open_opts *opts) {
> > + int err = 0;
> > +
> > + if (!OPTS_VALID(opts, perf_evsel_open_opts)) {
> > + err = -EINVAL;
> > + return err;
> > + }
> > +
> > + evsel->open_flags = OPTS_GET(opts, open_flags, 0);
> > +
> > + err = perf_evsel__open(evsel, cpus, threads);
> > + if (err)
> > + return err;
> > +
> > + err = perf_evsel__set_signal_handler(evsel, opts);
> > + if (err)
> > + return err;
>
> please move the signal stuff handling into separate patch together with the
> related fields in opts struct
>
I'll fix it.


Best Regards
Shunsuke

\
 
 \ /
  Last update: 2022-04-11 10:32    [W:0.069 / U:0.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site