lkml.org 
[lkml]   [2020]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 12/16] perf tools: Move and globalize perf_evsel__find_pmu() and perf_evsel__is_aux_event()
    Date
    Move and globalize 2 functions so that they can be reused.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    ---
    tools/perf/util/auxtrace.c | 19 -------------------
    tools/perf/util/evsel.c | 20 ++++++++++++++++++++
    tools/perf/util/evsel.h | 3 +++
    3 files changed, 23 insertions(+), 19 deletions(-)

    diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
    index 809a09e75c55..33ad33378a90 100644
    --- a/tools/perf/util/auxtrace.c
    +++ b/tools/perf/util/auxtrace.c
    @@ -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.
    diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
    index 60e6cd49dee3..d4ab073c9fe7 100644
    --- a/tools/perf/util/evsel.c
    +++ b/tools/perf/util/evsel.c
    @@ -44,6 +44,7 @@
    #include "stat.h"
    #include "string2.h"
    #include "memswap.h"
    +#include "pmu.h"
    #include "util.h"
    #include "../perf-sys.h"
    #include "util/parse-branch-options.h"
    @@ -100,6 +101,25 @@ int perf_evsel__object_config(size_t object_size,
    return 0;
    }

    +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;
    +}
    +
    #define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))

    int __perf_evsel__sample_size(u64 sample_type)
    diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
    index e64ed4202cab..a463bc65b001 100644
    --- a/tools/perf/util/evsel.h
    +++ b/tools/perf/util/evsel.h
    @@ -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)
    --
    2.17.1
    \
     
     \ /
      Last update: 2020-04-01 12:18    [W:2.275 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site