Commit d6748385 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

tools headers: Make the difference output easier to read

Add failures to an array and display it before exiting.

Before:

  Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h' differs from latest version at 'include/uapi/linux/perf_event.h'
  diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
  Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
  diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
  Warning: Kernel ABI header at 'tools/arch/arm64/include/asm/cputype.h' differs from latest version at 'arch/arm64/include/asm/cputype.h'
  diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
  ...

After:

  Warning: Kernel ABI header differences:
    diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
    diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
    diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
  ...

The aim is to make the warnings easier to read and distinguish from
other Makefile warnings messages.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230605203425.1696844-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b541a917
#!/bin/sh #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
FILES=' YELLOW='\033[0;33m'
include/uapi/linux/const.h NC='\033[0m' # No Color
include/uapi/drm/drm.h
include/uapi/drm/i915_drm.h declare -a FILES
include/uapi/linux/fadvise.h FILES=(
include/uapi/linux/fcntl.h "include/uapi/linux/const.h"
include/uapi/linux/fs.h "include/uapi/drm/drm.h"
include/uapi/linux/fscrypt.h "include/uapi/drm/i915_drm.h"
include/uapi/linux/kcmp.h "include/uapi/linux/fadvise.h"
include/uapi/linux/kvm.h "include/uapi/linux/fcntl.h"
include/uapi/linux/in.h "include/uapi/linux/fs.h"
include/uapi/linux/mount.h "include/uapi/linux/fscrypt.h"
include/uapi/linux/openat2.h "include/uapi/linux/kcmp.h"
include/uapi/linux/perf_event.h "include/uapi/linux/kvm.h"
include/uapi/linux/prctl.h "include/uapi/linux/in.h"
include/uapi/linux/sched.h "include/uapi/linux/mount.h"
include/uapi/linux/stat.h "include/uapi/linux/openat2.h"
include/uapi/linux/usbdevice_fs.h "include/uapi/linux/perf_event.h"
include/uapi/linux/vhost.h "include/uapi/linux/prctl.h"
include/uapi/sound/asound.h "include/uapi/linux/sched.h"
include/linux/bits.h "include/uapi/linux/stat.h"
include/vdso/bits.h "include/uapi/linux/usbdevice_fs.h"
include/linux/const.h "include/uapi/linux/vhost.h"
include/vdso/const.h "include/uapi/sound/asound.h"
include/linux/hash.h "include/linux/bits.h"
include/linux/list-sort.h "include/vdso/bits.h"
include/uapi/linux/hw_breakpoint.h "include/linux/const.h"
arch/x86/include/asm/disabled-features.h "include/vdso/const.h"
arch/x86/include/asm/required-features.h "include/linux/hash.h"
arch/x86/include/asm/cpufeatures.h "include/linux/list-sort.h"
arch/x86/include/asm/inat_types.h "include/uapi/linux/hw_breakpoint.h"
arch/x86/include/asm/emulate_prefix.h "arch/x86/include/asm/disabled-features.h"
arch/x86/include/asm/irq_vectors.h "arch/x86/include/asm/required-features.h"
arch/x86/include/asm/msr-index.h "arch/x86/include/asm/cpufeatures.h"
arch/x86/include/uapi/asm/prctl.h "arch/x86/include/asm/inat_types.h"
arch/x86/lib/x86-opcode-map.txt "arch/x86/include/asm/emulate_prefix.h"
arch/x86/tools/gen-insn-attr-x86.awk "arch/x86/include/asm/irq_vectors.h"
arch/arm/include/uapi/asm/perf_regs.h "arch/x86/include/asm/msr-index.h"
arch/arm64/include/uapi/asm/perf_regs.h "arch/x86/include/uapi/asm/prctl.h"
arch/loongarch/include/uapi/asm/perf_regs.h "arch/x86/lib/x86-opcode-map.txt"
arch/mips/include/uapi/asm/perf_regs.h "arch/x86/tools/gen-insn-attr-x86.awk"
arch/powerpc/include/uapi/asm/perf_regs.h "arch/arm/include/uapi/asm/perf_regs.h"
arch/s390/include/uapi/asm/perf_regs.h "arch/arm64/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/perf_regs.h "arch/loongarch/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/kvm.h "arch/mips/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/kvm_perf.h "arch/powerpc/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/svm.h "arch/s390/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/unistd.h "arch/x86/include/uapi/asm/perf_regs.h"
arch/x86/include/uapi/asm/vmx.h "arch/x86/include/uapi/asm/kvm.h"
arch/powerpc/include/uapi/asm/kvm.h "arch/x86/include/uapi/asm/kvm_perf.h"
arch/s390/include/uapi/asm/kvm.h "arch/x86/include/uapi/asm/svm.h"
arch/s390/include/uapi/asm/kvm_perf.h "arch/x86/include/uapi/asm/unistd.h"
arch/s390/include/uapi/asm/sie.h "arch/x86/include/uapi/asm/vmx.h"
arch/arm/include/uapi/asm/kvm.h "arch/powerpc/include/uapi/asm/kvm.h"
arch/arm64/include/uapi/asm/kvm.h "arch/s390/include/uapi/asm/kvm.h"
arch/arm64/include/uapi/asm/unistd.h "arch/s390/include/uapi/asm/kvm_perf.h"
arch/alpha/include/uapi/asm/errno.h "arch/s390/include/uapi/asm/sie.h"
arch/mips/include/asm/errno.h "arch/arm/include/uapi/asm/kvm.h"
arch/mips/include/uapi/asm/errno.h "arch/arm64/include/uapi/asm/kvm.h"
arch/parisc/include/uapi/asm/errno.h "arch/arm64/include/uapi/asm/unistd.h"
arch/powerpc/include/uapi/asm/errno.h "arch/alpha/include/uapi/asm/errno.h"
arch/sparc/include/uapi/asm/errno.h "arch/mips/include/asm/errno.h"
arch/x86/include/uapi/asm/errno.h "arch/mips/include/uapi/asm/errno.h"
include/asm-generic/bitops/arch_hweight.h "arch/parisc/include/uapi/asm/errno.h"
include/asm-generic/bitops/const_hweight.h "arch/powerpc/include/uapi/asm/errno.h"
include/asm-generic/bitops/__fls.h "arch/sparc/include/uapi/asm/errno.h"
include/asm-generic/bitops/fls.h "arch/x86/include/uapi/asm/errno.h"
include/asm-generic/bitops/fls64.h "include/asm-generic/bitops/arch_hweight.h"
include/linux/coresight-pmu.h "include/asm-generic/bitops/const_hweight.h"
include/uapi/asm-generic/errno.h "include/asm-generic/bitops/__fls.h"
include/uapi/asm-generic/errno-base.h "include/asm-generic/bitops/fls.h"
include/uapi/asm-generic/ioctls.h "include/asm-generic/bitops/fls64.h"
include/uapi/asm-generic/mman-common.h "include/linux/coresight-pmu.h"
include/uapi/asm-generic/unistd.h "include/uapi/asm-generic/errno.h"
' "include/uapi/asm-generic/errno-base.h"
"include/uapi/asm-generic/ioctls.h"
SYNC_CHECK_FILES=' "include/uapi/asm-generic/mman-common.h"
arch/x86/include/asm/inat.h "include/uapi/asm-generic/unistd.h"
arch/x86/include/asm/insn.h )
arch/x86/lib/inat.c
arch/x86/lib/insn.c declare -a SYNC_CHECK_FILES
' SYNC_CHECK_FILES=(
"arch/x86/include/asm/inat.h"
"arch/x86/include/asm/insn.h"
"arch/x86/lib/inat.c"
"arch/x86/lib/insn.c"
)
# These copies are under tools/perf/trace/beauty/ as they are not used to in # These copies are under tools/perf/trace/beauty/ as they are not used to in
# building object files only by scripts in tools/perf/trace/beauty/ to generate # building object files only by scripts in tools/perf/trace/beauty/ to generate
# tables that then gets included in .c files for things like id->string syscall # tables that then gets included in .c files for things like id->string syscall
# tables (and the reverse lookup as well: string -> id) # tables (and the reverse lookup as well: string -> id)
BEAUTY_FILES=' declare -a BEAUTY_FILES
include/linux/socket.h BEAUTY_FILES=(
' "include/linux/socket.h"
)
declare -a FAILURES
check_2 () { check_2 () {
file1=$1 tools_file=$1
file2=$2 orig_file=$2
shift shift
shift shift
cmd="diff $* $file1 $file2 > /dev/null" cmd="diff $* $tools_file $orig_file > /dev/null"
test -f $file2 && { if [ -f "$orig_file" ] && ! eval "$cmd"
eval $cmd || { then
echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2 FAILURES+=(
echo diff -u $file1 $file2 "$tools_file $orig_file"
} )
} fi
} }
check () { check () {
...@@ -115,7 +123,7 @@ check () { ...@@ -115,7 +123,7 @@ check () {
shift shift
check_2 tools/$file $file $* check_2 "tools/$file" "$file" $*
} }
beauty_check () { beauty_check () {
...@@ -123,23 +131,29 @@ beauty_check () { ...@@ -123,23 +131,29 @@ beauty_check () {
shift shift
check_2 tools/perf/trace/beauty/$file $file $* check_2 "tools/perf/trace/beauty/$file" "$file" $*
} }
# Check if we have the kernel headers (tools/perf/../../include), else # Check if we have the kernel headers (tools/perf/../../include), else
# we're probably on a detached tarball, so no point in trying to check # we're probably on a detached tarball, so no point in trying to check
# differences. # differences.
test -d ../../include || exit 0 if ! [ -d ../../include ]
then
echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include"
exit 0
fi
cd ../.. cd ../..
# simple diff check # simple diff check
for i in $FILES; do for i in "${FILES[@]}"
check $i -B do
check "$i" -B
done done
for i in $SYNC_CHECK_FILES; do for i in "${SYNC_CHECK_FILES[@]}"
check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"' do
check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
done done
# diff with extra ignore lines # diff with extra ignore lines
...@@ -160,8 +174,9 @@ check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/s ...@@ -160,8 +174,9 @@ check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/s
check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
for i in $BEAUTY_FILES; do for i in "${BEAUTY_FILES[@]}"
beauty_check $i -B do
beauty_check "$i" -B
done done
# check duplicated library files # check duplicated library files
...@@ -169,3 +184,12 @@ check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h ...@@ -169,3 +184,12 @@ check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
cd tools/perf cd tools/perf
if [ ${#FAILURES[@]} -gt 0 ]
then
echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:"
for i in "${FAILURES[@]}"
do
echo " diff -u $i"
done
fi
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