[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YTCOVGyffe+VwL6G@krava>
Date: Thu, 2 Sep 2021 10:41:56 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Nakamura Shun <nakamura.shun@...itsu.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Rob Herring <robh@...nel.org>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: libperf: lack of interface
On Wed, Sep 01, 2021 at 10:36:40AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 01, 2021 at 09:45:10AM +0000, nakamura.shun@...itsu.com escreveu:
> > Hello.
> >
> > I'm trying to change rdpmc test in perf_event_tests[1] to use libperf, but libperf doesn't have enough interfaces.
> > Does anyone plan to implement any of these libperf features?
> >
> > - Interfaces that can run ioctl (PERF_EVENT_IOC_RESET) from userland
> > - Interfaces that can run fcntl (SIGIO) from userland
hi,
we could add perf_evsel__fd like below, would it help your usecase?
if you described your usecases in more details we could
see if we could add/move something to libperf for that
as Arnaldo said below it could be already in tools/perf/util/*.c
somewhere ;-)
jirka
> >
> > [1] https://github.com/deater/perf_event_tests/tree/master/tests/rdpmc
>
> So, while in this specific case you should probably follow PeterZ's
> advice, feel free to submit patches moving stuff that is in
> tools/perf/util/ to tools/lib/perf/ (libperf) when you have a reasonable
> use case, such as Vince's test suite.
>
> We can then discuss if any adjustment is needed, but doing it this
> piecemeal way, with justification, should be a good way to enrich
> libperf with things that are in quiescent state in tools/perf/util/ and
> that have external users.
>
> Thanks,
>
> - Arnaldo
>
---
tools/lib/perf/evsel.c | 13 +++++++++++++
tools/lib/perf/include/perf/evsel.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
index d8886720e83d..8cbdaa78749c 100644
--- a/tools/lib/perf/evsel.c
+++ b/tools/lib/perf/evsel.c
@@ -413,3 +413,16 @@ void perf_evsel__free_id(struct perf_evsel *evsel)
zfree(&evsel->id);
evsel->ids = 0;
}
+
+int perf_evsel__fd(struct perf_evsel *evsel, int cpu, int thread)
+{
+ int max_thread = xyarray__max_y(evsel->fd);
+ int max_cpu = xyarray__max_x(evsel->fd);
+
+ if (thread >= max_thread)
+ return -EINVAL;
+ if (cpu >= max_cpu)
+ return -EINVAL;
+
+ return FD(evsel, cpu, thread);
+}
diff --git a/tools/lib/perf/include/perf/evsel.h b/tools/lib/perf/include/perf/evsel.h
index 60eae25076d3..5f29935efcaf 100644
--- a/tools/lib/perf/include/perf/evsel.h
+++ b/tools/lib/perf/include/perf/evsel.h
@@ -39,5 +39,6 @@ LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu);
LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
+LIBPERF_API int perf_evsel__fd(struct perf_evsel *evsel, int cpu, int thread);
#endif /* __LIBPERF_EVSEL_H */
--
2.31.1
Powered by blists - more mailing lists