From: Nicholas Mc Guire <hofrat@osadl.org>
To: Michal Marek <mmarek@suse.cz>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>,
Sam Ravnborg <sam@ravnborg.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Alvin" <hpa@zytor.com>, Joe Perches <joe@perches.com>,
John Stultz <john.stultz@linaro.org>,
Andrew Hunter <ahh@google.com>, Paul Turner <pjt@google.com>,
Aaron Sierra <asierra@xes-inc.com>,
Brian Norris <computersforpeace@gmail.com>,
linux-kernel@vger.kernel.org,
Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH 1/3 V2] time: move timeconst.h into include/generated
Date: Sun, 12 Apr 2015 14:13:33 +0200 [thread overview]
Message-ID: <1428840815-21974-2-git-send-email-hofrat@osadl.org> (raw)
In-Reply-To: <1428840815-21974-1-git-send-email-hofrat@osadl.org>
kernel/time/timeconst.h is moved to include/generated/ and generated in
an early build stage by top level Kbuild. This allows using timeconst.h
in an earlier stage of the build.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Thanks to Joe Perches <joe@perches.com> for suggesting this approach and
catching the unconditional rebuild (should be fixed here now properly) as
well as for his review comments on the first attempts as well as for the
macro version that the reformatting of V2 re-uses.
V2: no changes in this one from V1
Some questions that remain:
* Kbuild - is passing in arguments to .bc files via pipe and read();
rather than using multiple files acceptable or is there some reason
for the original multi-file solution that Im overlooking ?
* conditional rebuild of timeconst.h with $(call filechk,gentimeconst)
not really clear if this is going to do all rebuilds that could be
necessary and not clear how to verify this. currently only checked by
1) defconfig -> build -> rebuild -> CHK is executed timeconst.h unmodified
2) defconfig -> build -> change HZ -> rebuild -> UPD timeconst.h resulting
in a rebuild of most files.
Patch was compile tested for x86_64_defconfig,multi_v7_defconfig,
ppc64_defconfig, and boot/run
tested on x86_64. Further a test-case with an invalid HZ value to trigger the
error output in kernel/time/timeconst.bc was run.
Patch is against 4.0-rc7 (localversion-next is -next-20150410)
Kbuild | 30 +++++++++++++++++++++++++-----
kernel/time/Makefile | 17 +----------------
kernel/time/time.c | 2 +-
kernel/time/timeconst.bc | 3 ++-
4 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/Kbuild b/Kbuild
index 6f0d82a..1d1aef5 100644
--- a/Kbuild
+++ b/Kbuild
@@ -2,8 +2,9 @@
# Kbuild for top-level directory of the kernel
# This file takes care of the following:
# 1) Generate bounds.h
-# 2) Generate asm-offsets.h (may need bounds.h)
-# 3) Check for missing system calls
+# 2) Generate timeconst.h
+# 3) Generate asm-offsets.h (may need bounds.h)
+# 4) Check for missing system calls
# Default sed regexp - multiline due to syntax constraints
define sed-y
@@ -47,7 +48,26 @@ $(obj)/$(bounds-file): kernel/bounds.s FORCE
$(call filechk,offsets,__LINUX_BOUNDS_H__)
#####
-# 2) Generate asm-offsets.h
+# 2) Generate timeconst.h
+
+timeconst-file := include/generated/timeconst.h
+
+always += $(timeconst-file)
+targets += $(timeconst-file)
+
+quiet_cmd_gentimeconst = GEN $@
+define cmd_gentimeconst
+ (echo $(CONFIG_HZ) | bc -q $< ) > $@
+endef
+define filechk_gentimeconst
+ (echo $(CONFIG_HZ) | bc -q $< )
+endef
+
+$(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
+ $(call filechk,gentimeconst)
+
+#####
+# 3) Generate asm-offsets.h
#
offsets-file := include/generated/asm-offsets.h
@@ -65,7 +85,7 @@ $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
$(call filechk,offsets,__ASM_OFFSETS_H__)
#####
-# 3) Check for missing system calls
+# 4) Check for missing system calls
#
always += missing-syscalls
@@ -78,4 +98,4 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
$(call cmd,syscalls)
# Keep these two files during make clean
-no-clean-files := $(bounds-file) $(offsets-file)
+no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
diff --git a/kernel/time/Makefile b/kernel/time/Makefile
index 01f0312..ffc4cc3 100644
--- a/kernel/time/Makefile
+++ b/kernel/time/Makefile
@@ -13,19 +13,4 @@ obj-$(CONFIG_TIMER_STATS) += timer_stats.o
obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o
obj-$(CONFIG_TEST_UDELAY) += test_udelay.o
-$(obj)/time.o: $(obj)/timeconst.h
-
-quiet_cmd_hzfile = HZFILE $@
- cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@
-
-targets += hz.bc
-$(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE
- $(call if_changed,hzfile)
-
-quiet_cmd_bc = BC $@
- cmd_bc = bc -q $(filter-out FORCE,$^) > $@
-
-targets += timeconst.h
-$(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE
- $(call if_changed,bc)
-
+$(obj)/time.o: $(objtree)/include/config/
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 2c85b77..4fa1d26 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -41,7 +41,7 @@
#include <asm/uaccess.h>
#include <asm/unistd.h>
-#include "timeconst.h"
+#include <generated/timeconst.h>
#include "timekeeping.h"
/*
diff --git a/kernel/time/timeconst.bc b/kernel/time/timeconst.bc
index 511bdf2..c7388de 100644
--- a/kernel/time/timeconst.bc
+++ b/kernel/time/timeconst.bc
@@ -50,7 +50,7 @@ define timeconst(hz) {
print "#include <linux/types.h>\n\n"
print "#if HZ != ", hz, "\n"
- print "#error \qkernel/timeconst.h has the wrong HZ value!\q\n"
+ print "#error \qinclude/generated/timeconst.h has the wrong HZ value!\q\n"
print "#endif\n\n"
if (hz < 2) {
@@ -105,4 +105,5 @@ define timeconst(hz) {
halt
}
+hz = read();
timeconst(hz)
--
1.7.10.4
next prev parent reply other threads:[~2015-04-12 12:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-12 12:13 [PATCH 0/3 V2] time: use __builtin_constant_p() in msecs_to_jiffies Nicholas Mc Guire
2015-04-12 12:13 ` Nicholas Mc Guire [this message]
2015-04-12 21:35 ` [PATCH 1/3 V2] time: move timeconst.h into include/generated Rob Landley
2015-04-12 12:13 ` [PATCH 2/3 V2] time: allow gcc to fold constants when using Nicholas Mc Guire
2015-04-22 12:00 ` Thomas Gleixner
2015-04-22 14:18 ` Joe Perches
2015-04-22 15:12 ` Nicholas Mc Guire
2015-04-22 14:36 ` Nicholas Mc Guire
2015-04-22 14:44 ` Thomas Gleixner
2015-04-12 12:13 ` [PATCH 3/3 V2] time: update msecs_to_jiffies doc and move to kernel-doc Nicholas Mc Guire
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=1428840815-21974-2-git-send-email-hofrat@osadl.org \
--to=hofrat@osadl.org \
--cc=ahh@google.com \
--cc=asierra@xes-inc.com \
--cc=computersforpeace@gmail.com \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=pjt@google.com \
--cc=sam@ravnborg.org \
--cc=tglx@linutronix.de \
--cc=yamada.m@jp.panasonic.com \
/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®