aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2013-10-01 08:14:31 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-09 02:48:49 -0400
commitbaa9c30e1e250abf3e53b98e5bcf415dccdc7ba2 (patch)
tree1bf3e1b7548aa685eb2b187690aa11fbe49f38fc /tools/perf
parentfb1c9185e36cf9c616ac15f54e54a01f052672bd (diff)
tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
Concatenate all feature checks into test-all.c. This can be built and checked faster than all the individual tests. If test-all fails then we still check all the individual features, so this is a pure speedup, it should have no effects on functionality. Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-5hlcb2qorzwfwrWTjiygjjih@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/config/Makefile45
-rw-r--r--tools/perf/config/feature-checks/Makefile3
-rw-r--r--tools/perf/config/feature-checks/test-all.c196
3 files changed, 238 insertions, 6 deletions
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 3207c25b15f0..cbd7cdca3e56 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -89,17 +89,21 @@ CFLAGS += -std=gnu99
89 89
90EXTLIBS = -lelf -lpthread -lrt -lm -ldl 90EXTLIBS = -lelf -lpthread -lrt -lm -ldl
91 91
92feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) 92feature_check = $(eval $(feature_check_code))
93define feature_check_code 93define feature_check_code
94 feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) 94 feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
95endef
96
97feature_set = $(eval $(feature_set_code))
98define feature_set_code
99 feature-$(1) := 1
95endef 100endef
96 101
97# 102#
98# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: 103# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
99# 104#
100$(info Testing features:) 105$(info )
101$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) 106$(info Auto-detecting system features:)
102$(info done)
103 107
104FEATURE_TESTS = \ 108FEATURE_TESTS = \
105 hello \ 109 hello \
@@ -126,7 +130,36 @@ FEATURE_TESTS = \
126 backtrace \ 130 backtrace \
127 libnuma 131 libnuma
128 132
129$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test))) 133#
134# Special fast-path for the 'all features are available' case:
135#
136$(call feature_check,all)
137
138ifeq ($(feature-all), 1)
139 $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
140else
141 $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1)
142 $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
143endif
144
145feature_print = $(eval $(feature_print_code))
146
147#
148# Print the result of the feature test:
149#
150define feature_print_code
151 ifeq ($(feature-$(1)), 1)
152 MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
153 else
154 MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
155 endif
156 $(info $(MSG))
157endef
158
159$(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat)))
160
161# newline at the end of the feature printouts:
162$(info )
130 163
131ifeq ($(feature-stackprotector-all), 1) 164ifeq ($(feature-stackprotector-all), 1)
132 CFLAGS += -fstack-protector-all 165 CFLAGS += -fstack-protector-all
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c65bdac0ebe2..4b855e0ccd0b 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ $@.c
32 32
33############################### 33###############################
34 34
35test-all:
36 $(BUILD) -Werror -fstack-protector -fstack-protector-all -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
37
35test-hello: 38test-hello:
36 $(BUILD) 39 $(BUILD)
37 40
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
new file mode 100644
index 000000000000..9f7c4b165305
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -0,0 +1,196 @@
1
2#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3
4#include <Python.h>
5
6#include <EXTERN.h>
7#include <perl.h>
8
9#include <stdio.h>
10#include <libelf.h>
11#include <gnu/libc-version.h>
12#include <dwarf.h>
13#include <elfutils/libdw.h>
14#include <elfutils/version.h>
15#include <libelf.h>
16#include <libunwind.h>
17#include <stdlib.h>
18#include <libaudit.h>
19#include <slang.h>
20#include <gtk/gtk.h>
21#include <bfd.h>
22#include <stdio.h>
23#include <execinfo.h>
24#include <stdio.h>
25#include <numa.h>
26#include <numaif.h>
27
28#pragma GCC diagnostic error "-Wstrict-prototypes"
29
30int main1(void)
31{
32 return puts("hi");
33}
34
35int main2(void)
36{
37 return puts("hi");
38}
39
40int main3(void)
41{
42 return puts("hi");
43}
44
45int main4(void)
46{
47 Elf *elf = elf_begin(0, ELF_C_READ, 0);
48 return (long)elf;
49}
50#
51int main5(void)
52{
53 Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
54 return (long)elf;
55}
56
57int main6(void)
58{
59 const char *version = gnu_get_libc_version();
60 return (long)version;
61}
62
63int main7(void)
64{
65 Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
66 return (long)dbg;
67}
68
69int main8(void)
70{
71 size_t dst;
72 return elf_getphdrnum(0, &dst);
73}
74
75extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
76 unw_word_t ip,
77 unw_dyn_info_t *di,
78 unw_proc_info_t *pi,
79 int need_unwind_info, void *arg);
80
81
82#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
83
84int main9(void)
85{
86 unw_addr_space_t addr_space;
87 addr_space = unw_create_addr_space(NULL, 0);
88 unw_init_remote(NULL, addr_space, NULL);
89 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
90 return 0;
91}
92
93int main10(void)
94{
95 printf("error message: %s\n", audit_errno_to_name(0));
96 return audit_open();
97}
98
99int main11(void)
100{
101 return SLsmg_init_smg();
102}
103
104int main12(int argc, char *argv[])
105{
106 gtk_init(&argc, &argv);
107
108 return 0;
109}
110
111int main13(void)
112{
113 gtk_info_bar_new();
114
115 return 0;
116}
117
118int main14(void)
119{
120 perl_alloc();
121
122 return 0;
123}
124
125int main15(void)
126{
127 Py_Initialize();
128 return 0;
129}
130
131#if PY_VERSION_HEX >= 0x03000000
132 #error
133#endif
134
135int main16(void)
136{
137 return 0;
138}
139
140int main17(void)
141{
142 bfd_demangle(0, 0, 0);
143 return 0;
144}
145
146void exit_function(int x, void *y)
147{
148}
149
150int main18(void)
151{
152 return on_exit(exit_function, NULL);
153}
154
155int main19(void)
156{
157 void *backtrace_fns[1];
158 size_t entries;
159
160 entries = backtrace(backtrace_fns, 1);
161 backtrace_symbols(backtrace_fns, entries);
162
163 return 0;
164}
165
166int main20(void)
167{
168 numa_available();
169 return 0;
170}
171
172int main(int argc, char *argv[])
173{
174 main1();
175 main2();
176 main3();
177 main4();
178 main5();
179 main6();
180 main7();
181 main8();
182 main9();
183 main10();
184 main11();
185 main12(argc, argv);
186 main13();
187 main14();
188 main15();
189 main16();
190 main17();
191 main18();
192 main19();
193 main20();
194
195 return 0;
196}