perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
This one gets us to pass .c files that gets built and
loaded, next step will be to be able to access function arguments, for which there are patches available, but I'm still reviewing them.
Please consider pulling,
- Arnaldo
The following changes since commit 66a565c203bc31b76969711fbd92da11bee2f129:
Merge tag 'perf-ebpf-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-10-29 13:17:56 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
for you to fetch changes up to 7ed4915ad60788d6b846e2cd034f49ee15698143:
perf unwind: Pass symbol source to libunwind (2015-10-29 17:48:38 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
New features:
- Allow passing C language eBPF scriptlets via --event in all tools, so that it gets built using clang and then pass it to the kernel via sys_bpf() (Wang Nan)
- Wire up the loaded ebpf object file with associated kprobes, so that it can determine if the kprobes will be filtered or not (Wang Nan)
User visible:
- Add cmd string table to decode sys_bpf first arg in 'trace' (Arnaldo Carvalho de Melo)
- Enable printing of branch stack in 'perf script' (Stephane Eranian)
- Pass the right file with debug info to libunwind (Rabin Vincent)
Build Fixes:
- Make sure fixdep is built before libbpf, fixing a race (Jiri Olsa)
- Fix libiberty feature detection (Rabin Vincent)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf trace: Add cmd string table to decode sys_bpf first arg
Jiri Olsa (1):
perf tools: Make sure fixdep is built before libbpf
Rabin Vincent (2):
tools build: Fix libiberty feature detection perf unwind: Pass symbol source to libunwind
Stephane Eranian (1):
perf script: Enable printing of branch stack
Wang Nan (3):
perf bpf: Attach eBPF filter to perf event
perf record: Add clang options for compiling BPF scripts
perf tools: Compile scriptlets to BPF objects when passing '.c' to --event
tools/build/feature/Makefile | 4 +- tools/perf/Documentation/perf-record.txt | 6 +++ tools/perf/Documentation/perf-script.txt | 14 +++++- tools/perf/Makefile.perf | 2 +- tools/perf/builtin-record.c | 7 +++ tools/perf/builtin-script.c | 82 +++++++++++++++++++++++++++++++- tools/perf/builtin-trace.c | 7 +++ tools/perf/tests/bpf-script-example.c | 44 +++++++++++++++++ tools/perf/util/bpf-loader.c | 17 ++++++- tools/perf/util/bpf-loader.h | 5 +- tools/perf/util/evsel.c | 17 +++++++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 11 ++++- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.l | 3 ++ tools/perf/util/parse-events.y | 15 +++++- tools/perf/util/unwind-libunwind.c | 5 +- 17 files changed, 227 insertions(+), 16 deletions(-) create mode 100644 tools/perf/tests/bpf-script-example.c
Arnaldo Carvalho de Melo
maintainerPATCH 1/8 perf trace: Add cmd string table to decode sys_bpf first arg
From: Arnaldo Carvalho de Melo <[email protected]>
# perf trace -e bpf perf record -e /tmp/foo.o -a 362.779 (0.130 ms): perf/3451 bpf(cmd: PROG_LOAD, uattr: 0x7ffe9a6825d0, size: 48) = 3
--- tools/perf/builtin-trace.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/builtin-trace.c +7 -0
@@ -585,6 +585,12 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op +static const char *bpf_cmd[] = { +"MAP_CREATE" ,"MAP_LOOKUP_ELEM" ,"MAP_UPDATE_ELEM" ,"MAP_DELETE_ELEM" , +"MAP_GET_NEXT_KEY" ,"PROG_LOAD" , +}; +static DEFINE_STRARRAY (bpf_cmd); +static const char *epoll_ctl_ops[] = {"ADD" ,"DEL" ,"MOD" , }; static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, 1);
@@ -1011,6 +1017,7 @@ static struct syscall_fmt { .arg_scnprintf = { [0] = SCA_FILENAME, /* filename */ [1] = SCA_ACCMODE, /* mode */ }, }, { .name = "arch_prctl", .errmsg = true, .alias = "prctl", }, + { .name = "bpf", .errmsg = true, STRARRAY(0, cmd, bpf_cmd), }, { .name = "brk", .hexret = true, .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, }, { .name = "chdir", .errmsg = true,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 2/8 perf script: Enable printing of branch stack
In reply to Arnaldo Carvalho de MeloFrom: Stephane Eranian <[email protected]>
This patch improves perf script by enabling printing of the branch stack via the 'brstack' and 'brstacksym' arguments to the field selection option -F. The option is off by default and operates only if the perf.data file has branch stack content.
The branches are printed in to/from pairs. The most recent branch is printed first. The number of branch entries vary based on the underlying hardware and filtering used.
The brstack prints FROM/TO addresses in raw hexadecimal format. The brstacksym prints FROM/TO addresses in symbolic form wherever possible.
$ perf script -F ip,brstack 5d3000 0x401aa0/0x5d2000/M/-/-/-/0 ...
$ perf script -F ip,brstacksym 4011e0 noploop+0x0/noploop+0x0/P/-/-/0
The notation F/T/M/X/A/C describes the attributes of the branch. F=from, T=to, M/P=misprediction/prediction, X=TSX, A=TSX abort, C=cycles (SKL)
--- tools/perf/Documentation/perf-script.txt | 14 +++++- tools/perf/builtin-script.c | 82 +++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-script.txt +12 -2
@@ -112,11 +112,11 @@ OPTIONS --debug-mode:: Do various checks like samples ordering and lost events. --f:: +-F:: --fields:: Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, - srcline, period, iregs, flags. + srcline, period, iregs, brstack, brstacksym, flags. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
@@ -175,6 +175,16 @@ OPTIONS Finally, a user may not set fields to none for all event types. i.e., -f "" is not allowed. + The brstack output includes branch related information with raw addresses using the + /v/v/v/v/ syntax in the following order: + FROM: branch source instruction + TO : branch target instruction + M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported + X/- : X=branch inside a transactional region, -=not in transaction region or not supported + A/- : A=TSX abort entry, -=not aborted region or not supported + + The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible. + -k:: --vmlinux=<file>:: vmlinux pathname
tools/perf/builtin-script.c +81 -1
112 lines not on this page · raw message
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 3/8 perf tools: Make sure fixdep is built before libbpf
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
While doing 'make -C tools/perf build-test':
LD fixdep-in.o
LINK fixdep
/bin/sh: /home/acme/git/linux/tools/build/fixdep: Permission denied make[6]: *** [bpf.o] Error 1
make[5]: *** [libbpf-in.o] Error 2
make[4]: *** [/home/acme/git/linux/tools/lib/bpf/libbpf.a] Error 2 make[4]: *** Waiting for unfinished jobs....
The fixdep tool needs to be built as the first binary. Libraries are built in paralel, so each of them needs to depend on fixdep target.
--- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
@@ -430,7 +430,7 @@ $(LIBAPI)-clean: $(call QUIET_CLEAN, libapi) $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null -$(LIBBPF): FORCE +$(LIBBPF): fixdep FORCE $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a $(LIBBPF)-clean:
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 4/8 perf bpf: Attach eBPF filter to perf event
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
This is the final patch which makes basic BPF filter work. After applying this patch, users are allowed to use BPF filter like:
# perf record --event ./hello_world.o ls
A bpf_fd field is appended to 'struct evsel', and setup during the callback function add_bpf_event() for each 'probe_trace_event'.
PERF_EVENT_IOC_SET_BPF ioctl is used to attach eBPF program to a newly created perf event. The file descriptor of the eBPF program is passed to perf record using previous patches, and stored into evsel->bpf_fd.
It is possible that different perf event are created for one kprobe events for different CPUs. In this case, when trying to call the ioctl, EEXIST will be return. This patch doesn't treat it as an error.
Committer note:
The bpf proggie used so far:
__attribute__((section("fork=_do_fork"), used))
int fork(void *ctx)
{
return 0;}
char _license[] __attribute__((section("license"), used)) = "GPL";
int _version __attribute__((section("version"), used)) = 0x40300;failed to produce any samples, even with forks happening and it being running in system wide mode.
That is because now the filter is being associated, and the code above always returns zero, meaning that all forks will be probed but filtered away ;-/
Change it to 'return 1;' instead and after that:
# trace --no-syscalls --event /tmp/foo.o
0.000 perf_bpf_probe:fork:(ffffffff8109be30))
2.333 perf_bpf_probe:fork:(ffffffff8109be30))
3.725 perf_bpf_probe:fork:(ffffffff8109be30))
4.550 perf_bpf_probe:fork:(ffffffff8109be30))
^C#And it works with all tools, including 'perf trace'.
--- tools/perf/util/evsel.c | 17 +++++++++++++++++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 6 ++++++ 3 files changed, 24 insertions(+)
tools/perf/util/evsel.c +17 -0
@@ -208,6 +208,7 @@ void perf_evsel__init(struct perf_evsel *evsel, evsel->unit ="" ; evsel->scale =1.0 ; evsel->evlist =NULL ; + evsel->bpf_fd =-1 ;INIT_LIST_HEAD (&evsel->node);INIT_LIST_HEAD (&evsel->config_terms); perf_evsel__object.init (evsel);
@@ -1356,6 +1357,22 @@ retry_open: err); goto try_fallback; } + +if (evsel->bpf_fd >=0 ) { +int evt_fd =FD (evsel, cpu, thread); +int bpf_fd = evsel->bpf_fd; + + err =ioctl (evt_fd, +PERF_EVENT_IOC_SET_BPF , + bpf_fd); +if (err && errno !=EEXIST ) { +pr_err ("failed to attach bpf fd %d: %s\n" , + bpf_fd,strerror (errno)); + err = -EINVAL ; + goto out_close; + } + } + set_rlimit =NO_CHANGE ;/*
tools/perf/util/evsel.h +1 -0
@@ -123,6 +123,7 @@ struct perf_evsel {char *group_name;bool cmdline_group_boundary;struct list_head config_terms; +int bpf_fd; };union u64_swap {
tools/perf/util/parse-events.c +6 -0
@@ -542,6 +542,7 @@ static int add_bpf_event(struct probe_trace_event *tev, int fd,struct __add_bpf_event_param *param = _param;struct parse_events_evlist *evlist = param->data;struct list_head *list = param->list; +struct perf_evsel *pos;int err; pr_debug("add bpf event %s:%s and attach bpf program %d\n",
@@ -562,6 +563,11 @@ static int add_bpf_event(struct probe_trace_event *tev, int fd, }pr_debug ("adding %s:%s\n" , tev->group, tev->event); +list_for_each_entry (pos, &new_evsels, node) { +pr_debug ("adding %s:%s to %p\n" , + tev->group, tev->event, pos); + pos->bpf_fd = fd; + }list_splice (&new_evsels, list);return 0 ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 5/8 perf record: Add clang options for compiling BPF scripts
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Although previous patch allows setting BPF compiler related options in perfconfig, on some ad-hoc situation it still requires passing options through cmdline. This patch introduces 2 options to 'perf record' for this propose: --clang-path and --clang-opt.
--- tools/perf/Documentation/perf-record.txt | 6 ++++++ tools/perf/builtin-record.c | 7 +++++++ 2 files changed, 13 insertions(+)
tools/perf/Documentation/perf-record.txt +6 -0
@@ -314,6 +314,12 @@ This option sets the time out limit. The default value is 500 ms. Record context switch events i.e. events of type PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE. +--clang-path:: +Path to clang binary to use for compiling BPF scriptlets. + +--clang-opt:: +Options passed to clang when compiling BPF scriptlets. + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +7 -0
@@ -31,6 +31,7 @@#include "util/auxtrace.h" #include "util/parse-branch-options.h" #include "util/parse-regs-options.h" +#include "util/llvm-utils.h" #include <unistd.h> #include <sched.h>
@@ -1112,6 +1113,12 @@ struct option __record_options[] = { "per thread proc mmap processing timeout in ms"),OPT_BOOLEAN (0 ,"switch-events" , &record.opts.record_switch_events,"Record context switch events" ), +#ifdef HAVE_LIBBPF_SUPPORT +OPT_STRING (0 ,"clang-path" , &llvm_param.clang_path,"clang path" , +"clang binary to use for compiling BPF scriptlets" ), +OPT_STRING (0 ,"clang-opt" , &llvm_param.clang_opt,"clang options" , +"options passed to clang when compiling BPF scriptlets" ), +#endif OPT_END() };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 6/8 perf tools: Compile scriptlets to BPF objects when passing '.c' to --event
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
This patch provides infrastructure for passing source files to --event directly using:
# perf record --event bpf-file.c command
This patch does following works:
1) Allow passing '.c' file to '--event'. parse_events_load_bpf() is expanded to allow caller tell it whether the passed file is source file or object.
2) llvm__compile_bpf() is called to compile the '.c' file, the result is saved into memory. Use bpf_object__open_buffer() to load the in-memory object.
Introduces a bpf-script-example.c so we can manually test it:
# perf record --clang-opt "-DLINUX_VERSION_CODE=0x40200" --event ./bpf-script-example.c sleep 1
Note that '--clang-opt' must put before '--event'.
Futher patches will merge it into a testcase so can be tested automatically.
--- tools/perf/tests/bpf-script-example.c | 44 +++++++++++++++++++++++++++++++++++ tools/perf/util/bpf-loader.c | 17 ++++++++++++-- tools/perf/util/bpf-loader.h | 5 ++-- tools/perf/util/parse-events.c | 5 ++-- tools/perf/util/parse-events.h | 3 ++- tools/perf/util/parse-events.l | 3 +++ tools/perf/util/parse-events.y | 15 ++++++++++-- 7 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 tools/perf/tests/bpf-script-example.c
tools/perf/tests/bpf-script-example.c new file +44 -0
@@ -0,0 +1,44 @@ +#ifndef LINUX_VERSION_CODE +# error Need LINUX_VERSION_CODE +# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' +#endif +#define BPF_ANY 0 +#define BPF_MAP_TYPE_ARRAY 2 +#define BPF_FUNC_map_lookup_elem 1 +#define BPF_FUNC_map_update_elem 2 + +static void *(*bpf_map_lookup_elem)(void *map,void *key) = + (void *) BPF_FUNC_map_lookup_elem; +static void *(*bpf_map_update_elem)(void *map,void *key,void *value,int flags) = + (void *) BPF_FUNC_map_update_elem; + +struct bpf_map_def { +unsigned int type; +unsigned int key_size; +unsigned int value_size; +unsigned int max_entries; +}; + +#define SEC (NAME ) __attribute__((section(NAME), used)) +struct bpf_map_def SEC("maps") flip_table = { + .type = BPF_MAP_TYPE_ARRAY, + .key_size = sizeof(int), + .value_size = sizeof(int), + .max_entries = 1, +}; + +SEC("func=sys_epoll_pwait") +int bpf_func__sys_epoll_pwait (void *ctx) +{ +int ind =0 ; +int *flag =bpf_map_lookup_elem (&flip_table, &ind); +int new_flag; +if (!flag) +return 0 ; +/* flip flag and store back */ + new_flag = !*flag; +bpf_map_update_elem (&flip_table, &ind, &new_flag,BPF_ANY ); +return new_flag; +} +char _license[] SEC("license") = "GPL"; +int _version SEC("version") = LINUX_VERSION_CODE;
tools/perf/util/bpf-loader.c +15 -2
@@ -12,6 +12,7 @@#include "bpf-loader.h" #include "probe-event.h" #include "probe-finder.h" // for MAX_PROBES +#include "llvm-utils.h" #define DEFINE_PRINT_FN (name, level) \ static int libbpf_##name(const char *fmt, ...) \
@@ -33,7 +34,7 @@ struct bpf_prog_priv {struct perf_probe_event pev; }; -struct bpf_object *bpf__prepare_load (const char *filename) +struct bpf_object *bpf__prepare_load (const char *filename,bool source) {struct bpf_object *obj;static bool libbpf_initialized;
@@ -45,7 +46,19 @@ struct bpf_object *bpf__prepare_load(const char *filename) libbpf_initialized = true; } - obj =bpf_object__open (filename); +if (source) { +int err; +void *obj_buf; +size_t obj_buf_sz; + + err =llvm__compile_bpf (filename, &obj_buf, &obj_buf_sz); +if (err) +return ERR_PTR (err); + obj =bpf_object__open_buffer (obj_buf, obj_buf_sz, filename); +free (obj_buf); + }else + obj =bpf_object__open (filename); +if (!obj) {pr_debug ("bpf: failed to load %s\n" , filename);return ERR_PTR (-EINVAL );
tools/perf/util/bpf-loader.h +3 -2
@@ -18,7 +18,7 @@ typedef int (*bpf_prog_iter_callback_t)(struct probe_trace_event *tev, int fd, void *arg);#ifdef HAVE_LIBBPF_SUPPORT -struct bpf_object *bpf__prepare_load (const char *filename); +struct bpf_object *bpf__prepare_load (const char *filename,bool source);void bpf__clear (void );
@@ -34,7 +34,8 @@ int bpf__foreach_tev(struct bpf_object *obj, bpf_prog_iter_callback_t func, void *arg);#else static inline struct bpf_object * -bpf__prepare_load (const char *filename__maybe_unused ) +bpf__prepare_load (const char *filename__maybe_unused , +bool source__maybe_unused ) {pr_debug ("ERROR: eBPF object loading is disabled during compiling.\n" );return ERR_PTR (-ENOTSUP );
tools/perf/util/parse-events.c +3 -2
@@ -626,11 +626,12 @@ errout:int parse_events_load_bpf (struct parse_events_evlist *data,struct list_head *list, -char *bpf_file_name) +char *bpf_file_name, +bool source) {struct bpf_object *obj; - obj =bpf__prepare_load (bpf_file_name); + obj =bpf__prepare_load (bpf_file_name, source);if (IS_ERR (obj) || !obj) {char errbuf[BUFSIZ ];int err;
tools/perf/util/parse-events.h +2 -1
@@ -125,7 +125,8 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx, struct list_head *head_config);int parse_events_load_bpf (struct parse_events_evlist *data,struct list_head *list, -char *bpf_file_name); +char *bpf_file_name, +bool source);/* Provide this function for perf test */ struct bpf_object ; int parse_events_load_bpf_obj(struct parse_events_evlist *data,
tools/perf/util/parse-events.l +3 -0
@@ -116,6 +116,7 @@ group [^,{}/]*[{][^}]*[}][^,{}/]* event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* event [^,{}/]+ bpf_object .*\.(o|bpf) +bpf_source .*\.c num_dec [0-9]+ num_hex 0x[a-fA-F0-9]+
@@ -161,6 +162,7 @@ modifier_bp [rwx]{1,3} {event_pmu} | {bpf_object} | +{bpf_source} | {event} { BEGIN(INITIAL); REWIND(1);
@@ -269,6 +271,7 @@ r{num_raw_hex} { return raw(yyscanner); } {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } {bpf_object} { return str(yyscanner, PE_BPF_OBJECT); } +{bpf_source} { return str(yyscanner, PE_BPF_SOURCE); } {name} { return pmu_str_check(yyscanner); } "/" { BEGIN(config); return '/'; } - { return '-'; }
tools/perf/util/parse-events.y +13 -2
@@ -42,7 +42,7 @@ static inc_group_count(struct list_head *list, %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM %token PE_EVENT_NAME %token PE_NAME -%token PE_BPF_OBJECT +%token PE_BPF_OBJECT PE_BPF_SOURCE %token PE_MODIFIER_EVENT PE_MODIFIER_BP %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
@@ -55,6 +55,7 @@ static inc_group_count(struct list_head *list, %type <num> PE_TERM %type <str> PE_NAME %type <str> PE_BPF_OBJECT +%type <str> PE_BPF_SOURCE %type <str> PE_NAME_CACHE_TYPE %type <str> PE_NAME_CACHE_OP_RESULT %type <str> PE_MODIFIER_EVENT
@@ -461,7 +462,17 @@ PE_BPF_OBJECT struct list_head *list; ALLOC_LIST(list); - ABORT_ON(parse_events_load_bpf(data, list, $1)); + ABORT_ON(parse_events_load_bpf(data, list, $1, false)); + $$ = list; +} +| +PE_BPF_SOURCE +{ + struct parse_events_evlist *data = _data; + struct list_head *list; + + ALLOC_LIST(list); + ABORT_ON(parse_events_load_bpf(data, list, $1, true)); $$ = list; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 7/8 tools build: Fix libiberty feature detection
In reply to Arnaldo Carvalho de MeloFrom: Rabin Vincent <[email protected]>
Any CFLAGS or LDFLAGS set by the user need to be passed to the feature build command. This many include for example -I or -L to point to libraries and include files in custom paths.
In most of the test-*.bin rules in build/feature/Makefile, we use the BUILD macro which always sends in CFLAGS and LDFLAGS. The libiberty build line however doesn't use the BUILD macro and thus needs to send in CFLAGS and LDFLAGS explicitly. Without this, when using custom CFLAGS/LDFLAGS, libiberty fails to be detected and the perf link fails with something like:
LINK perf
libbfd.a(bfd.o): In function `bfd_errmsg':
bfd.c:(.text+0x168): undefined reference to xstrerror' bbfd.a(opncls.o): In function _bfd_new_bfd':
opncls.c:(.text+0xe8): undefined reference to `objalloc_create'
...
--- tools/build/feature/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +2 -2
@@ -132,10 +132,10 @@ test-libbfd.bin: $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl test-liberty.bin: - $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty + $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty test-liberty-z.bin: - $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz + $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz test-cplus-demangle.bin: $(BUILD) -liberty
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 8/8 perf unwind: Pass symbol source to libunwind
In reply to Arnaldo Carvalho de MeloFrom: Rabin Vincent <[email protected]>
Even if --symfs is used to point to the debug binaries, we send in the non-debug filenames to libunwind, which leads to libunwind not finding the debug frame. Fix this by preferring the file in --symfs, if it is available.
--- tools/perf/util/unwind-libunwind.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/unwind-libunwind.c +4 -1
@@ -360,12 +360,15 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,int fd =dso__data_get_fd (map->dso, ui->machine);int is_exec =elf_is_exec (fd, map->dso->name);unw_word_t base = is_exec ?0 : map->start; +const char *symfile;if (fd >=0 )dso__data_put_fd (map->dso); + symfile = map->dso->symsrc_filename ?: map->dso->name; +memset (&di,0 ,sizeof (di)); -if (dwarf_find_debug_frame (0 , &di, ip, base, map->dso->name, +if (dwarf_find_debug_frame (0 , &di, ip, base, symfile, map->start, map->end))return dwarf_search_unwind_table (as, ip, &di, pi, need_unwind_info, arg);
Signature · 1 line
2.1.0
Quoted 80 lines · Arnaldo Carvalho de Melo
Hi Ingo,
This one gets us to pass .c files that gets built and
loaded, next step will be to be able to access function arguments, for which there are patches available, but I'm still reviewing them.Please consider pulling,
- Arnaldo
The following changes since commit
66a565c203bc31b76969711fbd92da11bee2f129:Merge tag 'perf-ebpf-for-mingo' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2015-10-29 13:17:56 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingofor you to fetch changes up to
7ed4915ad60788d6b846e2cd034f49ee15698143:perf unwind: Pass symbol source to libunwind (2015-10-29 17:48:38 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:New features:
- Allow passing C language eBPF scriptlets via --event in all tools, so that it gets built using clang and then pass it to the kernel via
sys_bpf()(Wang Nan)- Wire up the loaded ebpf object file with associated kprobes, so that it can determine if the kprobes will be filtered or not (Wang Nan)
User visible:
- Add cmd string table to decode
sys_bpffirst arg in 'trace' (Arnaldo Carvalho de Melo)- Enable printing of branch stack in 'perf script' (Stephane Eranian)
- Pass the right file with debug info to libunwind (Rabin Vincent)
Build Fixes:
- Make sure fixdep is built before libbpf, fixing a race (Jiri Olsa)
- Fix libiberty feature detection (Rabin Vincent)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf trace: Add cmd string table to decodesys_bpffirst argJiri Olsa (1):
perf tools: Make sure fixdep is built before libbpfRabin Vincent (2):
tools build: Fix libiberty feature detection perf unwind: Pass symbol source to libunwindStephane Eranian (1):
perf script: Enable printing of branch stackWang Nan (3):
perf bpf: Attach eBPF filter to perf event
perf record: Add clang options for compiling BPF scripts
perf tools: Compile scriptlets to BPF objects when passing '.c' to --eventtools/build/feature/Makefile | 4 +- tools/perf/Documentation/perf-record.txt | 6 +++ tools/perf/Documentation/perf-script.txt | 14 +++++- tools/perf/Makefile.perf | 2 +- tools/perf/builtin-record.c | 7 +++ tools/perf/builtin-script.c | 82 +++++++++++++++++++++++++++++++- tools/perf/builtin-trace.c | 7 +++ tools/perf/tests/bpf-script-example.c | 44 +++++++++++++++++ tools/perf/util/bpf-loader.c | 17 ++++++- tools/perf/util/bpf-loader.h | 5 +- tools/perf/util/evsel.c | 17 +++++++
Quoted 8 lines
tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 11 ++++- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.l | 3 ++ tools/perf/util/parse-events.y | 15 +++++- tools/perf/util/unwind-libunwind.c | 5 +- 17 files changed, 227 insertions(+), 16 deletions(-) create mode 100644 tools/perf/tests/bpf-script-example.c
Pulled, thanks a lot Arnaldo!
Ingo