Skip to contentSkip to conversation

objtool,perf: Use shared x86 insn decoder

PATCH Applied Josh Poimboeuf 5 participants 24 messages Aug 29, 2019 – Sep 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover objtool,perf: Use shared x86 insn decoder

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

 .../{objtool => }/arch/x86/include/asm/inat.h |    0
 .../arch/x86/include/asm/inat_types.h         |    0
 .../{objtool => }/arch/x86/include/asm/insn.h |    0
 .../arch/x86/include/asm/orc_types.h          |    0
 tools/{objtool => }/arch/x86/lib/inat.c       |    0
 tools/{objtool => }/arch/x86/lib/insn.c       |    0
 .../arch/x86/lib/x86-opcode-map.txt           |    0
 .../arch/x86/tools/gen-insn-attr-x86.awk      |    0
 tools/objtool/Makefile                        |    4 +-
 tools/objtool/arch/x86/Build                  |    4 +-
 tools/objtool/arch/x86/decode.c               |    4 +-
 tools/objtool/sync-check.sh                   |   12 +-
 tools/perf/.gitignore                         |    3 +
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   22 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 25 files changed, 34 insertions(+), 2640 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/4 objtool: Move x86 insn decoder to a common location

The kernel tree has three identical copies of the x86 instruction decoder. Two of them are in the tools subdir.

The tools subdir is supposed to be completely standalone and separate from the kernel. So having at least one copy of the kernel decoder in the tools subdir is unavoidable. However, we don't need *two* of them.

Move objtool's copy of the decoder to a shared location, so that perf will also be able to use it.

---
 tools/{objtool => }/arch/x86/include/asm/inat.h      |  0
 .../{objtool => }/arch/x86/include/asm/inat_types.h  |  0
 tools/{objtool => }/arch/x86/include/asm/insn.h      |  0
 tools/{objtool => }/arch/x86/include/asm/orc_types.h |  0
 tools/{objtool => }/arch/x86/lib/inat.c              |  0
 tools/{objtool => }/arch/x86/lib/insn.c              |  0
 tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt  |  0
 .../arch/x86/tools/gen-insn-attr-x86.awk             |  0
 tools/objtool/Makefile                               |  4 ++--
 tools/objtool/arch/x86/Build                         |  4 ++--
 tools/objtool/arch/x86/decode.c                      |  4 ++--
 tools/objtool/sync-check.sh                          | 12 ++++++------
 12 files changed, 12 insertions(+), 12 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
tools/arch/x86/include/asm/inat.h renamed from tools/objtool/arch/x86/include/asm/inat.h +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/include/asm/inat.h
rename to tools/arch/x86/include/asm/inat.h
tools/arch/x86/include/asm/inat_types.h renamed from tools/objtool/arch/x86/include/asm/inat_types.h +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/include/asm/inat_types.h
rename to tools/arch/x86/include/asm/inat_types.h
tools/arch/x86/include/asm/insn.h renamed from tools/objtool/arch/x86/include/asm/insn.h +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/include/asm/insn.h
rename to tools/arch/x86/include/asm/insn.h
tools/arch/x86/include/asm/orc_types.h renamed from tools/objtool/arch/x86/include/asm/orc_types.h +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/include/asm/orc_types.h
rename to tools/arch/x86/include/asm/orc_types.h
tools/arch/x86/lib/inat.c renamed from tools/objtool/arch/x86/lib/inat.c +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/lib/inat.c
rename to tools/arch/x86/lib/inat.c
tools/arch/x86/lib/insn.c renamed from tools/objtool/arch/x86/lib/insn.c +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/lib/insn.c
rename to tools/arch/x86/lib/insn.c
tools/arch/x86/lib/x86-opcode-map.txt renamed from tools/objtool/arch/x86/lib/x86-opcode-map.txt +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/lib/x86-opcode-map.txt
rename to tools/arch/x86/lib/x86-opcode-map.txt
tools/arch/x86/tools/gen-insn-attr-x86.awk renamed from tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk +0 -0
similarity index 100%
rename from tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk
rename to tools/arch/x86/tools/gen-insn-attr-x86.awk
tools/objtool/Makefile +2 -2
index 88158239622b..8c9b9adc67ef 100644
@@ -33,7 +33,7 @@ all: $(OBJTOOL)
 
 INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
-	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
+	    -I$(srctree)/tools/arch/$(ARCH)/include
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
 CFLAGS   += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
 LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
@@ -60,7 +60,7 @@ $(LIBSUBCMD): fixdep FORCE
 clean:
 	$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
 	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
-	$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
+	$(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep
 
 FORCE:
 
tools/objtool/arch/x86/Build +2 -2
index b998412c017d..7c5004008e97 100644
@@ -1,7 +1,7 @@
 objtool-y += decode.o
 
-inat_tables_script = arch/x86/tools/gen-insn-attr-x86.awk
-inat_tables_maps = arch/x86/lib/x86-opcode-map.txt
+inat_tables_script = ../arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = ../arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)arch/x86/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)
tools/objtool/arch/x86/decode.c +2 -2
index 0567c47a91b1..a62e032863a8 100644
@@ -8,8 +8,8 @@
 
 #define unlikely(cond) (cond)
 #include <asm/insn.h>
-#include "lib/inat.c"
-#include "lib/insn.c"
+#include "../../../arch/x86/lib/inat.c"
+#include "../../../arch/x86/lib/insn.c"
 
 #include "../../elf.h"
 #include "../../arch.h"
tools/objtool/sync-check.sh +6 -6
index 1470e74e9d66..66f1575b80f3 100755
@@ -2,21 +2,21 @@
 # SPDX-License-Identifier: GPL-2.0
 
 FILES='
-arch/x86/lib/insn.c
-arch/x86/lib/inat.c
-arch/x86/lib/x86-opcode-map.txt
-arch/x86/tools/gen-insn-attr-x86.awk
-arch/x86/include/asm/insn.h
 arch/x86/include/asm/inat.h
 arch/x86/include/asm/inat_types.h
+arch/x86/include/asm/insn.h
 arch/x86/include/asm/orc_types.h
+arch/x86/lib/inat.c
+arch/x86/lib/insn.c
+arch/x86/lib/x86-opcode-map.txt
+arch/x86/tools/gen-insn-attr-x86.awk
 '
 
 check()
 {
 	local file=$1
 
-	diff $file ../../$file > /dev/null ||
+	diff ../$file ../../$file > /dev/null ||
 		echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'"
 }
 
Signature · 1 line
2.20.1
merge bot Applied
#2 lore raw

[tip: perf/core] objtool: Move x86 insn decoder to a common location

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     d046b725487a97a3a3b35a00e84ca093963b8b4e
Gitweb:        https://git.kernel.org/tip/d046b725487a97a3a3b35a00e84ca093963b8b4e
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 29 Aug 2019 17:41:18 -05:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

objtool: Move x86 insn decoder to a common location

The kernel tree has three identical copies of the x86 instruction decoder. Two of them are in the tools subdir.

The tools subdir is supposed to be completely standalone and separate from the kernel. So having at least one copy of the kernel decoder in the tools subdir is unavoidable. However, we don't need *two* of them.

Move objtool's copy of the decoder to a shared location, so that perf will also be able to use it.

---
 tools/arch/x86/include/asm/inat.h                  |  230 ++-
 tools/arch/x86/include/asm/inat_types.h            |   15 +-
 tools/arch/x86/include/asm/insn.h                  |  216 ++-
 tools/arch/x86/include/asm/orc_types.h             |   97 +-
 tools/arch/x86/lib/inat.c                          |   83 +-
 tools/arch/x86/lib/insn.c                          |  593 ++++++-
 tools/arch/x86/lib/x86-opcode-map.txt              | 1072 +++++++++++-
 tools/arch/x86/tools/gen-insn-attr-x86.awk         |  393 ++++-
 tools/objtool/Makefile                             |    4 +-
 tools/objtool/arch/x86/Build                       |    4 +-
 tools/objtool/arch/x86/decode.c                    |    4 +-
 tools/objtool/arch/x86/include/asm/inat.h          |  230 +--
 tools/objtool/arch/x86/include/asm/inat_types.h    |   15 +-
 tools/objtool/arch/x86/include/asm/insn.h          |  216 +--
 tools/objtool/arch/x86/include/asm/orc_types.h     |   97 +-
 tools/objtool/arch/x86/lib/inat.c                  |   83 +-
 tools/objtool/arch/x86/lib/insn.c                  |  593 +------
 tools/objtool/arch/x86/lib/x86-opcode-map.txt      | 1072 +-----------
 tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk |  393 +----
 tools/objtool/sync-check.sh                        |   12 +-
 20 files changed, 2711 insertions(+), 2711 deletions(-)
 create mode 100644 tools/arch/x86/include/asm/inat.h
 create mode 100644 tools/arch/x86/include/asm/inat_types.h
 create mode 100644 tools/arch/x86/include/asm/insn.h
 create mode 100644 tools/arch/x86/include/asm/orc_types.h
 create mode 100644 tools/arch/x86/lib/inat.c
 create mode 100644 tools/arch/x86/lib/insn.c
 create mode 100644 tools/arch/x86/lib/x86-opcode-map.txt
 create mode 100644 tools/arch/x86/tools/gen-insn-attr-x86.awk
 delete mode 100644 tools/objtool/arch/x86/include/asm/inat.h
 delete mode 100644 tools/objtool/arch/x86/include/asm/inat_types.h
 delete mode 100644 tools/objtool/arch/x86/include/asm/insn.h
 delete mode 100644 tools/objtool/arch/x86/include/asm/orc_types.h
 delete mode 100644 tools/objtool/arch/x86/lib/inat.c
 delete mode 100644 tools/objtool/arch/x86/lib/insn.c
 delete mode 100644 tools/objtool/arch/x86/lib/x86-opcode-map.txt
 delete mode 100644 tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk
