Skip to content

Commit 00a2639

Browse files
jpoimboeacmel
authored andcommitted
perf intel-pt: Use shared x86 insn decoder
Now that there's a common version of the decoder for all tools, use it instead of the local copy. Also use perf's check-headers.sh script to diff the decoder files to make sure they remain in sync with the kernel version. Objtool has a similar check. Committer notes: Had to keep this all pointing explicitely to x86 headers/files, i.e. instead of asm/isnn.h we had to use ../include/asm/insn.h when the files were in differemt dirs, or just replace "<asm/foo.h>" with "foo.h". This way we continue to be able to process perf.data files with Intel PT traces in distros other than x86. Also fixed up the awk script paths to use $(srcdir)/tools/arch instead or relative directories so that we keep detached tarballs (make help | grep perf) working. For now the include lines in these headers are being ignored so as not to flag false reports of kernel/tools out of sync. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/8a37e615d2880f039505d693d1e068a009358a2b.1567118001.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f1da0a6 commit 00a2639

16 files changed

Lines changed: 23 additions & 2632 deletions

File tree

‎tools/arch/x86/include/asm/inat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Written by Masami Hiramatsu <mhiramat@redhat.com>
88
*/
9-
#include <asm/inat_types.h>
9+
#include "inat_types.h"
1010

1111
/*
1212
* Internal bits. Don't use bitmasks directly, because these bits are

‎tools/arch/x86/include/asm/insn.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
/* insn_attr_t is defined in inat.h */
11-
#include <asm/inat.h>
11+
#include "inat.h"
1212

1313
struct insn_field {
1414
union {

‎tools/arch/x86/lib/inat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Written by Masami Hiramatsu <mhiramat@redhat.com>
66
*/
7-
#include <asm/insn.h>
7+
#include "../include/asm/insn.h"
88

99
/* Attribute tables are generated from opcode map */
1010
#include "inat-tables.c"

‎tools/arch/x86/lib/insn.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#else
1111
#include <string.h>
1212
#endif
13-
#include <asm/inat.h>
14-
#include <asm/insn.h>
13+
#include "../include/asm/inat.h"
14+
#include "../include/asm/insn.h"
1515

1616
/* Verify next sizeof(t) bytes can be on the same instruction */
1717
#define validate_next(t, insn, n) \

‎tools/perf/arch/x86/tests/insn-x86.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/types.h>
3+
#include "../../../../arch/x86/include/asm/insn.h"
34
#include <string.h>
45

56
#include "debug.h"
67
#include "tests/tests.h"
78
#include "arch-tests.h"
89

9-
#include "intel-pt-decoder/insn.h"
1010
#include "intel-pt-decoder/intel-pt-insn-decoder.h"
1111

1212
struct test_data {

‎tools/perf/arch/x86/util/archinsn.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#include "../../../../arch/x86/include/asm/insn.h"
23
#include "archinsn.h"
3-
#include "util/intel-pt-decoder/insn.h"
44
#include "machine.h"
55
#include "thread.h"
66
#include "symbol.h"

‎tools/perf/check-headers.sh‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: GPL-2.0
33

4-
HEADERS='
4+
FILES='
55
include/uapi/linux/const.h
66
include/uapi/drm/drm.h
77
include/uapi/drm/i915_drm.h
@@ -26,7 +26,14 @@ include/uapi/linux/hw_breakpoint.h
2626
arch/x86/include/asm/disabled-features.h
2727
arch/x86/include/asm/required-features.h
2828
arch/x86/include/asm/cpufeatures.h
29+
arch/x86/include/asm/inat.h
30+
arch/x86/include/asm/inat_types.h
31+
arch/x86/include/asm/insn.h
2932
arch/x86/include/uapi/asm/prctl.h
33+
arch/x86/lib/inat.c
34+
arch/x86/lib/insn.c
35+
arch/x86/lib/x86-opcode-map.txt
36+
arch/x86/tools/gen-insn-attr-x86.awk
3037
arch/arm/include/uapi/asm/perf_regs.h
3138
arch/arm64/include/uapi/asm/perf_regs.h
3239
arch/powerpc/include/uapi/asm/perf_regs.h
@@ -98,7 +105,7 @@ test -d ../../include || exit 0
98105
cd ../..
99106

100107
# simple diff check
101-
for i in $HEADERS; do
108+
for i in $FILES; do
102109
check $i -B
103110
done
104111

‎tools/perf/util/intel-pt-decoder/Build‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
22

3-
inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
4-
inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
3+
inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk
4+
inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt
55

66
$(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
77
$(call rule_mkdir)
@@ -10,22 +10,6 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table
1010
# Busybox's diff doesn't have -I, avoid warning in the case
1111

1212
$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
13-
@(diff -I 2>&1 | grep -q 'option requires an argument' && \
14-
test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
15-
((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \
16-
(echo "Warning: Intel PT: x86 instruction decoder C file at 'tools/perf/util/intel-pt-decoder/insn.c' differs from latest version at 'arch/x86/lib/insn.c'" >&2)) && \
17-
((diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null) || \
18-
(echo "Warning: Intel PT: x86 instruction decoder C file at 'tools/perf/util/intel-pt-decoder/inat.c' differs from latest version at 'arch/x86/lib/inat.c'" >&2)) && \
19-
((diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null) || \
20-
(echo "Warning: Intel PT: x86 instruction decoder map file at 'tools/perf/util/intel-pt-decoder/x86-opcode-map.txt' differs from latest version at 'arch/x86/lib/x86-opcode-map.txt'" >&2)) && \
21-
((diff -B util/intel-pt-decoder/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null) || \
22-
(echo "Warning: Intel PT: x86 instruction decoder script at 'tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk' differs from latest version at 'arch/x86/tools/gen-insn-attr-x86.awk'" >&2)) && \
23-
((diff -B -I'^#include' util/intel-pt-decoder/insn.h ../../arch/x86/include/asm/insn.h >/dev/null) || \
24-
(echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'" >&2)) && \
25-
((diff -B -I'^#include' util/intel-pt-decoder/inat.h ../../arch/x86/include/asm/inat.h >/dev/null) || \
26-
(echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h'" >&2)) && \
27-
((diff -B -I'^#include' util/intel-pt-decoder/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) || \
28-
(echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/inat_types.h' differs from latest version at 'arch/x86/include/asm/inat_types.h'" >&2)))) || true
2913
$(call rule_mkdir)
3014
$(call if_changed_dep,cc_o_c)
3115

0 commit comments

Comments
 (0)