aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2015-10-14 08:41:12 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-28 11:48:12 -0400
commited63f34c026e9a60d17fa750ecdfe3f600d49393 (patch)
tree1a6c9fab170c8a76b2b05904264f728c7bcc7621 /tools/perf
parent443f8c75e8d58d394b0e65b47e02e5cd8ed32b41 (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/MANIFEST3
-rw-r--r--tools/perf/Makefile.perf21
-rw-r--r--tools/perf/config/Makefile19
-rw-r--r--tools/perf/tests/make4
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
17tools/arch/x86/include/asm/atomic.h 17tools/arch/x86/include/asm/atomic.h
18tools/arch/x86/include/asm/rmwcc.h 18tools/arch/x86/include/asm/rmwcc.h
19tools/lib/traceevent 19tools/lib/traceevent
20tools/lib/bpf
20tools/lib/api 21tools/lib/api
21tools/lib/bpf 22tools/lib/bpf
22tools/lib/hweight.c 23tools/lib/hweight.c
@@ -69,6 +70,8 @@ arch/*/lib/memset*.S
69include/linux/poison.h 70include/linux/poison.h
70include/linux/hw_breakpoint.h 71include/linux/hw_breakpoint.h
71include/uapi/linux/perf_event.h 72include/uapi/linux/perf_event.h
73include/uapi/linux/bpf.h
74include/uapi/linux/bpf_common.h
72include/uapi/linux/const.h 75include/uapi/linux/const.h
73include/uapi/linux/swab.h 76include/uapi/linux/swab.h
74include/uapi/linux/hw_breakpoint.h 77include/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
80unexport LC_ALL 82unexport LC_ALL
@@ -145,6 +147,7 @@ AWK = awk
145 147
146LIB_DIR = $(srctree)/tools/lib/api/ 148LIB_DIR = $(srctree)/tools/lib/api/
147TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ 149TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
150BPF_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
181ifneq ($(OUTPUT),) 184ifneq ($(OUTPUT),)
182 TE_PATH=$(OUTPUT) 185 TE_PATH=$(OUTPUT)
186 BPF_PATH=$(OUTPUT)
183ifneq ($(subdir),) 187ifneq ($(subdir),)
184 LIB_PATH=$(OUTPUT)/../lib/api/ 188 LIB_PATH=$(OUTPUT)/../lib/api/
185else 189else
@@ -188,6 +192,7 @@ endif
188else 192else
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)
191endif 196endif
192 197
193LIBTRACEEVENT = $(TE_PATH)libtraceevent.a 198LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
@@ -199,6 +204,8 @@ LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYN
199LIBAPI = $(LIB_PATH)libapi.a 204LIBAPI = $(LIB_PATH)libapi.a
200export LIBAPI 205export LIBAPI
201 206
207LIBBPF = $(BPF_PATH)libbpf.a
208
202# python extension build directories 209# python extension build directories
203PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ 210PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
204PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ 211PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
@@ -251,6 +258,9 @@ export PERL_PATH
251LIB_FILE=$(OUTPUT)libperf.a 258LIB_FILE=$(OUTPUT)libperf.a
252 259
253PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) 260PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT)
261ifndef NO_LIBBPF
262 PERFLIBS += $(LIBBPF)
263endif
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
423help: 440help:
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
462TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include 479TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include ../lib/bpf
463TAG_FILES= ../../include/uapi/linux/perf_event.h 480TAG_FILES= ../../include/uapi/linux/perf_event.h
464 481
465TAGS: 482TAGS:
@@ -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
570clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean 587clean: $(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
107endif 107endif
108 108
109FEATURE_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
240else 242else
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
312endif # NO_LIBELF 322endif # NO_LIBELF
313 323
314ifeq ($(ARCH),powerpc) 324ifeq ($(ARCH),powerpc)
@@ -324,6 +334,13 @@ ifndef NO_LIBUNWIND
324 endif 334 endif
325endif 335endif
326 336
337ifndef 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
342endif
343
327dwarf-post-unwind := 1 344dwarf-post-unwind := 1
328dwarf-post-unwind-text := BUG 345dwarf-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
44make_no_libaudit := NO_LIBAUDIT=1 44make_no_libaudit := NO_LIBAUDIT=1
45make_no_libbionic := NO_LIBBIONIC=1 45make_no_libbionic := NO_LIBBIONIC=1
46make_no_auxtrace := NO_AUXTRACE=1 46make_no_auxtrace := NO_AUXTRACE=1
47make_no_libbpf := NO_LIBBPF=1
47make_tags := tags 48make_tags := tags
48make_cscope := cscope 49make_cscope := cscope
49make_help := help 50make_help := help
@@ -66,7 +67,7 @@ make_static := LDFLAGS=-static
66make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 67make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
67make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 68make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
68make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 69make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
69make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 70make_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
72run := make_pure 73run := make_pure
@@ -94,6 +95,7 @@ run += make_no_libnuma
94run += make_no_libaudit 95run += make_no_libaudit
95run += make_no_libbionic 96run += make_no_libbionic
96run += make_no_auxtrace 97run += make_no_auxtrace
98run += make_no_libbpf
97run += make_help 99run += make_help
98run += make_doc 100run += make_doc
99run += make_perf_o 101run += make_perf_o