summaryrefslogtreecommitdiff
path: root/tools/perf/Makefile.perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-05-04 11:56:15 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-05-15 14:31:23 -0300
commit8f12a2ff00e5e48ad5618167bac72cad7c9f214e (patch)
treed5fcf9867fece8d62e7b29c9f408868ee93d748e /tools/perf/Makefile.perf
parent1b16fffa389dcd4cc054f49e77a4e2ac61e8f287 (diff)
perf bpf: Add 'examples' directories
The first one is the bare minimum that bpf infrastructure accepts before it expects actual events to be set up: $ cat tools/perf/examples/bpf/empty.c char _license[] __attribute__((section("license"), used)) = "GPL"; int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE; $ If you remove that "version" line, then it will be refused with: # perf trace -e tools/perf/examples/bpf/empty.c event syntax error: 'tools/perf/examples/bpf/empty.c' \___ Failed to load tools/perf/examples/bpf/empty.c from source: 'version' section incorrect or lost (add -v to see detail) Run 'perf list' for a list of valid events Usage: perf trace [<options>] [<command>] or: perf trace [<options>] -- <command> [<options>] or: perf trace record [<options>] [<command>] or: perf trace record [<options>] -- <command> [<options>] -e, --event <event> event/syscall selector. use 'perf list' to list available events # The next ones will, step by step, show simple filters, then the needs for headers will be made clear, it will be put in place and tested with new examples, rinse, repeat. Back to using this first one to test the perf+bpf infrastructure: If we run it will fail, as no functions are present connecting with, say, a tracepoint or a function using the kprobes or uprobes infrastructure: # perf trace -e tools/perf/examples/bpf/empty.c WARNING: event parser found nothing invalid or unsupported event: 'tools/perf/examples/bpf/empty.c' Run 'perf list' for a list of valid events Usage: perf trace [<options>] [<command>] or: perf trace [<options>] -- <command> [<options>] or: perf trace record [<options>] [<command>] or: perf trace record [<options>] -- <command> [<options>] -e, --event <event> event/syscall selector. use 'perf list' to list available events # But, if we set things up to dump the generated object file to a file, and do this after having run 'make install', still on the developer's $HOME directory: # cat ~/.perfconfig [llvm] dump-obj = true # # perf trace -e ~acme/lib/examples/perf/bpf/empty.c LLVM: dumping /home/acme/lib/examples/perf/bpf/empty.o WARNING: event parser found nothing invalid or unsupported event: '/home/acme/lib/examples/perf/bpf/empty.c' <SNIP> # We can look at the dumped object file: # ls -la ~acme/lib/examples/perf/bpf/empty.o -rw-r--r--. 1 root root 576 May 4 12:10 /home/acme/lib/examples/perf/bpf/empty.o # file ~acme/lib/examples/perf/bpf/empty.o /home/acme/lib/examples/perf/bpf/empty.o: ELF 64-bit LSB relocatable, *unknown arch 0xf7* version 1 (SYSV), not stripped # readelf -sw ~acme/lib/examples/perf/bpf/empty.o Symbol table '.symtab' contains 3 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 3 _license 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 4 _version # # tools/bpf/bpftool/bpftool --pretty ~acme/lib/examples/perf/bpf/empty.o null # Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-y7dkhakejz3013o0w21n98xd@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/Makefile.perf')
-rw-r--r--tools/perf/Makefile.perf3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d9663b1cf43e..9343b7d945bb 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -770,6 +770,9 @@ endif
ifndef NO_LIBBPF
$(call QUIET_INSTALL, lib) \
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'
+ $(call QUIET_INSTALL, lib) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
+ $(INSTALL) examples/bpf/*.c '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
endif
$(call QUIET_INSTALL, perf-archive) \
$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'