libperf: Add perf_evsel__init function
authorJiri Olsa <jolsa@kernel.org>
Sun, 21 Jul 2019 11:24:24 +0000 (13:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:44 +0000 (18:34 -0300)
Add the perf_evsel__init() function to initialize perf_evsel struct.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-38-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/lib/evsel.c
tools/perf/lib/include/perf/evsel.h
tools/perf/lib/libperf.map
tools/perf/util/evsel.c

index 12e86de1994bd2f9751ea74c99464f23264b5e6d..9a87e867a7ecfc5d1097b090f5fedd5f12ed3bd1 100644 (file)
@@ -2,3 +2,8 @@
 #include <perf/evsel.h>
 #include <linux/list.h>
 #include <internal/evsel.h>
+
+void perf_evsel__init(struct perf_evsel *evsel)
+{
+       INIT_LIST_HEAD(&evsel->node);
+}
index 162bffd43409da6a58920d0943ec9ce1d909681f..b4d074a3684bdf7a950fbf6d42fbb2f2d5e4a151 100644 (file)
@@ -2,6 +2,10 @@
 #ifndef __LIBPERF_EVSEL_H
 #define __LIBPERF_EVSEL_H
 
+#include <perf/core.h>
+
 struct perf_evsel;
 
+LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel);
+
 #endif /* __LIBPERF_EVSEL_H */
index c4f611010ccc4fba9b6cc07b59febd901c13708f..54f8503c6d82f9aa21d56d82d3baf5ce45e9fcd9 100644 (file)
@@ -9,6 +9,7 @@ LIBPERF_0.0.1 {
                perf_thread_map__comm;
                perf_thread_map__get;
                perf_thread_map__put;
+               perf_evsel__init;
        local:
                *;
 };
index 8fed22d889a498db50895c20338a9d852e24db12..172bcc2e198faddf5bfbfd0aca400ad726939f25 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <perf/evsel.h>
 #include "asm/bug.h"
 #include "callchain.h"
 #include "cgroup.h"
@@ -226,6 +227,7 @@ bool perf_evsel__is_function_event(struct evsel *evsel)
 void evsel__init(struct evsel *evsel,
                 struct perf_event_attr *attr, int idx)
 {
+       perf_evsel__init(&evsel->core);
        evsel->idx         = idx;
        evsel->tracking    = !idx;
        evsel->attr        = *attr;
@@ -236,7 +238,6 @@ void evsel__init(struct evsel *evsel,
        evsel->evlist      = NULL;
        evsel->bpf_obj     = NULL;
        evsel->bpf_fd      = -1;
-       INIT_LIST_HEAD(&evsel->core.node);
        INIT_LIST_HEAD(&evsel->config_terms);
        perf_evsel__object.init(evsel);
        evsel->sample_size = __perf_evsel__sample_size(attr->sample_type);