tools/arch/x86/include/asm/inat.h new file +230 -0
new file mode 100644
index 0000000..4cf2ad5
@@ -0,0 +1,230 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _ASM_X86_INAT_H
+#define _ASM_X86_INAT_H
+/*
+ * x86 instruction attributes
+ *
+ * Written by Masami Hiramatsu <[email protected]>
+ */
+#include <asm/inat_types.h>
+
+/*
+ * Internal bits. Don't use bitmasks directly, because these bits are
+ * unstable. You should use checking functions.
+ */
+
+#define INAT_OPCODE_TABLE_SIZE 256
+#define INAT_GROUP_TABLE_SIZE 8
+
+/* Legacy last prefixes */
+#define INAT_PFX_OPNDSZ	1	/* 0x66 */ /* LPFX1 */
+#define INAT_PFX_REPE	2	/* 0xF3 */ /* LPFX2 */
+#define INAT_PFX_REPNE	3	/* 0xF2 */ /* LPFX3 */
+/* Other Legacy prefixes */
+#define INAT_PFX_LOCK	4	/* 0xF0 */
+#define INAT_PFX_CS	5	/* 0x2E */
+#define INAT_PFX_DS	6	/* 0x3E */
+#define INAT_PFX_ES	7	/* 0x26 */
+#define INAT_PFX_FS	8	/* 0x64 */
+#define INAT_PFX_GS	9	/* 0x65 */
+#define INAT_PFX_SS	10	/* 0x36 */
+#define INAT_PFX_ADDRSZ	11	/* 0x67 */
+/* x86-64 REX prefix */
+#define INAT_PFX_REX	12	/* 0x4X */
+/* AVX VEX prefixes */
+#define INAT_PFX_VEX2	13	/* 2-bytes VEX prefix */
+#define INAT_PFX_VEX3	14	/* 3-bytes VEX prefix */
+#define INAT_PFX_EVEX	15	/* EVEX prefix */
+
+#define INAT_LSTPFX_MAX	3
+#define INAT_LGCPFX_MAX	11
+
+/* Immediate size */
+#define INAT_IMM_BYTE		1
+#define INAT_IMM_WORD		2
+#define INAT_IMM_DWORD		3
+#define INAT_IMM_QWORD		4
+#define INAT_IMM_PTR		5
+#define INAT_IMM_VWORD32	6
+#define INAT_IMM_VWORD		7
+
+/* Legacy prefix */
+#define INAT_PFX_OFFS	0
+#define INAT_PFX_BITS	4
+#define INAT_PFX_MAX    ((1 << INAT_PFX_BITS) - 1)
+#define INAT_PFX_MASK	(INAT_PFX_MAX << INAT_PFX_OFFS)
+/* Escape opcodes */
+#define INAT_ESC_OFFS	(INAT_PFX_OFFS + INAT_PFX_BITS)
+#define INAT_ESC_BITS	2
+#define INAT_ESC_MAX	((1 << INAT_ESC_BITS) - 1)
+#define INAT_ESC_MASK	(INAT_ESC_MAX << INAT_ESC_OFFS)
+/* Group opcodes (1-16) */
+#define INAT_GRP_OFFS	(INAT_ESC_OFFS + INAT_ESC_BITS)
+#define INAT_GRP_BITS	5
+#define INAT_GRP_MAX	((1 << INAT_GRP_BITS) - 1)
+#define INAT_GRP_MASK	(INAT_GRP_MAX << INAT_GRP_OFFS)
+/* Immediates */
+#define INAT_IMM_OFFS	(INAT_GRP_OFFS + INAT_GRP_BITS)
+#define INAT_IMM_BITS	3
+#define INAT_IMM_MASK	(((1 << INAT_IMM_BITS) - 1) << INAT_IMM_OFFS)
+/* Flags */
+#define INAT_FLAG_OFFS	(INAT_IMM_OFFS + INAT_IMM_BITS)
+#define INAT_MODRM	(1 << (INAT_FLAG_OFFS))
+#define INAT_FORCE64	(1 << (INAT_FLAG_OFFS + 1))
+#define INAT_SCNDIMM	(1 << (INAT_FLAG_OFFS + 2))
+#define INAT_MOFFSET	(1 << (INAT_FLAG_OFFS + 3))
+#define INAT_VARIANT	(1 << (INAT_FLAG_OFFS + 4))
+#define INAT_VEXOK	(1 << (INAT_FLAG_OFFS + 5))
+#define INAT_VEXONLY	(1 << (INAT_FLAG_OFFS + 6))
+#define INAT_EVEXONLY	(1 << (INAT_FLAG_OFFS + 7))
+/* Attribute making macros for attribute tables */
+#define INAT_MAKE_PREFIX(pfx)	(pfx << INAT_PFX_OFFS)
+#define INAT_MAKE_ESCAPE(esc)	(esc << INAT_ESC_OFFS)
+#define INAT_MAKE_GROUP(grp)	((grp << INAT_GRP_OFFS) | INAT_MODRM)
+#define INAT_MAKE_IMM(imm)	(imm << INAT_IMM_OFFS)
+
+/* Identifiers for segment registers */
+#define INAT_SEG_REG_IGNORE	0
+#define INAT_SEG_REG_DEFAULT	1
+#define INAT_SEG_REG_CS		2
+#define INAT_SEG_REG_SS		3
+#define INAT_SEG_REG_DS		4
+#define INAT_SEG_REG_ES		5
+#define INAT_SEG_REG_FS		6
+#define INAT_SEG_REG_GS		7
+
+/* Attribute search APIs */
+extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
+extern int inat_get_last_prefix_id(insn_byte_t last_pfx);
+extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode,
+					     int lpfx_id,
+					     insn_attr_t esc_attr);
+extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm,
+					    int lpfx_id,
+					    insn_attr_t esc_attr);
+extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode,
+					  insn_byte_t vex_m,
+					  insn_byte_t vex_pp);
+
+/* Attribute checking functions */
+static inline int inat_is_legacy_prefix(insn_attr_t attr)
+{
+	attr &= INAT_PFX_MASK;
+	return attr && attr <= INAT_LGCPFX_MAX;
+}
+
+static inline int inat_is_address_size_prefix(insn_attr_t attr)
+{
+	return (attr & INAT_PFX_MASK) == INAT_PFX_ADDRSZ;
+}
+
+static inline int inat_is_operand_size_prefix(insn_attr_t attr)
+{
+	return (attr & INAT_PFX_MASK) == INAT_PFX_OPNDSZ;
+}
+
+static inline int inat_is_rex_prefix(insn_attr_t attr)
+{
+	return (attr & INAT_PFX_MASK) == INAT_PFX_REX;
+}
+
+static inline int inat_last_prefix_id(insn_attr_t attr)
+{
+	if ((attr & INAT_PFX_MASK) > INAT_LSTPFX_MAX)
+		return 0;
+	else
+		return attr & INAT_PFX_MASK;
+}
+
+static inline int inat_is_vex_prefix(insn_attr_t attr)
+{
+	attr &= INAT_PFX_MASK;
+	return attr == INAT_PFX_VEX2 || attr == INAT_PFX_VEX3 ||
+	       attr == INAT_PFX_EVEX;
+}
+
+static inline int inat_is_evex_prefix(insn_attr_t attr)
+{
+	return (attr & INAT_PFX_MASK) == INAT_PFX_EVEX;
+}
+
+static inline int inat_is_vex3_prefix(insn_attr_t attr)
+{
+	return (attr & INAT_PFX_MASK) == INAT_PFX_VEX3;
+}
+
+static inline int inat_is_escape(insn_attr_t attr)
+{
+	return attr & INAT_ESC_MASK;
+}
+
+static inline int inat_escape_id(insn_attr_t attr)
+{
+	return (attr & INAT_ESC_MASK) >> INAT_ESC_OFFS;
+}
+
+static inline int inat_is_group(insn_attr_t attr)
+{
+	return attr & INAT_GRP_MASK;
+}
+
+static inline int inat_group_id(insn_attr_t attr)
+{
+	return (attr & INAT_GRP_MASK) >> INAT_GRP_OFFS;
+}
+
+static inline int inat_group_common_attribute(insn_attr_t attr)
+{
+	return attr & ~INAT_GRP_MASK;
+}
+
+static inline int inat_has_immediate(insn_attr_t attr)
+{
+	return attr & INAT_IMM_MASK;
+}
+
+static inline int inat_immediate_size(insn_attr_t attr)
+{
+	return (attr & INAT_IMM_MASK) >> INAT_IMM_OFFS;
+}
+
+static inline int inat_has_modrm(insn_attr_t attr)
+{
+	return attr & INAT_MODRM;
+}
+
+static inline int inat_is_force64(insn_attr_t attr)
+{
+	return attr & INAT_FORCE64;
+}
+
+static inline int inat_has_second_immediate(insn_attr_t attr)
+{
+	return attr & INAT_SCNDIMM;
+}
+
+static inline int inat_has_moffset(insn_attr_t attr)
+{
+	return attr & INAT_MOFFSET;
+}
+
+static inline int inat_has_variant(insn_attr_t attr)
+{
+	return attr & INAT_VARIANT;
+}
+
+static inline int inat_accept_vex(insn_attr_t attr)
+{
+	return attr & INAT_VEXOK;
+}
+
+static inline int inat_must_vex(insn_attr_t attr)
+{
+	return attr & (INAT_VEXONLY | INAT_EVEXONLY);
+}
+
+static inline int inat_must_evex(insn_attr_t attr)
+{
+	return attr & INAT_EVEXONLY;
+}
+#endif
tools/arch/x86/include/asm/inat_types.h new file +15 -0
new file mode 100644
index 0000000..b047efa
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _ASM_X86_INAT_TYPES_H
+#define _ASM_X86_INAT_TYPES_H
+/*
+ * x86 instruction attributes
+ *
+ * Written by Masami Hiramatsu <[email protected]>
+ */
+
+/* Instruction attributes */
+typedef unsigned int insn_attr_t;
+typedef unsigned char insn_byte_t;
+typedef signed int insn_value_t;
+
+#endif
tools/arch/x86/include/asm/insn.h new file +216 -0

216 lines not on this page · raw message

tools/arch/x86/include/asm/orc_types.h new file +97 -0

97 lines not on this page · raw message

tools/arch/x86/lib/inat.c new file +83 -0

83 lines not on this page · raw message

tools/arch/x86/lib/insn.c new file +593 -0

593 lines not on this page · raw message

tools/arch/x86/lib/x86-opcode-map.txt new file +1072 -0

1,072 lines not on this page · raw message

tools/arch/x86/tools/gen-insn-attr-x86.awk new file +393 -0

393 lines not on this page · raw message

tools/objtool/Makefile +2 -2
index 8815823..8c9b9ad 100644
@@ -33,7 +33,7 @@ all: $(OBJTOOL)
 
 INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
-	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
+	    -I$(srctree)/tools/arch/$(ARCH)/include
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
 CFLAGS   += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
 LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
@@ -60,7 +60,7 @@ $(LIBSUBCMD): fixdep FORCE
 clean:
 	$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
 	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
-	$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
+	$(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep
 
 FORCE:
 
tools/objtool/arch/x86/Build +2 -2
index b998412..7c50040 100644
@@ -1,7 +1,7 @@
 objtool-y += decode.o
 
-inat_tables_script = arch/x86/tools/gen-insn-attr-x86.awk
-inat_tables_maps = arch/x86/lib/x86-opcode-map.txt
+inat_tables_script = ../arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = ../arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)arch/x86/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)
tools/objtool/arch/x86/decode.c +2 -2
index 0567c47..a62e032 100644
@@ -8,8 +8,8 @@
 
 #define unlikely(cond) (cond)
 #include <asm/insn.h>
-#include "lib/inat.c"
-#include "lib/insn.c"
+#include "../../../arch/x86/lib/inat.c"
+#include "../../../arch/x86/lib/insn.c"
 
 #include "../../elf.h"
 #include "../../arch.h"
tools/objtool/arch/x86/include/asm/inat.h deleted +0 -230

230 lines not on this page · raw message

tools/objtool/arch/x86/include/asm/inat_types.h deleted +0 -15
deleted file mode 100644
index b047efa..0000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ASM_X86_INAT_TYPES_H
-#define _ASM_X86_INAT_TYPES_H
-/*
- * x86 instruction attributes
- *
- * Written by Masami Hiramatsu <[email protected]>
- */
-
-/* Instruction attributes */
-typedef unsigned int insn_attr_t;
-typedef unsigned char insn_byte_t;
-typedef signed int insn_value_t;
-
-#endif
tools/objtool/arch/x86/include/asm/insn.h deleted +0 -216

21 lines not on this page · raw message

tools/objtool/arch/x86/include/asm/orc_types.h deleted +0 -97

97 lines not on this page · raw message

tools/objtool/arch/x86/lib/inat.c deleted +0 -83

83 lines not on this page · raw message

tools/objtool/arch/x86/lib/insn.c deleted +0 -593

593 lines not on this page · raw message

tools/objtool/arch/x86/lib/x86-opcode-map.txt deleted +0 -1072

1,072 lines not on this page · raw message

tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk deleted +0 -393

393 lines not on this page · raw message

tools/objtool/sync-check.sh +6 -6
index 1470e74..66f1575 100755

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 2/4 perf: Update .gitignore file

In reply to Josh Poimboeuf

After a "make tools/perf", git reports the following untracked files:

tools/perf/feature/
tools/perf/fixdep
tools/perf/libtraceevent-dynamic-list

Add these generated files to perf's .gitignore file.

---
 tools/perf/.gitignore | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/.gitignore +3 -0
index 3e5135dded16..bf1252dc2cb0 100644
@@ -34,3 +34,6 @@ arch/*/include/generated/
 trace/beauty/generated/
 pmu-events/pmu-events.c
 pmu-events/jevents
+feature/
+fixdep
+libtraceevent-dynamic-list
Signature · 1 line
2.20.1
merge bot Applied
#4 lore raw

[tip: perf/core] perf: Update .gitignore file

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     58993fb2c5115e93c52058e25f9b2ff289374870
Gitweb:        https://git.kernel.org/tip/58993fb2c5115e93c52058e25f9b2ff289374870
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 29 Aug 2019 17:41:19 -05:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

perf: Update .gitignore file

After a "make tools/perf", git reports the following untracked files:

tools/perf/feature/
tools/perf/fixdep tools/perf/libtraceevent-dynamic-list

Add these generated files to perf's .gitignore file.

---
 tools/perf/.gitignore | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/.gitignore +3 -0
index 3e5135d..bf1252d 100644
@@ -34,3 +34,6 @@ arch/*/include/generated/
 trace/beauty/generated/
 pmu-events/pmu-events.c
 pmu-events/jevents
+feature/
+fixdep
+libtraceevent-dynamic-list
#5 lore raw

PATCH 3/4 perf intel-pt: Remove inat.c from build dependency list

In reply to Josh Poimboeuf

intel-pt-insn-decoder.c includes inat.c directly, so it already has an implicit dependency on inat.c. The Build file dependency is redundant.

---
 tools/perf/util/intel-pt-decoder/Build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/intel-pt-decoder/Build +1 -1
index 23bf788f84b9..acb18a3463c3 100644
@@ -9,7 +9,7 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table
 
 # Busybox's diff doesn't have -I, avoid warning in the case
 
