Commit 24915609 authored by Mark Rutland's avatar Mark Rutland Committed by Stephen Rothwell

locking/atomics: build atomic headers as required

Andrew and Ingo report that the check-atomics.sh script is simply too slow
to run for every kernel build, and it's impractical to make it faster
without rewriting it in something other than shell.

Rather than committing the generated headers, let's regenerate these
as-required for a pristine tree.

That ensures they're always up-to-date, allows them to be built in
parallel, and avoid redundant rebuilds, which is a 2-8s saving per
incremental build.  Since the results are not committed, it's very obvious
that they should not be modified directly.  If we need to generate more
headers in future, it's easy to extend Makefile.genheader to permit this.

I've verified that this works in the cases we previously had issues with
(out-of-tree builds and where scripts have no execute permissions), and
have tested these cases for both x86_64 and arm64.

The diffstat looks nice, at least...

Link: http://lkml.kernel.org/r/20181123153321.8561-1-mark.rutland@arm.comSigned-off-by: 's avatarMark Rutland <mark.rutland@arm.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: 's avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: 's avatarStephen Rothwell <sfr@canb.auug.org.au>
parent 3a1b0720
......@@ -6,8 +6,7 @@
# 2) Generate timeconst.h
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
# 4) Check for missing system calls
# 5) check atomics headers are up-to-date
# 6) Generate constants.py (may need bounds.h)
# 5) Generate constants.py (may need bounds.h)
#####
# 1) Generate bounds.h
......@@ -60,20 +59,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
$(call cmd,syscalls)
#####
# 5) Check atomic headers are up-to-date
#
always += old-atomics
targets += old-atomics
quiet_cmd_atomics = CALL $<
cmd_atomics = $(CONFIG_SHELL) $<
old-atomics: scripts/atomic/check-atomics.sh FORCE
$(call cmd,atomics)
#####
# 6) Generate constants for Python GDB integration
# 5) Generate constants for Python GDB integration
#
extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
......
......@@ -234,7 +234,7 @@ clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers_% archheaders archscripts \
%asm-generic kernelversion %src-pkg
%asm-generic genheader kernelversion %src-pkg
no-sync-config-targets := $(no-dot-config-targets) install %install \
kernelrelease
......@@ -1080,7 +1080,7 @@ endif
# prepare2 creates a makefile if using a separate output directory.
# From this point forward, .config has been reprocessed, so any rules
# that need to depend on updated CONFIG_* values can be checked here.
prepare2: prepare3 outputmakefile asm-generic
prepare2: prepare3 outputmakefile asm-generic genheader
prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
$(cmd_crmodverdir)
......@@ -1103,6 +1103,10 @@ asm-generic: uapi-asm-generic
uapi-asm-generic:
$(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm
PHONY += genheader
genheader:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.genheader obj=include/generated
PHONY += prepare-objtool
prepare-objtool: $(objtool_target)
ifeq ($(SKIP_STACK_VALIDATION),1)
......
......@@ -166,7 +166,7 @@
#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
#include <asm-generic/atomic-instrumented.h>
#include <generated/atomic-instrumented.h>
#endif
#endif
......@@ -262,6 +262,6 @@ static inline int arch_atomic_fetch_xor(int i, atomic_t *v)
# include <asm/atomic64_64.h>
#endif
#include <asm-generic/atomic-instrumented.h>
#include <generated/atomic-instrumented.h>
#endif /* _ASM_X86_ATOMIC_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -71,8 +71,8 @@
__ret; \
})
#include <linux/atomic-fallback.h>
#include <generated/atomic-fallback.h>
#include <asm-generic/atomic-long.h>
#include <generated/atomic-long.h>
#endif /* _LINUX_ATOMIC_H */
# SPDX-License-Identifier: GPL-2.0
#
# Generate common headers under include/generated/
include scripts/Kbuild.include
atomics-dir := $(srctree)/scripts/atomic
atomic-tbl := $(atomics-dir)/atomics.tbl
.PHONY: all
targets += atomic-fallback.h
targets += atomic-instrumented.h
targets += atomic-long.h
all: $(addprefix $(obj)/,$(targets))
quiet_cmd_genheader = GENHDR $@
cmd_genheader = $(CONFIG_SHELL) $^ >$@
$(obj)/atomic-%.h: $(atomics-dir)/gen-atomic-%.sh $(atomic-tbl)
$(call if_changed,genheader)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment