lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-baa9c30e1e250abf3e53b98e5bcf415dccdc7ba2@git.kernel.org>
Date:	Mon, 14 Oct 2013 22:17:09 -0700
From:	tip-bot for Ingo Molnar <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, acme@...hat.com, hpa@...or.com,
	mingo@...nel.org, a.p.zijlstra@...llo.nl, namhyung@...nel.org,
	jolsa@...hat.com, dsahern@...il.com, tglx@...utronix.de
Subject: [tip:perf/core] tools/perf/build:
  Speed up auto-detection of features by adding a 'test-all' target

Commit-ID:  baa9c30e1e250abf3e53b98e5bcf415dccdc7ba2
Gitweb:     http://git.kernel.org/tip/baa9c30e1e250abf3e53b98e5bcf415dccdc7ba2
Author:     Ingo Molnar <mingo@...nel.org>
AuthorDate: Tue, 1 Oct 2013 14:14:31 +0200
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 9 Oct 2013 08:48:49 +0200

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@...hat.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: David Ahern <dsahern@...il.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Link: http://lkml.kernel.org/n/tip-5hlcb2qorzwfwrWTjiygjjih@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 tools/perf/config/Makefile                  |  45 ++++++-
 tools/perf/config/feature-checks/Makefile   |   3 +
 tools/perf/config/feature-checks/test-all.c | 196 ++++++++++++++++++++++++++++
 3 files changed, 238 insertions(+), 6 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 3207c25..cbd7cdc 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -89,17 +89,21 @@ CFLAGS += -std=gnu99
 
 EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
-feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1))
+feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+endef
+
+feature_set = $(eval $(feature_set_code))
+define feature_set_code
+  feature-$(1) := 1
 endef
 
 #
 # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
 #
-$(info Testing features:)
-$(shell make -i -j -C config/feature-checks >/dev/null 2>&1)
-$(info done)
+$(info )
+$(info Auto-detecting system features:)
 
 FEATURE_TESTS =				\
 	hello				\
@@ -126,7 +130,36 @@ FEATURE_TESTS =				\
 	backtrace			\
 	libnuma
 
-$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
+#
+# Special fast-path for the 'all features are available' case:
+#
+$(call feature_check,all)
+
+ifeq ($(feature-all), 1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
+else
+  $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
+endif
+
+feature_print = $(eval $(feature_print_code))
+
+#
+# Print the result of the feature test:
+#
+define feature_print_code
+  ifeq ($(feature-$(1)), 1)
+    MSG := $(shell printf '...%30s: [ \033[32mon\033[m  ]' $(1))
+  else
+    MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
+  endif
+  $(info $(MSG))
+endef
+
+$(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat)))
+
+# newline at the end of the feature printouts:
+$(info )
 
 ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c65bdac..4b855e0 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ $@.c
 
 ###############################
 
+test-all:
+	$(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
+
 test-hello:
 	$(BUILD)
 
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 0000000..9f7c4b1
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -0,0 +1,196 @@
+
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+
+#include <Python.h>
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include <stdio.h>
+#include <libelf.h>
+#include <gnu/libc-version.h>
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <elfutils/version.h>
+#include <libelf.h>
+#include <libunwind.h>
+#include <stdlib.h>
+#include <libaudit.h>
+#include <slang.h>
+#include <gtk/gtk.h>
+#include <bfd.h>
+#include <stdio.h>
+#include <execinfo.h>
+#include <stdio.h>
+#include <numa.h>
+#include <numaif.h>
+
+#pragma GCC diagnostic error "-Wstrict-prototypes"
+
+int main1(void)
+{
+	return puts("hi");
+}
+
+int main2(void)
+{
+	return puts("hi");
+}
+
+int main3(void)
+{
+	return puts("hi");
+}
+
+int main4(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ, 0);
+	return (long)elf;
+}
+#
+int main5(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+	return (long)elf;
+}
+
+int main6(void)
+{
+	const char *version = gnu_get_libc_version();
+	return (long)version;
+}
+
+int main7(void)
+{
+	Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+	return (long)dbg;
+}
+
+int main8(void)
+{
+	size_t dst;
+	return elf_getphdrnum(0, &dst);
+}
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                      unw_word_t ip,
+                                      unw_dyn_info_t *di,
+                                      unw_proc_info_t *pi,
+                                      int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+int main9(void)
+{
+	unw_addr_space_t addr_space;
+	addr_space = unw_create_addr_space(NULL, 0);
+	unw_init_remote(NULL, addr_space, NULL);
+	dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+	return 0;
+}
+
+int main10(void)
+{
+	printf("error message: %s\n", audit_errno_to_name(0));
+	return audit_open();
+}
+
+int main11(void)
+{
+	return SLsmg_init_smg();
+}
+
+int main12(int argc, char *argv[])
+{
+        gtk_init(&argc, &argv);
+
+        return 0;
+}
+
+int main13(void)
+{
+	gtk_info_bar_new();
+
+	return 0;
+}
+
+int main14(void)
+{
+	perl_alloc();
+
+	return 0;
+}
+
+int main15(void)
+{
+	Py_Initialize();
+	return 0;
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+	#error
+#endif
+
+int main16(void)
+{
+	return 0;
+}
+
+int main17(void)
+{
+	bfd_demangle(0, 0, 0);
+	return 0;
+}
+
+void exit_function(int x, void *y)
+{
+}
+
+int main18(void)
+{
+	return on_exit(exit_function, NULL);
+}
+
+int main19(void)
+{
+	void *backtrace_fns[1];
+	size_t entries;
+
+	entries = backtrace(backtrace_fns, 1);
+	backtrace_symbols(backtrace_fns, entries);
+
+	return 0;
+}
+
+int main20(void)
+{
+	numa_available();
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	main1();
+	main2();
+	main3();
+	main4();
+	main5();
+	main6();
+	main7();
+	main8();
+	main9();
+	main10();
+	main11();
+	main12(argc, argv);
+	main13();
+	main14();
+	main15();
+	main16();
+	main17();
+	main18();
+	main19();
+	main20();
+
+	return 0;
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