All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: David Ahern <dsahern@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] perf test-hack: Split out feature tests to cache them and to build them in parallel
Date: Sun, 15 Sep 2013 11:10:29 +0200	[thread overview]
Message-ID: <20130915091029.GA21465@gmail.com> (raw)
In-Reply-To: <20130912204313.GA3259@gmail.com>


So, the discussion died down a bit, so just to demonstrate how feature 
tests should be done IMO, here's a quick hack to perf that adds a new 
'make feature-check' test-target and factors out 4 standalone feature 
tests:

 $ make feature-check
 ...
 Testing features:
 dwarf  support:  disabled
 ELF    support:  enabled
 glibc  support:  enabled
 Bionic support:  disabled

Repeat invocations only rebuild the testcases that failed. If no testcase 
fails then nothing is rebuilt and the features check runs very fast.

Even in the worst-case when most testcases are rebuilt there's a big 
improvement in runtime due to building the testcases in parallel.

NOTE: the new testcases are not fed back into perf's 
NO_DWARF/NO_LIBELF/etc. flag hierarchy yet, the patch only demonstrates 
that this method is a viable and fast method that solves most of our 
current problems in this area.

Other advantages over the current config/feature-tests.mak method:

 - The individual testcases can be built/tested in the feature-checks/ 
   directory as well, individually

 - The testcases are simple, plain, standalone C files, unlike
   config/feature-tests.mak which suffers from escaping complications.

'make clean' in feature-checks/ gets rid of all testcase binaries.

Thanks,

	Ingo

---------------------->

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 3a0ff7f..e6398e7 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -816,3 +816,17 @@ clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean
 .PHONY: all install clean strip $(LIBTRACEEVENT) $(LIBLK)
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
 .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
