From patchwork Thu Jun 27 18:48:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 2794691 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8B03CBF4A1 for ; Thu, 27 Jun 2013 18:48:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 851AD2041E for ; Thu, 27 Jun 2013 18:48:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B2772041D for ; Thu, 27 Jun 2013 18:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754165Ab3F0Ss3 (ORCPT ); Thu, 27 Jun 2013 14:48:29 -0400 Received: from mail-ye0-f202.google.com ([209.85.213.202]:61445 "EHLO mail-ye0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049Ab3F0Ss1 (ORCPT ); Thu, 27 Jun 2013 14:48:27 -0400 Received: by mail-ye0-f202.google.com with SMTP id r11so69161yen.3 for ; Thu, 27 Jun 2013 11:48:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=EG49+WWE7NUXcfu2rSXYS8RpuXR+8UWRNopa3henWPo=; b=pibJx+hN/i4Q33+zTo53zEEusSGSF3Zt/+D/ZmZIk8qB1aeJp33ftGWAi1Vas1lJet jYFA50hnhxdXv4MLvwXHJQ5u+QSozBX0Yz0eIPEI689EWLFwtcQT67HiO0V0PwaXzvs3 kHdiJDEJBDE1OIYCewPzsiXn+uV2bTZgUNIqhdwpI7vWVkyY10wGxHZA3WOWxUNQfOml 3WF7psGy7yAblcJ6Yz4wUSlFbLSt0XuTF93smlw7BmBPx9CFtooWR3Dkb4zxg599JUSD PpKdD8uWmEQxj94DADCs1LzllcTOgIU6dlSCcU+cj3/fzmsanWSX2fVMlOGMAubNwfL8 Dq9g== X-Received: by 10.236.135.66 with SMTP id t42mr5384072yhi.36.1372358907350; Thu, 27 Jun 2013 11:48:27 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id t25si2175372yhg.6.2013.06.27.11.48.27 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Thu, 27 Jun 2013 11:48:27 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.34]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 3422931C3E8; Thu, 27 Jun 2013 11:48:27 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id C639680608; Thu, 27 Jun 2013 11:48:26 -0700 (PDT) From: Doug Anderson To: linux-kernel@vger.kernel.org Cc: Mike Frysinger , Olof Johansson , Doug Anderson , Michal Marek , linux-kbuild@vger.kernel.org Subject: [PATCH] kbuild: Avoid race generating / using MODLIB Date: Thu, 27 Jun 2013 11:48:04 -0700 Message-Id: <1372358884-12269-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.3 X-Gm-Message-State: ALoCoQkq11sEcRKNuUkTYGhfhxPYE84QA1QE1NGi02XePGweaM6RinT5crQhQ80bIz2FZWDKpVdZ7NPc9pH9L8lem9gj6Tr5l3VrkOWDPRdz52JdbBWdCwGXyN95XCwkSqFY6V+2cj47Mew8R6pzg66hG1LHbwoFFMsXVY1uOfTaFlkq4FeeLrBsRrRGPY1zXV1t8Uu2okJmEFpiR2L262VYV4qakAIVBQ== Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 The $(MODLIB) variable is recursively expanded and is: $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) The $(KERNELRELEASE) variable is also recursively expanded: $(shell cat include/config/kernel.release 2> /dev/null) The file being read is a generated by the Makefile itself. When the file is generated it is removed and then recreated. This leaves a period of time when the file doesn't exist. If we happen to use $(MODLIB) during this time then we'll end up with a bad value. This is fairly easy for me to reproduce by: * Add a "sleep 2" between the 'rm -f $@' and the 'echo' in the rule to build 'include/config/kernel.release' * make -j32 ARCH=arm CROSS_COMPILE=armv7a-cros-linux-gnueabi- \ zImage dtbs modules * make -j32 ARCH=arm CROSS_COMPILE=armv7a-cros-linux-gnueabi- \ INSTALL_PATH=foo INSTALL_MOD_PATH=foomod \ install firmware_install modules_install Without trying to rethink the whole KERNELRELEASE variable, the simple fix is to just add a dependency. Signed-off-by: Doug Anderson --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0142c93..9cf2b24 100644 --- a/Makefile +++ b/Makefile @@ -964,7 +964,7 @@ PHONY += modules_install modules_install: _modinst_ _modinst_post PHONY += _modinst_ -_modinst_: +_modinst_: include/config/kernel.release @rm -rf $(MODLIB)/kernel @rm -f $(MODLIB)/source @mkdir -p $(MODLIB)/kernel @@ -1232,7 +1232,7 @@ modules_install: _emodinst_ _emodinst_post install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) PHONY += _emodinst_ -_emodinst_: +_emodinst_: include/config/kernel.release $(Q)mkdir -p $(MODLIB)/$(install-dir) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst