Skip to content

Commit

Permalink
perf evsel: Move and globalize perf_evsel__find_pmu() and perf_evsel_…
Browse files Browse the repository at this point in the history
…_is_aux_event()

Move and globalize 2 functions from the auxtrace specific sources so
that they can be reused.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20200401101613.6201-13-adrian.hunter@intel.com
[ Move to pmu.c, as moving to evsel.h breaks the python binding ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Apr 18, 2020
1 parent 2855c05 commit e12ee9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
19 changes: 0 additions & 19 deletions tools/perf/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,6 @@
#include "symbol/kallsyms.h"
#include <internal/lib.h>

static struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel)
{
struct perf_pmu *pmu = NULL;

while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (pmu->type == evsel->core.attr.type)
break;
}

return pmu;
}

static bool perf_evsel__is_aux_event(struct evsel *evsel)
{
struct perf_pmu *pmu = perf_evsel__find_pmu(evsel);

return pmu && pmu->auxtrace;
}

/*
* Make a group from 'leader' to 'last', requiring that the events were not
* already grouped to a different leader.
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ int perf_evsel__object_config(size_t object_size,
int (*init)(struct evsel *evsel),
void (*fini)(struct evsel *evsel));

struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel);
bool perf_evsel__is_aux_event(struct evsel *evsel);

struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx);

static inline struct evsel *evsel__new(struct perf_event_attr *attr)
Expand Down
20 changes: 20 additions & 0 deletions tools/perf/util/pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <regex.h>
#include <perf/cpumap.h>
#include "debug.h"
#include "evsel.h"
#include "pmu.h"
#include "parse-events.h"
#include "header.h"
Expand Down Expand Up @@ -884,6 +885,25 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu)
return NULL;
}

struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel)
{
struct perf_pmu *pmu = NULL;

while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (pmu->type == evsel->core.attr.type)
break;
}

return pmu;
}

bool perf_evsel__is_aux_event(struct evsel *evsel)
{
struct perf_pmu *pmu = perf_evsel__find_pmu(evsel);

return pmu && pmu->auxtrace;
}

struct perf_pmu *perf_pmu__find(const char *name)
{
struct perf_pmu *pmu;
Expand Down

0 comments on commit e12ee9f

Please sign in to comment.