-$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
+$(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
 	@(diff -I 2>&1 | grep -q 'option requires an argument' && \
 	test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
 	((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \
Signature · 1 line
2.20.1
merge bot Applied
#6 lore raw

[tip: perf/core] perf intel-pt: Remove inat.c from build dependency list

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     f1da0a6c136542b9571b30af27bc1e84254f7a47
Gitweb:        https://git.kernel.org/tip/f1da0a6c136542b9571b30af27bc1e84254f7a47
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 29 Aug 2019 17:41:20 -05:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

perf intel-pt: Remove inat.c from build dependency list

intel-pt-insn-decoder.c includes inat.c directly, so it already has an implicit dependency on inat.c. The Build file dependency is redundant.

---
 tools/perf/util/intel-pt-decoder/Build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/intel-pt-decoder/Build +1 -1
index 23bf788..acb18a3 100644
@@ -9,7 +9,7 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table
 
 # Busybox's diff doesn't have -I, avoid warning in the case
 
-$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
+$(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
 	@(diff -I 2>&1 | grep -q 'option requires an argument' && \
 	test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
 	((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \
#7 lore raw

PATCH 4/4 perf intel-pt: Use shared x86 insn decoder

In reply to Josh Poimboeuf

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.

---
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   20 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 12 files changed, 18 insertions(+), 2627 deletions(-)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
tools/perf/arch/x86/tests/insn-x86.c +1 -1
index c3e5f4ab0d3e..96b6d47bc962 100644
@@ -1,11 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
+#include <asm/insn.h>
 
 #include "debug.h"
 #include "tests/tests.h"
 #include "arch-tests.h"
 
-#include "intel-pt-decoder/insn.h"
 #include "intel-pt-decoder/intel-pt-insn-decoder.h"
 
 struct test_data {
tools/perf/arch/x86/util/archinsn.c +1 -1
index 4237bb2e7fa2..68542d6fddc0 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <asm/insn.h>
 #include "perf.h"
 #include "archinsn.h"
-#include "util/intel-pt-decoder/insn.h"
 #include "machine.h"
 #include "thread.h"
 #include "symbol.h"
tools/perf/check-headers.sh +9 -2
index 5308b3836278..cbcc3590098c 100755
@@ -1,7 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 
-HEADERS='
+FILES='
 include/uapi/linux/const.h
 include/uapi/drm/drm.h
 include/uapi/drm/i915_drm.h
@@ -26,7 +26,14 @@ include/uapi/linux/hw_breakpoint.h
 arch/x86/include/asm/disabled-features.h
 arch/x86/include/asm/required-features.h
 arch/x86/include/asm/cpufeatures.h
+arch/x86/include/asm/inat.h
+arch/x86/include/asm/inat_types.h
+arch/x86/include/asm/insn.h
 arch/x86/include/uapi/asm/prctl.h
+arch/x86/lib/inat.c
+arch/x86/lib/insn.c
+arch/x86/lib/x86-opcode-map.txt
+arch/x86/tools/gen-insn-attr-x86.awk
 arch/arm/include/uapi/asm/perf_regs.h
 arch/arm64/include/uapi/asm/perf_regs.h
 arch/powerpc/include/uapi/asm/perf_regs.h
@@ -98,7 +105,7 @@ test -d ../../include || exit 0
 cd ../..
 
 # simple diff check
-for i in $HEADERS; do
+for i in $FILES; do
   check $i -B
 done
 
tools/perf/util/intel-pt-decoder/Build +2 -18
index acb18a3463c3..1530f5cfd1b8 100644
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
-inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
+inat_tables_script = ../../arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = ../../arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)
@@ -10,22 +10,6 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table
 # Busybox's diff doesn't have -I, avoid warning in the case
 
 $(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
-	@(diff -I 2>&1 | grep -q 'option requires an argument' && \
-	test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
-	((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null) || \
-	(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)) && \
-	((diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null) || \
-	(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)) && \
-	((diff -B util/intel-pt-decoder/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/insn.h ../../arch/x86/include/asm/insn.h >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat.h ../../arch/x86/include/asm/inat.h >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) || \
-	(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
 	$(call rule_mkdir)
 	$(call if_changed_dep,cc_o_c)
 
tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk deleted +0 -392

392 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat.c deleted +0 -82

82 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat.h deleted +0 -230

230 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat_types.h deleted +0 -15
deleted file mode 100644
index b047efa9ddc2..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ASM_X86_INAT_TYPES_H
-#define _ASM_X86_INAT_TYPES_H
-/*
- * x86 instruction attributes
- *
- * Written by Masami Hiramatsu <[email protected]>
- */
-
-/* Instruction attributes */
-typedef unsigned int insn_attr_t;
-typedef unsigned char insn_byte_t;
-typedef signed int insn_value_t;
-
-#endif
tools/perf/util/intel-pt-decoder/insn.c deleted +0 -593

593 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/insn.h deleted +0 -216

216 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +5 -5
index 598f56be9f17..d2215a54d407 100644
@@ -4,17 +4,17 @@
  * Copyright (c) 2013-2014, Intel Corporation.
  */
 
+#include <linux/kernel.h>
 #include <stdio.h>
 #include <string.h>
 #include <endian.h>
 #include <byteswap.h>
+#include <asm/insn.h>
 
-#include "event.h"
-
-#include "insn.h"
+#include "../../../arch/x86/lib/inat.c"
+#include "../../../arch/x86/lib/insn.c"
 
-#include "inat.c"
-#include "insn.c"
+#include "event.h"
 
 #include "intel-pt-insn-decoder.h"
 #include "dump-insn.h"
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt deleted +0 -1072

1,072 lines not on this page · raw message

Signature · 1 line
2.20.1
#8 lore raw

Re: [PATCH 4/4] perf intel-pt: Use shared x86 insn decoder

Em Thu, Aug 29, 2019 at 05:41:21PM -0500, Josh Poimboeuf escreveu:

tools/perf/util/intel-pt-decoder/Build line 4

Quoted 8 lines

+++ b/tools/perf/util/intel-pt-decoder/Build

tools/perf/util/intel-pt-decoder/Build +2 -2
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
-inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
+inat_tables_script = ../../arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = ../../arch/x86/lib/x86-opcode-map.txt

I'm having trouble building it from:

[acme@quaco perf]$ make help | grep perf
perf-tar-src-pkg - Build perf-5.3.0-rc6.tar source tarball
perf-targz-src-pkg - Build perf-5.3.0-rc6.tar.gz source tarball perf-tarbz2-src-pkg - Build perf-5.3.0-rc6.tar.bz2 source tarball perf-tarxz-src-pkg - Build perf-5.3.0-rc6.tar.xz source tarball

I.e. detached tarballs, outside the kernel source tree, also using O=

[acme@quaco perf]$ ls -la perf-5*
ls: cannot access 'perf-5*': No such file or directory [acme@quaco perf]$ make perf-tarxz-src-pkg ; ls -la perf-5.*
TAR
PERF_VERSION = 5.3.rc6.gc55f04097932
-rw-rw-r--. 1 acme acme 1670016 Aug 30 16:57 perf-5.3.0-rc6.tar.xz [acme@quaco perf]$ cp perf-5.3.0-rc6.tar.xz /tmp
[acme@quaco perf]$ cd /tmp
[acme@quaco tmp]$ ls -la perf-5*
-rw-rw-r--. 1 acme acme 1670016 Aug 30 16:57 perf-5.3.0-rc6.tar.xz [acme@quaco tmp]$ tar xf perf-5.3.0-rc6.tar.xz
[acme@quaco tmp]$ cd perf-5.3.0-rc6/
[acme@quaco perf-5.3.0-rc6]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf [acme@quaco perf-5.3.0-rc6]$ make O=/tmp/build/perf -C tools/perf install-bin
make: Entering directory '/tmp/perf-5.3.0-rc6/tools/perf'

  BUILD:   Doing 'make -j8' parallel build
  HOSTCC   /tmp/build/perf/fixdep.o
  HOSTLD   /tmp/build/perf/fixdep-in.o
  LINK     /tmp/build/perf/fixdep

Auto-detecting system features:

...                         dwarf: [ on  ]
...            dwarf_getlocations: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ on  ]
...                        libcap: [ on  ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...        numa_num_possible_cpus: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                     libcrypto: [ on  ]
...                     libunwind: [ on  ]
...            libdw-dwarf-unwind: [ on  ]
...                          zlib: [ on  ]
...                          lzma: [ on  ]
...                     get_cpuid: [ on  ]
...                           bpf: [ on  ]
...                        libaio: [ on  ]
...                       libzstd: [ on  ]
...        disassembler-four-args: [ on  ]

GEN /tmp/build/perf/common-cmds.h
PERF_VERSION = 5.3.rc6.gc55f04097932

  CC       /tmp/build/perf/exec-cmd.o
  MKDIR    /tmp/build/perf/fd/
  MKDIR    /tmp/build/perf/fs/
<SNIP>
  CC       /tmp/build/perf/util/rwsem.o
  CC       /tmp/build/perf/util/thread-stack.o
  LD       /tmp/build/perf/tests/perf-in.o
  CC       /tmp/build/perf/util/auxtrace.o
make[5]: *** No rule to make target '../../arch/x86/tools/gen-insn-attr-x86.awk', needed by '/tmp/build/perf/util/intel-pt-decoder/inat-tables.c'.  Stop.
make[5]: *** Waiting for unfinished jobs....
  CC       /tmp/build/perf/util/intel-pt.o
  MKDIR    /tmp/build/perf/util/intel-pt-decoder/
  CC       /tmp/build/perf/util/intel-bts.o
  CC       /tmp/build/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.o
  MKDIR    /tmp/build/perf/util/scripting-engines/
  MKDIR    /tmp/build/perf/util/scripting-engines/
  CC       /tmp/build/perf/util/scripting-engines/trace-event-perl.o
  CC       /tmp/build/perf/util/scripting-engines/trace-event-python.o

make[4]: *** [/tmp/perf-5.3.0-rc6/tools/build/Makefile.build:139: intel-pt-decoder] Error 2 make[4]: *** Waiting for unfinished jobs....
CC /tmp/build/perf/util/arm-spe.o
LD /tmp/build/perf/util/scripting-engines/perf-in.o
make[3]: *** [/tmp/perf-5.3.0-rc6/tools/build/Makefile.build:139: util] Error 2 make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile.perf:597: /tmp/build/perf/perf-in.o] Error 2
make[1]: *** [Makefile.perf:221: sub-make] Error 2
make: *** [Makefile:110: install-bin] Error 2
make: Leaving directory '/tmp/perf-5.3.0-rc6/tools/perf'
[acme@quaco perf-5.3.0-rc6]$

#9 lore raw

Re: [PATCH 4/4] perf intel-pt: Use shared x86 insn decoder

Em Fri, Aug 30, 2019 at 04:59:37PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 20 lines

Em Thu, Aug 29, 2019 at 05:41:21PM -0500, Josh Poimboeuf escreveu:

Review line 4

Quoted 8 lines

+++ b/tools/perf/util/intel-pt-decoder/Build

(quoted diff) +2 -2
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
-inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
+inat_tables_script = ../../arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = ../../arch/x86/lib/x86-opcode-map.txt

I'm having trouble building it from:

[acme@quaco perf]$ make help | grep perf
perf-tar-src-pkg - Build perf-5.3.0-rc6.tar source tarball
perf-targz-src-pkg - Build perf-5.3.0-rc6.tar.gz source tarball perf-tarbz2-src-pkg - Build perf-5.3.0-rc6.tar.bz2 source tarball perf-tarxz-src-pkg - Build perf-5.3.0-rc6.tar.xz source tarball

I.e. detached tarballs, outside the kernel source tree, also using O=

Quoted 10 lines

[acme@quaco perf]$ ls -la perf-5*
ls: cannot access 'perf-5*': No such file or directory
[acme@quaco perf]$ make perf-tarxz-src-pkg ; ls -la perf-5.*
TAR
PERF_VERSION = 5.3.rc6.gc55f04097932
-rw-rw-r--. 1 acme acme 1670016 Aug 30 16:57 perf-5.3.0-rc6.tar.xz
LD /tmp/build/perf/tests/perf-in.o
CC /tmp/build/perf/util/auxtrace.o
make[5]: *** No rule to make target '../../arch/x86/tools/gen-insn-attr-x86.awk', needed by '/tmp/build/perf/util/intel-pt-decoder/inat-tables.c'. Stop. make[5]: *** Waiting for unfinished jobs....

A fix, please lemme know if you're ok, so that I can fold both patches so that we can keep it all bisect happy.

- Arnaldo

commit 423a2bf6e04aaecbeb5c2d5689cb3b832c240df0

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Fri Aug 30 17:01:58 2019 -0300

srcdir awk

tools/perf/util/intel-pt-decoder/Build +2 -2
index 1530f5cfd1b8..bc629359826f 100644
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = ../../arch/x86/tools/gen-insn-attr-x86.awk
-inat_tables_maps = ../../arch/x86/lib/x86-opcode-map.txt
+inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)
#10 lore raw

Re: [PATCH 4/4] perf intel-pt: Use shared x86 insn decoder

Quoted 18 lines

A fix, please lemme know if you're ok, so that I can fold both patches so that we can keep it all bisect happy.

- Arnaldo

commit 423a2bf6e04aaecbeb5c2d5689cb3b832c240df0

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Fri Aug 30 17:01:58 2019 -0300

srcdir awk

tools/perf/util/intel-pt-decoder/Build +0 -0
index 1530f5cfd1b8..bc629359826f 100644

tools/perf/util/intel-pt-decoder/Build line 7

Quoted 9 lines
tools/perf/util/intel-pt-decoder/Build +2 -2
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = ../../arch/x86/tools/gen-insn-attr-x86.awk
-inat_tables_maps = ../../arch/x86/lib/x86-opcode-map.txt
+inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)

Looks good to me. Thanks for fixing these!

Signature · 1 line
Josh
merge bot Applied
#11 lore raw

[tip: perf/core] perf intel-pt: Use shared x86 insn decoder

In reply to Josh Poimboeuf
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     00a263902ac3da886cf275663a938f503a853f68
Gitweb:        https://git.kernel.org/tip/00a263902ac3da886cf275663a938f503a853f68
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 29 Aug 2019 17:41:21 -05:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

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.

---
 tools/arch/x86/include/asm/inat.h                        |    2 +-
 tools/arch/x86/include/asm/insn.h                        |    2 +-
 tools/arch/x86/lib/inat.c                                |    2 +-
 tools/arch/x86/lib/insn.c                                |    4 +-
 tools/perf/arch/x86/tests/insn-x86.c                     |    2 +-
 tools/perf/arch/x86/util/archinsn.c                      |    2 +-
 tools/perf/check-headers.sh                              |   11 +-
 tools/perf/util/intel-pt-decoder/Build                   |   20 +-
 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk   |  392 +---
 tools/perf/util/intel-pt-decoder/inat.c                  |   82 +-
 tools/perf/util/intel-pt-decoder/inat.h                  |  230 +--
 tools/perf/util/intel-pt-decoder/inat_types.h            |   15 +-
 tools/perf/util/intel-pt-decoder/insn.c                  |  593 +----
 tools/perf/util/intel-pt-decoder/insn.h                  |  216 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c |   10 +-
 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt      | 1072 +-------
 16 files changed, 23 insertions(+), 2632 deletions(-)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
tools/arch/x86/include/asm/inat.h +1 -1
index 4cf2ad5..877827b 100644
@@ -6,7 +6,7 @@
  *
  * Written by Masami Hiramatsu <[email protected]>
  */
-#include <asm/inat_types.h>
+#include "inat_types.h"
 
 /*
  * Internal bits. Don't use bitmasks directly, because these bits are
tools/arch/x86/include/asm/insn.h +1 -1
index 154f27b..37a4c39 100644
@@ -8,7 +8,7 @@
  */
 
 /* insn_attr_t is defined in inat.h */
-#include <asm/inat.h>
+#include "inat.h"
 
 struct insn_field {
 	union {
tools/arch/x86/lib/inat.c +1 -1
index 12539fc..4f5ed49 100644
@@ -4,7 +4,7 @@
  *
  * Written by Masami Hiramatsu <[email protected]>
  */
-#include <asm/insn.h>
+#include "../include/asm/insn.h"
 
 /* Attribute tables are generated from opcode map */
 #include "inat-tables.c"
tools/arch/x86/lib/insn.c +2 -2
index 0b5862b..79e048f 100644
@@ -10,8 +10,8 @@
 #else
 #include <string.h>
 #endif
-#include <asm/inat.h>
-#include <asm/insn.h>
+#include "../include/asm/inat.h"
+#include "../include/asm/insn.h"
 
 /* Verify next sizeof(t) bytes can be on the same instruction */
 #define validate_next(t, insn, n)	\
tools/perf/arch/x86/tests/insn-x86.c +1 -1
index d67bc0f..745f29a 100644
@@ -1,12 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
+#include "../../../../arch/x86/include/asm/insn.h"
 #include <string.h>
 
 #include "debug.h"
 #include "tests/tests.h"
 #include "arch-tests.h"
 
-#include "intel-pt-decoder/insn.h"
 #include "intel-pt-decoder/intel-pt-insn-decoder.h"
 
 struct test_data {
tools/perf/arch/x86/util/archinsn.c +1 -1
index 62e8e18..9876c7a 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
+#include "../../../../arch/x86/include/asm/insn.h"
 #include "archinsn.h"
-#include "util/intel-pt-decoder/insn.h"
 #include "machine.h"
 #include "thread.h"
 #include "symbol.h"
tools/perf/check-headers.sh +9 -2
index 5308b38..cbcc359 100755
@@ -1,7 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 
-HEADERS='
+FILES='
 include/uapi/linux/const.h
 include/uapi/drm/drm.h
 include/uapi/drm/i915_drm.h
@@ -26,7 +26,14 @@ include/uapi/linux/hw_breakpoint.h
 arch/x86/include/asm/disabled-features.h
 arch/x86/include/asm/required-features.h
 arch/x86/include/asm/cpufeatures.h
+arch/x86/include/asm/inat.h
+arch/x86/include/asm/inat_types.h
+arch/x86/include/asm/insn.h
 arch/x86/include/uapi/asm/prctl.h
+arch/x86/lib/inat.c
+arch/x86/lib/insn.c
+arch/x86/lib/x86-opcode-map.txt
+arch/x86/tools/gen-insn-attr-x86.awk
 arch/arm/include/uapi/asm/perf_regs.h
 arch/arm64/include/uapi/asm/perf_regs.h
 arch/powerpc/include/uapi/asm/perf_regs.h
@@ -98,7 +105,7 @@ test -d ../../include || exit 0
 cd ../..
 
 # simple diff check
-for i in $HEADERS; do
+for i in $FILES; do
   check $i -B
 done
 
tools/perf/util/intel-pt-decoder/Build +2 -18
index acb18a3..bc62935 100644
@@ -1,7 +1,7 @@
 perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
 
-inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
-inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
+inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk
+inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt
 
 $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
 	$(call rule_mkdir)
@@ -10,22 +10,6 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table
 # Busybox's diff doesn't have -I, avoid warning in the case
 
 $(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
-	@(diff -I 2>&1 | grep -q 'option requires an argument' && \
-	test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
-	((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null) || \
-	(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)) && \
-	((diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null) || \
-	(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)) && \
-	((diff -B util/intel-pt-decoder/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/insn.h ../../arch/x86/include/asm/insn.h >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat.h ../../arch/x86/include/asm/inat.h >/dev/null) || \
-	(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)) && \
-	((diff -B -I'^#include' util/intel-pt-decoder/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) || \
-	(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
 	$(call rule_mkdir)
 	$(call if_changed_dep,cc_o_c)
 
tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk deleted +0 -392

392 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat.c deleted +0 -82

82 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat.h deleted +0 -230

230 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/inat_types.h deleted +0 -15
deleted file mode 100644
index b047efa..0000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ASM_X86_INAT_TYPES_H
-#define _ASM_X86_INAT_TYPES_H
-/*
- * x86 instruction attributes
- *
- * Written by Masami Hiramatsu <[email protected]>
- */
-
-/* Instruction attributes */
-typedef unsigned int insn_attr_t;
-typedef unsigned char insn_byte_t;
-typedef signed int insn_value_t;
-
-#endif
tools/perf/util/intel-pt-decoder/insn.c deleted +0 -593

593 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/insn.h deleted +0 -216

216 lines not on this page · raw message

tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +5 -5
index 598f56b..fb8a355 100644
@@ -4,17 +4,17 @@
  * Copyright (c) 2013-2014, Intel Corporation.
  */
 
+#include <linux/kernel.h>
 #include <stdio.h>
 #include <string.h>
 #include <endian.h>
 #include <byteswap.h>
+#include "../../../arch/x86/include/asm/insn.h"
 
-#include "event.h"
-
-#include "insn.h"
+#include "../../../arch/x86/lib/inat.c"
+#include "../../../arch/x86/lib/insn.c"
 
-#include "inat.c"
-#include "insn.c"
+#include "event.h"
 
 #include "intel-pt-insn-decoder.h"
 #include "dump-insn.h"
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt deleted +0 -1072

1,072 lines not on this page · raw message

maintainer Acked-by on the v1 series
#12 lore raw
In reply to Josh Poimboeuf
Quoted 9 lines · Josh Poimboeuf

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

Reviewed-by on the v1 series
#13 lore raw
In reply to Josh Poimboeuf
Quoted 4 lines · On Thu, 29 Aug 2019 17:41:17 -0500 Josh Poimboeuf <[email protected]> wrote:

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Sounds good to me ;)

Thanks,

Quoted 51 lines

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

 .../{objtool => }/arch/x86/include/asm/inat.h |    0
 .../arch/x86/include/asm/inat_types.h         |    0
 .../{objtool => }/arch/x86/include/asm/insn.h |    0
 .../arch/x86/include/asm/orc_types.h          |    0
 tools/{objtool => }/arch/x86/lib/inat.c       |    0
 tools/{objtool => }/arch/x86/lib/insn.c       |    0
 .../arch/x86/lib/x86-opcode-map.txt           |    0
 .../arch/x86/tools/gen-insn-attr-x86.awk      |    0
 tools/objtool/Makefile                        |    4 +-
 tools/objtool/arch/x86/Build                  |    4 +-
 tools/objtool/arch/x86/decode.c               |    4 +-
 tools/objtool/sync-check.sh                   |   12 +-
 tools/perf/.gitignore                         |    3 +
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   22 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 25 files changed, 34 insertions(+), 2640 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
Signature · 1 line
2.20.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
#14 lore raw

Em Sat, Aug 31, 2019 at 12:20:04AM +0900, Masami Hiramatsu escreveu:

Quoted 11 lines
Quoted 4 lines · On Thu, 29 Aug 2019 17:41:17 -0500 Josh Poimboeuf <[email protected]> wrote:

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Sounds good to me ;)

Good, two already, Adrian?

- Arnaldo

Quoted 57 lines

Thanks,

Quoted 51 lines

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

 .../{objtool => }/arch/x86/include/asm/inat.h |    0
 .../arch/x86/include/asm/inat_types.h         |    0
 .../{objtool => }/arch/x86/include/asm/insn.h |    0
 .../arch/x86/include/asm/orc_types.h          |    0
 tools/{objtool => }/arch/x86/lib/inat.c       |    0
 tools/{objtool => }/arch/x86/lib/insn.c       |    0
 .../arch/x86/lib/x86-opcode-map.txt           |    0
 .../arch/x86/tools/gen-insn-attr-x86.awk      |    0
 tools/objtool/Makefile                        |    4 +-
 tools/objtool/arch/x86/Build                  |    4 +-
 tools/objtool/arch/x86/decode.c               |    4 +-
 tools/objtool/sync-check.sh                   |   12 +-
 tools/perf/.gitignore                         |    3 +
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   22 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 25 files changed, 34 insertions(+), 2640 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
Signature · 1 line
2.20.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
- Arnaldo
#15 lore raw
In reply to Josh Poimboeuf

Em Thu, Aug 29, 2019 at 05:41:17PM -0500, Josh Poimboeuf escreveu:

Quoted 3 lines

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Ok, I fixed up some minor conflicts with my perf/core branch and will submit this together with the other things to the container builds and then push it upstream, collected Peter and Masami's Acks.

- Arnaldo

Quoted 50 lines

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

 .../{objtool => }/arch/x86/include/asm/inat.h |    0
 .../arch/x86/include/asm/inat_types.h         |    0
 .../{objtool => }/arch/x86/include/asm/insn.h |    0
 .../arch/x86/include/asm/orc_types.h          |    0
 tools/{objtool => }/arch/x86/lib/inat.c       |    0
 tools/{objtool => }/arch/x86/lib/insn.c       |    0
 .../arch/x86/lib/x86-opcode-map.txt           |    0
 .../arch/x86/tools/gen-insn-attr-x86.awk      |    0
 tools/objtool/Makefile                        |    4 +-
 tools/objtool/arch/x86/Build                  |    4 +-
 tools/objtool/arch/x86/decode.c               |    4 +-
 tools/objtool/sync-check.sh                   |   12 +-
 tools/perf/.gitignore                         |    3 +
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   22 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 25 files changed, 34 insertions(+), 2640 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo
#16 lore raw

Em Fri, Aug 30, 2019 at 03:40:20PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

Em Thu, Aug 29, 2019 at 05:41:17PM -0500, Josh Poimboeuf escreveu:

Quoted 3 lines

It's kind of silly that we have *three* identical copies of the x86 insn decoder in the kernel tree. Make it approximately 50% less silly by reducing that number to two.

Ok, I fixed up some minor conflicts with my perf/core branch and will submit this together with the other things to the container builds and then push it upstream, collected Peter and Masami's Acks.

Ok, I quickly take that back (but a fix is provided below), as I noticed that it is failing in the first cross-builds I tried:

perfbuilder@1317a113fde0:~$ export | grep HOME -B20
declare -x ARCH="arm64"
declare -x CROSS_COMPILE="aarch64-linux-gnu-"
declare -x EXTRA_MAKE_ARGS="CORESIGHT=1"
declare -x HOME="/home/perfbuilder"
perfbuilder@1317a113fde0:~$ 

I completely removed the build dir and restarted the build just in case, but got:

CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-insn-decoder.o
util/intel-pt-decoder/intel-pt-insn-decoder.c:12:10: fatal error: asm/insn.h: No such file or directory

 #include <asm/insn.h>
          ^~~~~~~~~~~~

compilation terminated.
mv: cannot stat '/tmp/build/perf/util/intel-pt-decoder/.intel-pt-insn-decoder.o.tmp': No such file or directory make[5]: *** [util/intel-pt-decoder/Build:14: /tmp/build/perf/util/intel-pt-decoder/intel-pt-insn-decoder.o] Error 1

Also on:

perfbuilder@f3b14e504747:~$ export | grep HOME -B20
declare -x ARCH="s390"
declare -x CROSS_COMPILE="s390x-linux-gnu-"
declare -x HOME="/home/perfbuilder"
perfbuilder@f3b14e504747:~$ 

CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-insn-decoder.o
CC /tmp/build/perf/util/demangle-rust.o
util/intel-pt-decoder/intel-pt-insn-decoder.c:12:22: fatal error: asm/insn.h: No such file or directory compilation terminated.
mv: cannot stat '/tmp/build/perf/util/intel-pt-decoder/.intel-pt-insn-decoder.o.tmp': No such file or directory util/intel-pt-decoder/Build:13: recipe for target '/tmp/build/perf/util/intel-pt-decoder/intel-pt-insn-decoder.o' failed

All built with:

perfbuilder@1317a113fde0:~$ alias m
alias m='make $EXTRA_MAKE_ARGS ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE EXTRA_CFLAGS="$EXTRA_CFLAGS" -C /git/perf/tools/perf O=/tmp/build/perf'
perfbuilder@1317a113fde0:~$

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Probably this should go to the master copy, i.e. to the kernel sources, no?

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

- Arnaldo

tools/arch/x86/include/asm/inat.h +1 -1
index 4cf2ad521f65..877827b7c2c3 100644
@@ -6,7 +6,7 @@
  *
  * Written by Masami Hiramatsu <[email protected]>
  */
-#include <asm/inat_types.h>
+#include "inat_types.h"
 
 /*
  * Internal bits. Don't use bitmasks directly, because these bits are
tools/arch/x86/include/asm/insn.h +1 -1
index 154f27be8bfc..37a4c390750b 100644
@@ -8,7 +8,7 @@
  */
 
 /* insn_attr_t is defined in inat.h */
-#include <asm/inat.h>
+#include "inat.h"
 
 struct insn_field {
 	union {
tools/arch/x86/lib/inat.c +1 -1
index 12539fca75c4..4f5ed49e1b4e 100644
@@ -4,7 +4,7 @@
  *
  * Written by Masami Hiramatsu <[email protected]>
  */
-#include <asm/insn.h>
+#include "../include/asm/insn.h"
 
 /* Attribute tables are generated from opcode map */
 #include "inat-tables.c"
tools/arch/x86/lib/insn.c +2 -2
index 0b5862ba6a75..79e048f1d902 100644
@@ -10,8 +10,8 @@
 #else
 #include <string.h>
 #endif
-#include <asm/inat.h>
-#include <asm/insn.h>
+#include "../include/asm/inat.h"
+#include "../include/asm/insn.h"
 
 /* Verify next sizeof(t) bytes can be on the same instruction */
 #define validate_next(t, insn, n)	\
tools/perf/arch/x86/tests/insn-x86.c +1 -1
index 824ae7164d01..745f29adb14b 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
-#include <asm/insn.h>
+#include "../../../../arch/x86/include/asm/insn.h"
 #include <string.h>
 
 #include "debug.h"
tools/perf/arch/x86/util/archinsn.c +1 -1
index 589213d38c87..9876c7a7ed7c 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <asm/insn.h>
+#include "../../../../arch/x86/include/asm/insn.h"
 #include "archinsn.h"
 #include "machine.h"
 #include "thread.h"
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +1 -1
index d2215a54d407..fb8a3558d3d5 100644
@@ -9,7 +9,7 @@
 #include <string.h>
 #include <endian.h>
 #include <byteswap.h>
-#include <asm/insn.h>
+#include "../../../arch/x86/include/asm/insn.h"
 
 #include "../../../arch/x86/lib/inat.c"
 #include "../../../arch/x86/lib/insn.c"
Quoted 56 lines

- Arnaldo

Quoted 50 lines

Josh Poimboeuf (4):
objtool: Move x86 insn decoder to a common location
perf: Update .gitignore file
perf intel-pt: Remove inat.c from build dependency list perf intel-pt: Use shared x86 insn decoder

 .../{objtool => }/arch/x86/include/asm/inat.h |    0
 .../arch/x86/include/asm/inat_types.h         |    0
 .../{objtool => }/arch/x86/include/asm/insn.h |    0
 .../arch/x86/include/asm/orc_types.h          |    0
 tools/{objtool => }/arch/x86/lib/inat.c       |    0
 tools/{objtool => }/arch/x86/lib/insn.c       |    0
 .../arch/x86/lib/x86-opcode-map.txt           |    0
 .../arch/x86/tools/gen-insn-attr-x86.awk      |    0
 tools/objtool/Makefile                        |    4 +-
 tools/objtool/arch/x86/Build                  |    4 +-
 tools/objtool/arch/x86/decode.c               |    4 +-
 tools/objtool/sync-check.sh                   |   12 +-
 tools/perf/.gitignore                         |    3 +
 tools/perf/arch/x86/tests/insn-x86.c          |    2 +-
 tools/perf/arch/x86/util/archinsn.c           |    2 +-
 tools/perf/check-headers.sh                   |   11 +-
 tools/perf/util/intel-pt-decoder/Build        |   22 +-
 .../intel-pt-decoder/gen-insn-attr-x86.awk    |  392 ------
 tools/perf/util/intel-pt-decoder/inat.c       |   82 --
 tools/perf/util/intel-pt-decoder/inat.h       |  230 ----
 tools/perf/util/intel-pt-decoder/inat_types.h |   15 -
 tools/perf/util/intel-pt-decoder/insn.c       |  593 ---------
 tools/perf/util/intel-pt-decoder/insn.h       |  216 ----
 .../intel-pt-decoder/intel-pt-insn-decoder.c  |   10 +-
 .../util/intel-pt-decoder/x86-opcode-map.txt  | 1072 -----------------
 25 files changed, 34 insertions(+), 2640 deletions(-)
 rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%)
 rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%)
 rename tools/{objtool => }/arch/x86/lib/inat.c (100%)
 rename tools/{objtool => }/arch/x86/lib/insn.c (100%)
 rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%)
 rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%)
 delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
#17 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Probably this should go to the master copy, i.e. to the kernel sources, no?

Quoted 8 lines

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

Interesting, I didn't realize other arches would be using it. The patch looks good to me.

Ideally there wouldn't be any differences between the headers, but if that's unavoidable then I guess we can just use the same 'diff -I' trick we were using before in the check script(s).

Signature · 1 line
Josh
#18 lore raw

Em Fri, Aug 30, 2019 at 02:31:09PM -0500, Josh Poimboeuf escreveu:

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 11 lines

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Probably this should go to the master copy, i.e. to the kernel sources, no?

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

Quoted 6 lines
Quoted 4 lines

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

Interesting, I didn't realize other arches would be using it. The patch

Yeah, decoding CoreSight (aarch64) hardware traces on x86_64 should be as possible as decoding Intel PT hardware traces on aarch64 :-)

Quoted 4 lines

looks good to me.

Ideally there wouldn't be any differences between the headers, but if that's unavoidable then I guess we can just use the same 'diff -I' trick

I'll go with this now, but...

Quoted 1 line

we were using before in the check script(s).

Masami? What do you think of applying the patch to the main kernel sources so that building a decoder for x86 on any other arch becomes possible?

- Arnaldo

#19 lore raw
Quoted 8 lines · On Fri, 30 Aug 2019 16:48:45 -0300 Arnaldo Carvalho de Melo <[email protected]>…

Em Fri, Aug 30, 2019 at 02:31:09PM -0500, Josh Poimboeuf escreveu:

Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Probably this should go to the master copy, i.e. to the kernel sources, no?

Interesting approach. Hmm, but I would like "diff -I" trick just for short term solution.

Quoted 20 lines
Quoted 11 lines
Quoted 9 lines

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

Interesting, I didn't realize other arches would be using it. The patch

Yeah, decoding CoreSight (aarch64) hardware traces on x86_64 should be as possible as decoding Intel PT hardware traces on aarch64 :-)

Quoted 4 lines

looks good to me.

Ideally there wouldn't be any differences between the headers, but if that's unavoidable then I guess we can just use the same 'diff -I' trick

Quoted 7 lines

I'll go with this now, but...

Quoted 1 line

we were using before in the check script(s).

Masami? What do you think of applying the patch to the main kernel sources so that building a decoder for x86 on any other arch becomes possible?

I think the build of kernel and user-space tools are different especially for "include/asm", since user-space tools may want to use all architecture features, but kernel needs only the architecture which it runs on. Maybe we need a special Makefile entries for the modules which depends on architecture dependent parts. e.g.

x86-objs = insn.o inat.o ...
arm64-objs = coresight.o ...

and they should have different -I options ('-I arch/x86/include' or '-I arch/arm64/include') for compiling.
I think this is better and scalable, if you use common (clone) files in the kernel tree.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#20 lore raw

Em Sat, Aug 31, 2019 at 10:51:52AM +0900, Masami Hiramatsu escreveu:

Quoted 9 lines
Quoted 6 lines · On Fri, 30 Aug 2019 16:48:45 -0300 Arnaldo Carvalho de Melo <[email protected]>…

Em Fri, Aug 30, 2019 at 02:31:09PM -0500, Josh Poimboeuf escreveu:

Quoted 5 lines · Arnaldo Carvalho de Melo
Quoted 4 lines

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Probably this should go to the master copy, i.e. to the kernel sources, no?

Interesting approach. Hmm, but I would like "diff -I" trick just for short term solution.

Ok, I'm in a hurry right now, plumbers and all, so I'll just add the diff -I trick and will have your "I would like that trick" sentence above as an Acked-by: you, ok?

- Arnaldo

Quoted 45 lines
Quoted 19 lines
Quoted 10 lines
Quoted 8 lines

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

Interesting, I didn't realize other arches would be using it. The patch

Yeah, decoding CoreSight (aarch64) hardware traces on x86_64 should be as possible as decoding Intel PT hardware traces on aarch64 :-)

Quoted 4 lines

looks good to me.

Ideally there wouldn't be any differences between the headers, but if that's unavoidable then I guess we can just use the same 'diff -I' trick

Quoted 7 lines

I'll go with this now, but...

Quoted 1 line

we were using before in the check script(s).

Masami? What do you think of applying the patch to the main kernel sources so that building a decoder for x86 on any other arch becomes possible?

I think the build of kernel and user-space tools are different especially for "include/asm", since user-space tools may want to use all architecture features, but kernel needs only the architecture which it runs on. Maybe we need a special Makefile entries for the modules which depends on architecture dependent parts. e.g.

x86-objs = insn.o inat.o ...
arm64-objs = coresight.o ...

and they should have different -I options ('-I arch/x86/include' or '-I arch/arm64/include') for compiling.
I think this is better and scalable, if you use common (clone) files in the kernel tree.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
- Arnaldo
#21 lore raw
Quoted 13 lines · On Sat, 31 Aug 2019 17:19:31 -0300 Arnaldo Carvalho de Melo <[email protected]>…

Em Sat, Aug 31, 2019 at 10:51:52AM +0900, Masami Hiramatsu escreveu:

Quoted 12 lines
Quoted 8 lines · On Fri, 30 Aug 2019 16:48:45 -0300 Arnaldo Carvalho de Melo <[email protected]>…

Em Fri, Aug 30, 2019 at 02:31:09PM -0500, Josh Poimboeuf escreveu:

Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

I.e. we need to make sure that it always gets the x86 stuff, not something that is tied to the host arch, with the patch below we get it to work, please take a look.

Probably this should go to the master copy, i.e. to the kernel sources, no?

Quoted 6 lines
Quoted 2 lines

Interesting approach. Hmm, but I would like "diff -I" trick just for short term solution.

Ok, I'm in a hurry right now, plumbers and all, so I'll just add the diff -I trick and will have your "I would like that trick" sentence above as an Acked-by: you, ok?

Yes, that's fine :) Please use my acked-by for the diff -I trick patch.

Thank you,

Quoted 52 lines

- Arnaldo

Quoted 45 lines
Quoted 19 lines
Quoted 10 lines
Quoted 8 lines

That or we'll have to ask the check-headers.sh and objtool sync-check (hey, this should be unified, each project could provide just the list of things it uses, but I digress) to ignore those lines...

I.e. we want to decode intel_PT traces on other arches, ditto for CoreSight (not affected here, but similar concept).

will kick the full container build process now.

Interesting, I didn't realize other arches would be using it. The patch

Yeah, decoding CoreSight (aarch64) hardware traces on x86_64 should be as possible as decoding Intel PT hardware traces on aarch64 :-)

Quoted 4 lines

looks good to me.

Ideally there wouldn't be any differences between the headers, but if that's unavoidable then I guess we can just use the same 'diff -I' trick

Quoted 7 lines

I'll go with this now, but...

Quoted 1 line

we were using before in the check script(s).

Masami? What do you think of applying the patch to the main kernel sources so that building a decoder for x86 on any other arch becomes possible?

I think the build of kernel and user-space tools are different especially for "include/asm", since user-space tools may want to use all architecture features, but kernel needs only the architecture which it runs on. Maybe we need a special Makefile entries for the modules which depends on architecture dependent parts. e.g.

x86-objs = insn.o inat.o ...
arm64-objs = coresight.o ...

and they should have different -I options ('-I arch/x86/include' or '-I arch/arm64/include') for compiling.
I think this is better and scalable, if you use common (clone) files in the kernel tree.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
- Arnaldo
Signature · 1 line
Masami Hiramatsu <[email protected]>
#22 lore raw

[tip: perf/core] objtool: Update sync-check.sh from perf's check-headers.sh

In reply to Josh Poimboeuf
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     2ffd84ae973b5ad16be96840574bb1142fda268a
Gitweb:        https://git.kernel.org/tip/2ffd84ae973b5ad16be96840574bb1142fda268a
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Sat, 31 Aug 2019 17:29:47 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

objtool: Update sync-check.sh from perf's check-headers.sh

To allow using the -I trick that will be needed for checking the x86 insn decoder files.

Without the specific -I lines we still get the same warnings as before:

  $ make -C tools/objtool/ clean ; make -C tools/objtool/
  make: Entering directory '/home/acme/git/perf/tools/objtool'
    CLEAN    objtool
  find  -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  rm -f arch/x86/inat-tables.c fixdep
  <SNIP>
    LD       objtool-in.o
  make[1]: Leaving directory '/home/acme/git/perf/tools/objtool'
  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h'
  diff -u tools/arch/x86/include/asm/inat.h arch/x86/include/asm/inat.h
  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'
  diff -u tools/arch/x86/include/asm/insn.h arch/x86/include/asm/insn.h
  Warning: Kernel ABI header at 'tools/arch/x86/lib/inat.c' differs from latest version at 'arch/x86/lib/inat.c'
  diff -u tools/arch/x86/lib/inat.c arch/x86/lib/inat.c
  Warning: Kernel ABI header at 'tools/arch/x86/lib/insn.c' differs from latest version at 'arch/x86/lib/insn.c'
  diff -u tools/arch/x86/lib/insn.c arch/x86/lib/insn.c
  /home/acme/git/perf/tools/objtool
    LINK     objtool
  make: Leaving directory '/home/acme/git/perf/tools/objtool'
  $

The next patch will add the -I lines for those files.

---
 tools/objtool/sync-check.sh | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
tools/objtool/sync-check.sh +26 -5
index 66f1575..6fa87de 100755
@@ -12,18 +12,39 @@ arch/x86/lib/x86-opcode-map.txt
 arch/x86/tools/gen-insn-attr-x86.awk
 '
 
-check()
-{
-	local file=$1
+check_2 () {
+  file1=$1
+  file2=$2
 
-	diff ../$file ../../$file > /dev/null ||
-		echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'"
+  shift
+  shift
+
+  cmd="diff $* $file1 $file2 > /dev/null"
+
+  test -f $file2 && {
+    eval $cmd || {
+      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
+      echo diff -u $file1 $file2
+    }
+  }
+}
+
+check () {
+  file=$1
+
+  shift
+
+  check_2 tools/$file $file $*
 }
 
 if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
 	exit 0
 fi
 
+cd ../..
+
 for i in $FILES; do
   check $i
 done
+
+cd -
#23 lore raw

[tip: perf/core] objtool: Ignore intentional differences for the x86 insn decoder

In reply to Josh Poimboeuf
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     ae31a514a134d9e4ca1d7b0f0a19b5934747d79f
Gitweb:        https://git.kernel.org/tip/ae31a514a134d9e4ca1d7b0f0a19b5934747d79f
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Sat, 31 Aug 2019 17:35:53 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Sat, 31 Aug 2019 22:27:52 -03:00

objtool: Ignore intentional differences for the x86 insn decoder

Since we need to build this in !x86, we need to explicitely use the x86 files, not things like asm/insn.h, so we intentionally differ from the master copy in the kernel sources, add -I diff directives to ignore just these differences when checking for drift.

---
 tools/objtool/sync-check.sh |  9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tools/objtool/sync-check.sh +5 -4
index 6fa87de..0a832e2 100755
@@ -2,12 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 FILES='
-arch/x86/include/asm/inat.h
 arch/x86/include/asm/inat_types.h
-arch/x86/include/asm/insn.h
 arch/x86/include/asm/orc_types.h
-arch/x86/lib/inat.c
-arch/x86/lib/insn.c
 arch/x86/lib/x86-opcode-map.txt
 arch/x86/tools/gen-insn-attr-x86.awk
 '
@@ -47,4 +43,9 @@ for i in $FILES; do
   check $i
 done
 
+check arch/x86/include/asm/inat.h     '-I "^#include [\"<]\(asm/\)*inat_types.h[\">]"'
+check arch/x86/include/asm/insn.h     '-I "^#include [\"<]\(asm/\)*inat.h[\">]"'
+check arch/x86/lib/inat.c             '-I "^#include [\"<]\(../include/\)*asm/insn.h[\">]"'
+check arch/x86/lib/insn.c             '-I "^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]"'
+
 cd -