Re: [RFC 00/79] perf tools: Initial libperf separation
From: Arnaldo Carvalho de Melo
Date: Wed Jul 24 2019 - 09:50:48 EST
Em Wed, Jul 24, 2019 at 07:42:50AM +0000, Song Liu escreveu:
> > On Jul 21, 2019, at 4:23 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > we have long term goal to separate some of the perf functionality
> > into library. This patchset is initial effort on separating some
> > of the interface.
> > Currently only the basic counting interface is exported, it allows
> > to:
> > - create cpu/threads maps
> > - create evlist/evsel objects
> > - add evsel objects into evlist
> > - open/close evlist/evsel objects
> > - enable/disable events
> > - read evsel counts
> Based on my understanding, evsel and evlist are abstractions in
> perf utilities. I think most other tools that use perf UAPIs are
> not built based on these abstractions. I looked at a few internal
> tools. Most of them just uses sys_perf_event_open() and struct
> perf_event_attr. I am not sure whether these tools would adopt
> libperf, as libperf changes their existing concepts/abstractions.
Right, and for now we're just trying to have something that is not so
tied to perf and could possibly be useful outside tools/perf/ when the
need arises for whatever new tool or pre-existing one.
There are features there that may be interesting to use outside perf,
time will tell.
> > The initial effort was to have total separation of the objects
> > from perf code, but it showed not to be a good way. The amount
> > of changed code was too big with high chance for regressions,
> > mainly because of the code embedding one of the above objects
> > statically.
> > We took the other approach of sharing the objects/struct details
> > within the perf and libperf code. This way we can keep perf
> > functionality without any major changes and the libperf users
> > are still separated from the object/struct details. We can move
> > to total libperf's objects separation gradually in future.
> I found some duplicated logic between libperf and perf, for
> example, perf_evlist__open() and evlist__open(). Do we plan to
> merge them in the future?
He is just slowly moving things to a public libperf while keeping perf
working, in the end the goal is to have as much stuff that is not
super specific to some of the existing perf tools
(tools/perf/builtin-*.c) in libperf as possible.
It is still early in this effort, that is why he is still leaving it in
tools/perf/lib/ and not in tools/lib/perf/ :-)
- Arnaldo