From: Doug Anderson <dianders@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Mike Frysinger <vapier@gentoo.org>,
Olof Johansson <olof@lixom.net>,
Doug Anderson <dianders@chromium.org>,
Michal Marek <mmarek@suse.cz>,
linux-kbuild@vger.kernel.org
Subject: [PATCH] kbuild: Avoid race generating / using MODLIB
Date: Thu, 27 Jun 2013 11:48:04 -0700 [thread overview]
Message-ID: <1372358884-12269-1-git-send-email-dianders@chromium.org> (raw)
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 <dianders@chromium.org>
---
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
--
1.8.3
reply other threads:[~2013-06-27 18:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1372358884-12269-1-git-send-email-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=olof@lixom.net \
--cc=vapier@gentoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®