Skip to content

Commit

Permalink
locking/atomics: Check generated headers are up-to-date
Browse files Browse the repository at this point in the history
Now that all the generated atomic headers are in place, it would be good
to ensure that:

a) the headers are up-to-date when scripting changes.

b) developers don't directly modify the generated headers.

To ensure both of these properties, let's add a Kbuild step to check
that the generated headers are up-to-date.

Signed-off-by: Mark Rutland <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Boqun Feng <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Mark Rutland authored and Ingo Molnar committed Nov 1, 2018
1 parent aa525d0 commit 8d32588
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# 2) Generate timeconst.h
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
# 4) Check for missing system calls
# 5) Generate constants.py (may need bounds.h)
# 5) check atomics headers are up-to-date
# 6) Generate constants.py (may need bounds.h)

#####
# 1) Generate bounds.h
Expand Down Expand Up @@ -72,7 +73,20 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
$(call cmd,syscalls)

#####
# 5) Generate constants for Python GDB integration
# 5) Check atomic headers are up-to-date
#

always += old-atomics
targets += old-atomics

quiet_cmd_atomics = CALL $<
cmd_atomics = $(CONFIG_SHELL) scripts/atomic/check-atomics.sh

old-atomics: scripts/atomic/check-atomics.sh FORCE
$(call cmd,atomics)

#####
# 6) Generate constants for Python GDB integration
#

extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
Expand Down
19 changes: 19 additions & 0 deletions scripts/atomic/check-atomics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Check if atomic headers are up-to-date

ATOMICDIR=$(dirname $0)
ATOMICTBL=${ATOMICDIR}/atomics.tbl
LINUXDIR=${ATOMICDIR}/../..

cat <<EOF |
gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h
gen-atomic-long.sh asm-generic/atomic-long.h
gen-atomic-fallback.sh linux/atomic-fallback.h
EOF
while read script header; do
if ! (${ATOMICDIR}/${script} ${ATOMICTBL} | diff - ${LINUXDIR}/include/${header} > /dev/null); then
printf "warning: include/${header} is out-of-date.\n"
fi
done

0 comments on commit 8d32588

Please sign in to comment.