diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-10-14 08:41:12 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-10-28 11:48:12 -0400 |
commit | ed63f34c026e9a60d17fa750ecdfe3f600d49393 (patch) | |
tree | 1a6c9fab170c8a76b2b05904264f728c7bcc7621 /tools/perf | |
parent | 443f8c75e8d58d394b0e65b47e02e5cd8ed32b41 (diff) |
perf tools: Make perf depend on libbpf
By adding libbpf into perf's Makefile, this patch enables perf to build
libbpf if libelf is found and neither NO_LIBELF nor NO_LIBBPF is set.
The newly introduced code is similar to how libapi and libtraceevent
are wired into Makefile.perf.
MANIFEST is also updated for 'make perf-*-src-pkg'.
Append make_no_libbpf to tools/perf/tests/make.
The 'bpf' feature check is appended into default FEATURE_TESTS and
FEATURE_DISPLAY, so perf will check the API version of bpf in
/path/to/kernel/include/uapi/linux/bpf.h. Which should not fail except
when we are trying to port this code to an old kernel.
Error messages are also updated to notify users about the lack of BPF
support in 'perf record' if libelf is missing or the BPF API check
failed.
tools/lib/bpf is added to TAG_FOLDERS to allow us to navigate libbpf
files when working on perf using tools/perf/tags.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-2-git-send-email-wangnan0@huawei.com
[ Document NO_LIBBPF in Makefile.perf, noted by Jiri Olsa ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/MANIFEST | 3 | ||||
-rw-r--r-- | tools/perf/Makefile.perf | 21 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 19 | ||||
-rw-r--r-- | tools/perf/tests/make | 4 |
4 files changed, 43 insertions, 4 deletions
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 9e6bdf5b2df6..39c38cb45b00 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST | |||
@@ -17,6 +17,7 @@ tools/build | |||
17 | tools/arch/x86/include/asm/atomic.h | 17 | tools/arch/x86/include/asm/atomic.h |
18 | tools/arch/x86/include/asm/rmwcc.h | 18 | tools/arch/x86/include/asm/rmwcc.h |
19 | tools/lib/traceevent | 19 | tools/lib/traceevent |
20 | tools/lib/bpf | ||
20 | tools/lib/api | 21 | tools/lib/api |
21 | tools/lib/bpf | 22 | tools/lib/bpf |
22 | tools/lib/hweight.c | 23 | tools/lib/hweight.c |
@@ -69,6 +70,8 @@ arch/*/lib/memset*.S | |||
69 | include/linux/poison.h | 70 | include/linux/poison.h |
70 | include/linux/hw_breakpoint.h | 71 | include/linux/hw_breakpoint.h |
71 | include/uapi/linux/perf_event.h | 72 | include/uapi/linux/perf_event.h |
73 | include/uapi/linux/bpf.h | ||
74 | include/uapi/linux/bpf_common.h | ||
72 | include/uapi/linux/const.h | 75 | include/uapi/linux/const.h |
73 | include/uapi/linux/swab.h | 76 | include/uapi/linux/swab.h |
74 | include/uapi/linux/hw_breakpoint.h | 77 | include/uapi/linux/hw_breakpoint.h |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 56517d304772..1e2e2d1d26b7 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -75,6 +75,8 @@ include config/utilities.mak | |||
75 | # Define NO_LZMA if you do not want to support compressed (xz) kernel modules | 75 | # Define NO_LZMA if you do not want to support compressed (xz) kernel modules |
76 | # | 76 | # |
77 | # Define NO_AUXTRACE if you do not want AUX area tracing support | 77 | # Define NO_AUXTRACE if you do not want AUX area tracing support |
78 | # | ||
79 | # Define NO_LIBBPF if you do not want BPF support | ||
78 | 80 | ||
79 | # As per kernel Makefile, avoid funny character set dependencies | 81 | # As per kernel Makefile, avoid funny character set dependencies |
80 | unexport LC_ALL | 82 | unexport LC_ALL |
@@ -145,6 +147,7 @@ AWK = awk | |||
145 | 147 | ||
146 | LIB_DIR = $(srctree)/tools/lib/api/ | 148 | LIB_DIR = $(srctree)/tools/lib/api/ |
147 | TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ | 149 | TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ |
150 | BPF_DIR = $(srctree)/tools/lib/bpf/ | ||
148 | 151 | ||
149 | # include config/Makefile by default and rule out | 152 | # include config/Makefile by default and rule out |
150 | # non-config cases | 153 | # non-config cases |
@@ -180,6 +183,7 @@ strip-libs = $(filter-out -l%,$(1)) | |||
180 | 183 | ||
181 | ifneq ($(OUTPUT),) | 184 | ifneq ($(OUTPUT),) |
182 | TE_PATH=$(OUTPUT) | 185 | TE_PATH=$(OUTPUT) |
186 | BPF_PATH=$(OUTPUT) | ||
183 | ifneq ($(subdir),) | 187 | ifneq ($(subdir),) |
184 | LIB_PATH=$(OUTPUT)/../lib/api/ | 188 | LIB_PATH=$(OUTPUT)/../lib/api/ |
185 | else | 189 | else |
@@ -188,6 +192,7 @@ endif | |||
188 | else | 192 | else |
189 | TE_PATH=$(TRACE_EVENT_DIR) | 193 | TE_PATH=$(TRACE_EVENT_DIR) |
190 | LIB_PATH=$(LIB_DIR) | 194 | LIB_PATH=$(LIB_DIR) |
195 | BPF_PATH=$(BPF_DIR) | ||
191 | endif | 196 | endif |
192 | 197 | ||
193 | LIBTRACEEVENT = $(TE_PATH)libtraceevent.a | 198 | LIBTRACEEVENT = $(TE_PATH)libtraceevent.a |
@@ -199,6 +204,8 @@ LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYN | |||
199 | LIBAPI = $(LIB_PATH)libapi.a | 204 | LIBAPI = $(LIB_PATH)libapi.a |
200 | export LIBAPI | 205 | export LIBAPI |
201 | 206 | ||
207 | LIBBPF = $(BPF_PATH)libbpf.a | ||
208 | |||
202 | # python extension build directories | 209 | # python extension build directories |
203 | PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ | 210 | PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ |
204 | PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ | 211 | PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ |
@@ -251,6 +258,9 @@ export PERL_PATH | |||
251 | LIB_FILE=$(OUTPUT)libperf.a | 258 | LIB_FILE=$(OUTPUT)libperf.a |
252 | 259 | ||
253 | PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) | 260 | PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) |
261 | ifndef NO_LIBBPF | ||
262 | PERFLIBS += $(LIBBPF) | ||
263 | endif | ||
254 | 264 | ||
255 | # We choose to avoid "if .. else if .. else .. endif endif" | 265 | # We choose to avoid "if .. else if .. else .. endif endif" |
256 | # because maintaining the nesting to match is a pain. If | 266 | # because maintaining the nesting to match is a pain. If |
@@ -420,6 +430,13 @@ $(LIBAPI)-clean: | |||
420 | $(call QUIET_CLEAN, libapi) | 430 | $(call QUIET_CLEAN, libapi) |
421 | $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null | 431 | $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null |
422 | 432 | ||
433 | $(LIBBPF): FORCE | ||
434 | $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a | ||
435 | |||
436 | $(LIBBPF)-clean: | ||
437 | $(call QUIET_CLEAN, libbpf) | ||
438 | $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null | ||
439 | |||
423 | help: | 440 | help: |
424 | @echo 'Perf make targets:' | 441 | @echo 'Perf make targets:' |
425 | @echo ' doc - make *all* documentation (see below)' | 442 | @echo ' doc - make *all* documentation (see below)' |
@@ -459,7 +476,7 @@ INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html | |||
459 | $(DOC_TARGETS): | 476 | $(DOC_TARGETS): |
460 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) | 477 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) |
461 | 478 | ||
462 | TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include | 479 | TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include ../lib/bpf |
463 | TAG_FILES= ../../include/uapi/linux/perf_event.h | 480 | TAG_FILES= ../../include/uapi/linux/perf_event.h |
464 | 481 | ||
465 | TAGS: | 482 | TAGS: |
@@ -567,7 +584,7 @@ config-clean: | |||
567 | $(call QUIET_CLEAN, config) | 584 | $(call QUIET_CLEAN, config) |
568 | $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null | 585 | $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null |
569 | 586 | ||
570 | clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean | 587 | clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean config-clean |
571 | $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS) | 588 | $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS) |
572 | $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete | 589 | $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete |
573 | $(Q)$(RM) $(OUTPUT).config-detected | 590 | $(Q)$(RM) $(OUTPUT).config-detected |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index ab09adaabc9c..de89ec574361 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -106,6 +106,7 @@ ifdef LIBBABELTRACE | |||
106 | FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf | 106 | FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf |
107 | endif | 107 | endif |
108 | 108 | ||
109 | FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi | ||
109 | # include ARCH specific config | 110 | # include ARCH specific config |
110 | -include $(src-perf)/arch/$(ARCH)/Makefile | 111 | -include $(src-perf)/arch/$(ARCH)/Makefile |
111 | 112 | ||
@@ -237,6 +238,7 @@ ifdef NO_LIBELF | |||
237 | NO_DEMANGLE := 1 | 238 | NO_DEMANGLE := 1 |
238 | NO_LIBUNWIND := 1 | 239 | NO_LIBUNWIND := 1 |
239 | NO_LIBDW_DWARF_UNWIND := 1 | 240 | NO_LIBDW_DWARF_UNWIND := 1 |
241 | NO_LIBBPF := 1 | ||
240 | else | 242 | else |
241 | ifeq ($(feature-libelf), 0) | 243 | ifeq ($(feature-libelf), 0) |
242 | ifeq ($(feature-glibc), 1) | 244 | ifeq ($(feature-glibc), 1) |
@@ -246,13 +248,14 @@ else | |||
246 | LIBC_SUPPORT := 1 | 248 | LIBC_SUPPORT := 1 |
247 | endif | 249 | endif |
248 | ifeq ($(LIBC_SUPPORT),1) | 250 | ifeq ($(LIBC_SUPPORT),1) |
249 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); | 251 | msg := $(warning No libelf found, disables 'probe' tool and BPF support in 'perf record', please install elfutils-libelf-devel/libelf-dev); |
250 | 252 | ||
251 | NO_LIBELF := 1 | 253 | NO_LIBELF := 1 |
252 | NO_DWARF := 1 | 254 | NO_DWARF := 1 |
253 | NO_DEMANGLE := 1 | 255 | NO_DEMANGLE := 1 |
254 | NO_LIBUNWIND := 1 | 256 | NO_LIBUNWIND := 1 |
255 | NO_LIBDW_DWARF_UNWIND := 1 | 257 | NO_LIBDW_DWARF_UNWIND := 1 |
258 | NO_LIBBPF := 1 | ||
256 | else | 259 | else |
257 | ifneq ($(filter s% -static%,$(LDFLAGS),),) | 260 | ifneq ($(filter s% -static%,$(LDFLAGS),),) |
258 | msg := $(error No static glibc found, please install glibc-static); | 261 | msg := $(error No static glibc found, please install glibc-static); |
@@ -309,6 +312,13 @@ ifndef NO_LIBELF | |||
309 | $(call detected,CONFIG_DWARF) | 312 | $(call detected,CONFIG_DWARF) |
310 | endif # PERF_HAVE_DWARF_REGS | 313 | endif # PERF_HAVE_DWARF_REGS |
311 | endif # NO_DWARF | 314 | endif # NO_DWARF |
315 | |||
316 | ifndef NO_LIBBPF | ||
317 | ifeq ($(feature-bpf), 1) | ||
318 | CFLAGS += -DHAVE_LIBBPF_SUPPORT | ||
319 | $(call detected,CONFIG_LIBBPF) | ||
320 | endif | ||
321 | endif # NO_LIBBPF | ||
312 | endif # NO_LIBELF | 322 | endif # NO_LIBELF |
313 | 323 | ||
314 | ifeq ($(ARCH),powerpc) | 324 | ifeq ($(ARCH),powerpc) |
@@ -324,6 +334,13 @@ ifndef NO_LIBUNWIND | |||
324 | endif | 334 | endif |
325 | endif | 335 | endif |
326 | 336 | ||
337 | ifndef NO_LIBBPF | ||
338 | ifneq ($(feature-bpf), 1) | ||
339 | msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.) | ||
340 | NO_LIBBPF := 1 | ||
341 | endif | ||
342 | endif | ||
343 | |||
327 | dwarf-post-unwind := 1 | 344 | dwarf-post-unwind := 1 |
328 | dwarf-post-unwind-text := BUG | 345 | dwarf-post-unwind-text := BUG |
329 | 346 | ||
diff --git a/tools/perf/tests/make b/tools/perf/tests/make index ba31c4bd441d..2cbd0c6901e3 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make | |||
@@ -44,6 +44,7 @@ make_no_libnuma := NO_LIBNUMA=1 | |||
44 | make_no_libaudit := NO_LIBAUDIT=1 | 44 | make_no_libaudit := NO_LIBAUDIT=1 |
45 | make_no_libbionic := NO_LIBBIONIC=1 | 45 | make_no_libbionic := NO_LIBBIONIC=1 |
46 | make_no_auxtrace := NO_AUXTRACE=1 | 46 | make_no_auxtrace := NO_AUXTRACE=1 |
47 | make_no_libbpf := NO_LIBBPF=1 | ||
47 | make_tags := tags | 48 | make_tags := tags |
48 | make_cscope := cscope | 49 | make_cscope := cscope |
49 | make_help := help | 50 | make_help := help |
@@ -66,7 +67,7 @@ make_static := LDFLAGS=-static | |||
66 | make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 | 67 | make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 |
67 | make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 | 68 | make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 |
68 | make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 | 69 | make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 |
69 | make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 | 70 | make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 |
70 | 71 | ||
71 | # $(run) contains all available tests | 72 | # $(run) contains all available tests |
72 | run := make_pure | 73 | run := make_pure |
@@ -94,6 +95,7 @@ run += make_no_libnuma | |||
94 | run += make_no_libaudit | 95 | run += make_no_libaudit |
95 | run += make_no_libbionic | 96 | run += make_no_libbionic |
96 | run += make_no_auxtrace | 97 | run += make_no_auxtrace |
98 | run += make_no_libbpf | ||
97 | run += make_help | 99 | run += make_help |
98 | run += make_doc | 100 | run += make_doc |
99 | run += make_perf_o | 101 | run += make_perf_o |