From af4a0991f40a1e50e5caff0317f152df2c82bdeb Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 15 Jul 2019 16:22:57 -0300 Subject: perf evsel: Store backpointer to attached bpf_object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We may want to get to this bpf_object, to search for other BPF programs, etc. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-3y8hrb6lszjfi23vjlic3cib@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index c61974a50aa5..6d0dfb777a79 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -763,7 +763,7 @@ int bpf__foreach_event(struct bpf_object *obj, if (priv->is_tp) { fd = bpf_program__fd(prog); - err = (*func)(priv->sys_name, priv->evt_name, fd, arg); + err = (*func)(priv->sys_name, priv->evt_name, fd, obj, arg); if (err) { pr_debug("bpf: tracepoint call back failed, stop iterate\n"); return err; @@ -788,7 +788,7 @@ int bpf__foreach_event(struct bpf_object *obj, return fd; } - err = (*func)(tev->group, tev->event, fd, arg); + err = (*func)(tev->group, tev->event, fd, obj, arg); if (err) { pr_debug("bpf: call back failed, stop iterate\n"); return err; -- cgit v1.2.1 From 32dcd021d004038ca12ac17319da5aa4756e9312 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 21 Jul 2019 13:23:51 +0200 Subject: perf evsel: Rename struct perf_evsel to struct evsel Rename struct perf_evsel to struct evsel, so we don't have a name clash when we add struct perf_evsel in libperf. Committer notes: Added fixes for arm64, provided by Jiri. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 6d0dfb777a79..594ea279e25b 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -817,7 +817,7 @@ struct bpf_map_op { } k; union { u64 value; - struct perf_evsel *evsel; + struct evsel *evsel; } v; }; @@ -1063,7 +1063,7 @@ __bpf_map__config_event(struct bpf_map *map, struct parse_events_term *term, struct perf_evlist *evlist) { - struct perf_evsel *evsel; + struct evsel *evsel; const struct bpf_map_def *def; struct bpf_map_op *op; const char *map_name = bpf_map__name(map); @@ -1401,7 +1401,7 @@ apply_config_value_for_key(int map_fd, void *pkey, static int apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, - struct perf_evsel *evsel) + struct evsel *evsel) { struct xyarray *xy = evsel->fd; struct perf_event_attr *attr; @@ -1523,11 +1523,11 @@ int bpf__apply_obj_config(void) (strcmp(name, \ bpf_map__name(pos)) == 0)) -struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name) +struct evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name) { struct bpf_map_priv *tmpl_priv = NULL; struct bpf_object *obj, *tmp; - struct perf_evsel *evsel = NULL; + struct evsel *evsel = NULL; struct bpf_map *map; int err; bool need_init = false; @@ -1602,7 +1602,7 @@ struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const cha int bpf__setup_stdout(struct perf_evlist *evlist) { - struct perf_evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); + struct evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); return PTR_ERR_OR_ZERO(evsel); } -- cgit v1.2.1 From 63503dba87acfab49280d3b05df6705a6f327e8a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 21 Jul 2019 13:23:52 +0200 Subject: perf evlist: Rename struct perf_evlist to struct evlist Rename struct perf_evlist to struct evlist, so we don't have a name clash when we add struct perf_evlist in libperf. Committer notes: Added fixes to build on arm64, from Jiri and from me (tools/perf/util/cs-etm.c) Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-6-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 594ea279e25b..b0696726ab76 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1043,7 +1043,7 @@ __bpf_map__config_value(struct bpf_map *map, static int bpf_map__config_value(struct bpf_map *map, struct parse_events_term *term, - struct perf_evlist *evlist __maybe_unused) + struct evlist *evlist __maybe_unused) { if (!term->err_val) { pr_debug("Config value not set\n"); @@ -1061,7 +1061,7 @@ bpf_map__config_value(struct bpf_map *map, static int __bpf_map__config_event(struct bpf_map *map, struct parse_events_term *term, - struct perf_evlist *evlist) + struct evlist *evlist) { struct evsel *evsel; const struct bpf_map_def *def; @@ -1103,7 +1103,7 @@ __bpf_map__config_event(struct bpf_map *map, static int bpf_map__config_event(struct bpf_map *map, struct parse_events_term *term, - struct perf_evlist *evlist) + struct evlist *evlist) { if (!term->err_val) { pr_debug("Config value not set\n"); @@ -1121,7 +1121,7 @@ bpf_map__config_event(struct bpf_map *map, struct bpf_obj_config__map_func { const char *config_opt; int (*config_func)(struct bpf_map *, struct parse_events_term *, - struct perf_evlist *); + struct evlist *); }; struct bpf_obj_config__map_func bpf_obj_config__map_funcs[] = { @@ -1169,7 +1169,7 @@ config_map_indices_range_check(struct parse_events_term *term, static int bpf__obj_config_map(struct bpf_object *obj, struct parse_events_term *term, - struct perf_evlist *evlist, + struct evlist *evlist, int *key_scan_pos) { /* key is "map:." */ @@ -1228,7 +1228,7 @@ out: int bpf__config_obj(struct bpf_object *obj, struct parse_events_term *term, - struct perf_evlist *evlist, + struct evlist *evlist, int *error_pos) { int key_scan_pos = 0; @@ -1523,7 +1523,7 @@ int bpf__apply_obj_config(void) (strcmp(name, \ bpf_map__name(pos)) == 0)) -struct evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name) +struct evsel *bpf__setup_output_event(struct evlist *evlist, const char *name) { struct bpf_map_priv *tmpl_priv = NULL; struct bpf_object *obj, *tmp; @@ -1600,7 +1600,7 @@ struct evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *na return evsel; } -int bpf__setup_stdout(struct perf_evlist *evlist) +int bpf__setup_stdout(struct evlist *evlist) { struct evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); return PTR_ERR_OR_ZERO(evsel); @@ -1756,7 +1756,7 @@ int bpf__strerror_load(struct bpf_object *obj, int bpf__strerror_config_obj(struct bpf_object *obj __maybe_unused, struct parse_events_term *term __maybe_unused, - struct perf_evlist *evlist __maybe_unused, + struct evlist *evlist __maybe_unused, int *error_pos __maybe_unused, int err, char *buf, size_t size) { @@ -1780,7 +1780,7 @@ int bpf__strerror_apply_obj_config(int err, char *buf, size_t size) return 0; } -int bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused, +int bpf__strerror_setup_output_event(struct evlist *evlist __maybe_unused, int err, char *buf, size_t size) { bpf__strerror_head(err, buf, size); -- cgit v1.2.1 From 1fc632cef4ea137bc45fd0fc4cb902e374064163 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 21 Jul 2019 13:24:29 +0200 Subject: libperf: Move perf_event_attr field from perf's evsel to libperf's perf_evsel Move the perf_event_attr struct fron 'struct evsel' to 'struct perf_evsel'. Committer notes: Fixed up these: tools/perf/arch/arm/util/auxtrace.c tools/perf/arch/arm/util/cs-etm.c tools/perf/arch/arm64/util/arm-spe.c tools/perf/arch/s390/util/auxtrace.c tools/perf/util/cs-etm.c Also cc1: warnings being treated as errors tests/sample-parsing.c: In function 'do_test': tests/sample-parsing.c:162: error: missing initializer tests/sample-parsing.c:162: error: (near initialization for 'evsel.core.cpus') struct evsel evsel = { .needs_swap = false, - .core.attr = { - .sample_type = sample_type, - .read_format = read_format, + .core = { + . attr = { + .sample_type = sample_type, + .read_format = read_format, + }, [perfbuilder@a70e4eeb5549 /]$ gcc --version |& head -1 gcc (GCC) 4.4.7 Also we don't need to include perf_event.h in tools/perf/lib/include/perf/evsel.h, forward declaring 'struct perf_event_attr' is enough. And this even fixes the build in some systems where things are used somewhere down the include path from perf_event.h without defining __always_inline. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-43-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index b0696726ab76..4df8bdea14ac 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1421,7 +1421,7 @@ apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, return -BPF_LOADER_ERRNO__OBJCONF_MAP_EVTDIM; } - attr = &evsel->attr; + attr = &evsel->core.attr; if (attr->inherit) { pr_debug("ERROR: Can't put inherit event into map %s\n", name); return -BPF_LOADER_ERRNO__OBJCONF_MAP_EVTINH; -- cgit v1.2.1 From 9dfcb7599084382884fec6d0fd9ca33945fa7578 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 21 Jul 2019 13:24:45 +0200 Subject: libperf: Move fd array from perf's evsel to lobperf's perf_evsel class Move the fd array from perf's evsel to libperf's perf_evsel class. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-59-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 4df8bdea14ac..9c219d413e57 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1403,7 +1403,7 @@ static int apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, struct evsel *evsel) { - struct xyarray *xy = evsel->fd; + struct xyarray *xy = evsel->core.fd; struct perf_event_attr *attr; unsigned int key, events; bool check_pass = false; -- cgit v1.2.1 From 964f384989585bc265fd929b2a7977b83fbe4c3b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 21 Aug 2019 11:57:50 -0300 Subject: perf bpf: Add missing xyarray.h header This was being obtained indirectly via evsel.h -> counts.h, since we don't need xyarray in counts.h, we need to add it here explicitely before removing it from counts.h. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-jirmxg527i82yz31bwad9we7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 9c219d413e57..e20d7c5e1925 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -26,6 +26,8 @@ #include "llvm-utils.h" #include "c++/clang-c.h" +#include + static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)), const char *fmt, va_list args) { -- cgit v1.2.1 From 630aec1a7fd60ac355d5f2d67b5454912c5971a6 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 28 Aug 2019 09:59:10 -0300 Subject: perf clang: Delete needless util-cxx.h header It was put in place just to make sure the 'new' C++ operator wouldn't clash with some argument name in util.h, but there is not anymore any such argument and also the reason stated for util.h to be included there was to get the __maybe_unused definition, that is in linux/compiler.h, so use that instead and nuke util-cxx.h. Cc: Adrian Hunter Cc: He Kuang Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-1r5tvfnwiydjxhukgqs6bi11@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index e20d7c5e1925..80a828e75cf6 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -23,6 +23,7 @@ #include "probe-finder.h" // for MAX_PROBES #include "parse-events.h" #include "strfilter.h" +#include "util.h" #include "llvm-utils.h" #include "c++/clang-c.h" -- cgit v1.2.1 From 0ac25fd0a04d8bd52ceac2476e71a4e497489987 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 15:42:40 -0300 Subject: perf tools: Remove perf.h from source files not needing it With the movement of lots of stuff out of perf.h to other headers we ended up not needing it in lots of places, remove it from those places. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-c718m0sxxwp73lp9d8vpihb4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 1 - 1 file changed, 1 deletion(-) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 80a828e75cf6..c1a57323e25d 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -14,7 +14,6 @@ #include #include #include -#include "perf.h" #include "debug.h" #include "evlist.h" #include "bpf-loader.h" -- cgit v1.2.1 From f2a39fe84901df2b3d1bec3459b65cee3e8db57c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 14:45:20 -0300 Subject: perf auxtrace: Uninline functions that touch perf_session So that we don't carry the session.h include directive in auxtrace.h, which in turn opens a can of worms of files that were getting all sorts of things via that include, fix them all. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-d2d83aovpgri2z75wlitquni@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util/bpf-loader.c') diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index c1a57323e25d..37283e865352 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "debug.h" #include "evlist.h" #include "bpf-loader.h" -- cgit v1.2.1