Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756103Ab3JHKM4 (ORCPT ); Tue, 8 Oct 2013 06:12:56 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:47448 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756011Ab3JHKMk (ORCPT ); Tue, 8 Oct 2013 06:12:40 -0400 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , David Ahern , Jiri Olsa Subject: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the system Date: Tue, 8 Oct 2013 12:11:09 +0200 Message-Id: <1381227082-22039-40-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1381227082-22039-1-git-send-email-mingo@kernel.org> References: <1381227082-22039-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2014 Lines: 72 Implement automatic parallel builds when building in tools/perf: $ time make # [ perf build: Doing 'make -j12' parallel build. ] Auto-detecting system features: ... real 0m9.265s user 0m59.888s sys 0m6.082s On GNU make achieving this is not particularly easy, it requires a separate makefile, which then invokes the main Makefile. ( Note: this patch adds Makefile.parallel to show the concept - the two makefiles will be flipped in the next patch to avoid having to specify -f to get parallelism in the default build. ) Cc: Arnaldo Carvalho de Melo Cc: Peter Zijlstra Cc: Namhyung Kim Cc: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/n/tip-dvBjwqiTyzrufzkz8oanhpf9@git.kernel.org Signed-off-by: Ingo Molnar --- tools/perf/Makefile.parallel | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/Makefile.parallel b/tools/perf/Makefile.parallel new file mode 100644 index 0000000..ec5e08b --- /dev/null +++ b/tools/perf/Makefile.parallel @@ -0,0 +1,26 @@ +# +# Do a parallel build with multiple jobs, based on the number of CPUs online +# in this system: 'make -j8' on a 8-CPU system, etc. +# +# (To override it, run 'make JOBS=1' and similar.) +# +ifeq ($(JOBS),) + JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null) + ifeq ($(JOBS),) + JOBS := 1 + endif +endif + +export JOBS + +$(info $(shell printf '# [ perf build: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build. ]\n')) + +# +# Needed if no target specified: +# +all: + @$(MAKE) --no-print-directory -j$(JOBS) $@ + +%: + @$(MAKE) --no-print-directory -j$(JOBS) $@ + -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/