From patchwork Tue Apr 28 13:24:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris J Arges X-Patchwork-Id: 6288711 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6DDF1BEEE1 for ; Tue, 28 Apr 2015 13:24:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8332520384 for ; Tue, 28 Apr 2015 13:24:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5925D20376 for ; Tue, 28 Apr 2015 13:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965423AbbD1NYy (ORCPT ); Tue, 28 Apr 2015 09:24:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46865 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965525AbbD1NYy (ORCPT ); Tue, 28 Apr 2015 09:24:54 -0400 Received: from [10.172.65.250] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Yn5VL-0004pT-RO; Tue, 28 Apr 2015 13:24:52 +0000 From: Chris J Arges To: linux-kbuild@vger.kernel.org, mmarek@suse.cz Cc: linux-kernel@vger.kernel.org, Chris J Arges Subject: [PATCH v3] builddeb: parallelize debug module installation Date: Tue, 28 Apr 2015 08:24:44 -0500 Message-Id: <1430227484-26361-1-git-send-email-chris.j.arges@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <553F5B5F.5000709@suse.cz> References: <553F5B5F.5000709@suse.cz> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When building the dbg package, we use a large 'for module in $(find' loop that can be easily parallelized by using 'find | xargs'. This patch modifies this loop to use the later paradigm. In addition, check if the user has requested a parallel build with make. If so, add the appropriate flags to xargs to set MAXPROCS (-P) equal to the number of processing units on the system. Signed-off-by: Chris J Arges --- scripts/package/builddeb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 88dbf23..5849f0c 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -152,16 +152,21 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then rmdir "$tmpdir/lib/modules/$version" fi if [ -n "$BUILD_DEBUG" ] ; then - for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do - module=lib/modules/$module - mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) + # If we've invoked make with -j, then parallelize; otherwise + # just use a single process. + procs=1 + test "${MAKEFLAGS#*-j}" != "${MAKEFLAGS}" && procs=`getconf _NPROCESSORS_ONLN` + find $tmpdir/lib/modules/ -name *.ko -printf '%P\n' | xargs -n1 -P${procs} -I {} sh -c ' + mkdir -p $(dirname '"$dbg_dir"'/usr/lib/debug/lib/modules/$1);'" # only keep debug symbols in the debug file - $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module + $OBJCOPY --only-keep-debug $tmpdir/lib/modules/{} \ + $dbg_dir/usr/lib/debug/lib/modules/{}; # strip original module from debug symbols - $OBJCOPY --strip-debug $tmpdir/$module + $OBJCOPY --strip-debug $tmpdir/lib/modules/{}; # then add a link to those - $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module - done + $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/lib/modules/{} \ + $tmpdir/lib/modules/{}; + " -- {} fi fi