+
+#
+# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
+#
+feature-check-build:
+	@echo "Testing features:"
+	@-make -i -j -C feature-checks >/dev/null 2>&1
+
+feature-check: feature-check-build
+	@echo -n "dwarf  support:  "; [ -f feature-checks/test-dwarf  ] && echo enabled || echo disabled
+	@echo -n "ELF    support:  "; [ -f feature-checks/test-libelf ] && echo enabled || echo disabled
+	@echo -n "glibc  support:  "; [ -f feature-checks/test-glibc  ] && echo enabled || echo disabled
+	@echo -n "Bionic support:  "; [ -f feature-checks/test-bionic ] && echo enabled || echo disabled
+
diff --git a/tools/perf/feature-checks/Makefile b/tools/perf/feature-checks/Makefile
new file mode 100644
index 0000000..dea10c8
--- /dev/null
+++ b/tools/perf/feature-checks/Makefile
@@ -0,0 +1,26 @@
+
+FILES=test-hello test-dwarf test-libelf test-glibc test-bionic
+
+all: $(FILES)
+
+###############################
+
+test-hello: test-hello.c
+	$(CC) -o $@ $@.c
+
+test-dwarf: test-dwarf.c
+	$(CC) -o $@ $@.c -ldw
+
+test-libelf: test-libelf.c
+	$(CC) -o $@ $@.c -lelf
+
+test-glibc: test-glibc.c
+	$(CC) -o $@ $@.c
+
+test-bionic: test-bionic.c
+	$(CC) -o $@ $@.c
+
+###############################
+
+clean:
+	rm -f $(FILES)
diff --git a/tools/perf/feature-checks/test-bionic.c b/tools/perf/feature-checks/test-bionic.c
new file mode 100644
index 0000000..eac24e9
--- /dev/null
+++ b/tools/perf/feature-checks/test-bionic.c
@@ -0,0 +1,6 @@
+#include <android/api-level.h>
+
+int main(void)
+{
+	return __ANDROID_API__;
+}
diff --git a/tools/perf/feature-checks/test-dwarf.c b/tools/perf/feature-checks/test-dwarf.c
new file mode 100644
index 0000000..783dfcd
--- /dev/null
+++ b/tools/perf/feature-checks/test-dwarf.c
@@ -0,0 +1,9 @@
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <elfutils/version.h>
+
+int main(void)
+{
+	Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+	return (long)dbg;
+}
diff --git a/tools/perf/feature-checks/test-glibc.c b/tools/perf/feature-checks/test-glibc.c
new file mode 100644
index 0000000..13c66a5
--- /dev/null
+++ b/tools/perf/feature-checks/test-glibc.c
@@ -0,0 +1,8 @@
+#include <gnu/libc-version.h>
+
+int main(void)
+{
+	const char *version = gnu_get_libc_version();
+	return (long)version;
+}
+
diff --git a/tools/perf/feature-checks/test-hello b/tools/perf/feature-checks/test-hello
new file mode 100755
index 0000000..6e9a668
Binary files /dev/null and b/tools/perf/feature-checks/test-hello differ
diff --git a/tools/perf/feature-checks/test-hello.c b/tools/perf/feature-checks/test-hello.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/feature-checks/test-hello.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
diff --git a/tools/perf/feature-checks/test-libelf b/tools/perf/feature-checks/test-libelf
new file mode 100755
index 0000000..bafde82
Binary files /dev/null and b/tools/perf/feature-checks/test-libelf differ
diff --git a/tools/perf/feature-checks/test-libelf.c b/tools/perf/feature-checks/test-libelf.c
new file mode 100644
index 0000000..1a08f97
--- /dev/null
+++ b/tools/perf/feature-checks/test-libelf.c
@@ -0,0 +1,7 @@
+#include <libelf.h>
+
+int main(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ, 0);
+	return (long)elf;
+}

  reply	other threads:[~2013-09-15  9:10 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 13:38 [GIT PULL] perf fixes Ingo Molnar
2013-09-12 18:03 ` Linus Torvalds
2013-09-12 18:10   ` Linus Torvalds
2013-09-12 18:43     ` Arnaldo Carvalho de Melo
2013-09-12 19:12       ` Arnaldo Carvalho de Melo
2013-09-12 19:13         ` Linus Torvalds
2013-09-12 19:55       ` Ingo Molnar
2013-09-12 19:58       ` David Ahern
2013-09-12 20:02         ` Arnaldo Carvalho de Melo
2013-09-12 20:31           ` Ingo Molnar
2013-09-12 20:43             ` Ingo Molnar
2013-09-15  9:10               ` Ingo Molnar [this message]
2013-09-30 16:42                 ` [PATCH] perf auto-dep: Speed up feature tests by building them in parallel Ingo Molnar
2013-09-30 17:12                   ` Arnaldo Carvalho de Melo
2013-09-30 17:27                     ` Arnaldo Carvalho de Melo
2013-09-30 17:30                       ` Arnaldo Carvalho de Melo
2013-09-30 17:36                         ` Arnaldo Carvalho de Melo
2013-09-30 17:39                           ` Arnaldo Carvalho de Melo
2013-09-30 17:46                             ` Arnaldo Carvalho de Melo
2013-09-30 18:02                               ` Arnaldo Carvalho de Melo
2013-09-30 19:15                                 ` Ingo Molnar
2013-09-30 19:09                         ` Ingo Molnar
2013-09-30 17:34                     ` Linus Torvalds
2013-09-30 17:53                       ` Arnaldo Carvalho de Melo
2013-09-30 19:04                         ` Ingo Molnar
2013-10-01 11:34                           ` [PATCH] perf autodep: Remove strlcpy feature check, add __weak strlcpy implementation Ingo Molnar
2013-10-01 12:04                             ` Ingo Molnar
2013-10-01 12:48                               ` Arnaldo Carvalho de Melo
2013-10-01 12:51                               ` [PATCH] perf autodep: Speed up the 'all features are present' case Ingo Molnar
2013-10-01 14:46                             ` [PATCH] perf tools: Speed up git-version test on re-make Ingo Molnar
2013-10-02  6:47                               ` Namhyung Kim
2013-10-02  6:50                                 ` Ingo Molnar
2013-10-02  8:04                                   ` Namhyung Kim
2013-10-01 15:27                             ` [PATCH] perf autodep: Remove strlcpy feature check, add __weak strlcpy implementation Ingo Molnar
2013-10-01 15:29                               ` [PATCH] perf tools: Speed up the final link Ingo Molnar
2013-10-01  7:04                       ` [PATCH] perf auto-dep: Speed up feature tests by building them in parallel Geert Uytterhoeven
2013-10-01  8:38                         ` Ingo Molnar
2013-10-02  6:05                   ` Namhyung Kim
2013-10-02  6:28                     ` Ingo Molnar
2013-10-02  9:26                   ` Jiri Olsa
2013-10-02 10:11                     ` Ingo Molnar
2013-09-12 20:18         ` [GIT PULL] perf fixes Ingo Molnar
2013-09-12 20:38           ` Arnaldo Carvalho de Melo
2013-09-12 20:46             ` Ingo Molnar
2013-09-12 21:09               ` David Ahern
2013-09-12 21:18                 ` Ingo Molnar
2013-09-12 22:10                   ` David Ahern
2013-09-13  5:09                     ` Ingo Molnar
2013-09-13  9:32                       ` Jean Pihet
2013-09-13  9:45                         ` Ingo Molnar
2013-09-13 17:15                           ` Jean Pihet
2013-09-12 18:51     ` Linus Torvalds
2013-09-12 20:33       ` Ingo Molnar
2013-09-12 20:38         ` Linus Torvalds
2013-09-12 20:49           ` Ingo Molnar
2013-09-12 20:52             ` Linus Torvalds
2013-09-12 21:01               ` Ingo Molnar
2013-09-12 20:10     ` Ingo Molnar
2013-10-02  7:31   ` [PATCH] tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al Ingo Molnar
2013-10-02  9:28     ` [PATCH] tools/perf/build: Automatically build in parallel, based on number of CPUs in the system Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130915091029.GA21465@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=akpm@linux-foundation.org \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.