From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/23] perf tools: Add probing for the XED disassembler library
Date: Wed, 25 Jan 2017 10:53:33 -0300 [thread overview]
Message-ID: <20170125135350.22983-7-acme@kernel.org> (raw)
In-Reply-To: <20170125135350.22983-1-acme@kernel.org>
From: Andi Kleen <ak@linux.intel.com>
Can be downloaded from https://github.com/intelxed/xed
v2: Hide. Require XED=1 to enable. Add XED_DIR
v3: Remove -lxed from probe all. Don't touch FEATURE_DISPLAY.
v4: Move to FEATURE_FLAGS_BASIC
Committer Notes:
>From https://intelxed.github.io/:
---
The X86 Encoder Decoder (XED), is a software library (and associated
headers) for encoding and decoding X86 (IA32 and Intel64) instructions.
The decoder takes sequences of 1-15 bytes along with machine mode
information and produces a data structure describing the opcode,
operands, and flags. The encoder takes a similar data structure and
produces a sequence of 1 to 15 bytes. Disassembly is essentially a
printing pass on the data structure.
XED is the encoder/decoder used by Pin and the Intel® Software
Development Emulator (SDE). XED is used by the ASIM performance model,
ZSIM, Intel® VTune Amplifier, IACA, as well as in projects at McAfee,
Wind River, and many other projects inside and outside Intel.
XED supports the notion of layers of instructions. As new instructions
are made public corresponding to future processors, the associated
layers are added to the tables of instructions in the "datafiles"
subdirectory. (Intel announces and documents instructions in the ISE and
SDM documents typically).
---
XED License: Apache, version 2.0.
Also remove it from test-all.c, since it is not normally available on
distros at this time and not selected by default.
For the same reason, move it from FEATURE_TESTS_BASIC to
FEATURE_TESTS_EXTRA, to avoid always trying to build
tools/build/feature/test-xed.c.
One has to define XED=1 to build WITH the XED disassembler to be used in
'perf script'. It is also possible to set XED_DIR=/path to set the XED
directory.
Added the XED_DIR to CFLAGS in addition to the feature detection
specific CFLAGS, so that the following patches can work.
Testing it:
WITHOUT XED in the system, NOT explicitely selecting it:
$ make O=/tmp/build/perf -C tools/perf install-bin
$ cat /tmp/build/perf/feature/test-xed.make.output
cat: /tmp/build/perf/feature/test-xed.make.output: No such file or directory
$
The feature test is NOT performed, ok.
WITHOUT XED in the system, EXPLICITELY selecting it:
$ make XED=1 O=/tmp/build/perf -C tools/perf install-bin
$ cat /tmp/build/perf/feature/test-xed.make.output
test-xed.c:1:31: fatal error: xed/xed-interface.h: No such file or directory
#include <xed/xed-interface.h>
^
compilation terminated.
$
Ok, the test _IS_ performed, the required devel files are not found, the
build is done without XED.
Now lets try building and installing xed in this system:
$ git clone https://github.com/intelxed/mbuild.git
$ git clone https://github.com/intelxed/xed.git
$ cd xed
$ ./mfile.py
$ ./mfile.py install
And lets try enabling XED, informing where 'mfile.py install' installed
it:
$ make XED=1 XED_DIR=/home/acme/git/xed/kits/xed-install-base-2017-01-23-lin-x86-64/ O=/tmp/build/perf -C tools/perf install-bin
$ ls -la /tmp/build/perf/feature/test-xed.make.output
-rw-rw-r--. 1 acme acme 0 Jan 23 10:57 /tmp/build/perf/feature/test-xed.make.output
$
But it still doesn't link with
/home/acme/git/xed/kits/xed-install-base-2017-01-23-lin-x86-64/lib/libxed.a
because the feature will only be used in the following csets.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/r/20170119014150.19218-2-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/build/Makefile.feature | 4 +++-
tools/build/feature/Makefile | 6 +++++-
tools/build/feature/test-all.c | 14 ++++++++++++++
tools/build/feature/test-xed.c | 9 +++++++++
tools/perf/Makefile.config | 19 +++++++++++++++++++
tools/perf/Makefile.perf | 3 +++
6 files changed, 53 insertions(+), 2 deletions(-)
create mode 100644 tools/build/feature/test-xed.c
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index e3fb5ecbdcb6..a3fa78296cb5 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -78,7 +78,8 @@ FEATURE_TESTS_EXTRA := \
liberty-z \
libunwind-debug-frame \
libunwind-debug-frame-arm \
- libunwind-debug-frame-aarch64
+ libunwind-debug-frame-aarch64 \
+ xed
FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)
@@ -140,6 +141,7 @@ ifeq ($(feature-all), 1)
$(call feature_check,compile-x32)
$(call feature_check,bionic)
$(call feature_check,libbabeltrace)
+ $(call feature_check,xed)
else
$(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
endif
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b564a2eea039..4f1aa82b867a 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -48,7 +48,8 @@ FILES= \
test-get_cpuid.bin \
test-sdt.bin \
test-cxx.bin \
- test-jvmti.bin
+ test-jvmti.bin \
+ test-xed.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -123,6 +124,9 @@ $(OUTPUT)test-numa_num_possible_cpus.bin:
$(OUTPUT)test-libunwind.bin:
$(BUILD) -lelf
+$(OUTPUT)test-xed.bin:
+ $(BUILD) -lxed
+
$(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -lelf
$(OUTPUT)test-libunwind-x86.bin:
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 699e43627397..cffe9fcda7c4 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -129,6 +129,19 @@
#undef main
#endif
+#if 0
+/*
+ * Disable xed check for test-all, because it is not available
+ * in most distributions. Will reenable when it becomes generally
+ * available in major distros.
+ */
+#define main main_test_xed
+# include "test-xed.c"
+#endif
+#else
+#define main_test_xed while(0)
+#endif
+
#define main main_test_lzma
# include "test-lzma.c"
#undef main
@@ -183,6 +196,7 @@ int main(int argc, char *argv[])
main_test_bpf();
main_test_libcrypto();
main_test_sdt();
+ main_test_xed();
return 0;
}
diff --git a/tools/build/feature/test-xed.c b/tools/build/feature/test-xed.c
new file mode 100644
index 000000000000..ef9aebf1559d
--- /dev/null
+++ b/tools/build/feature/test-xed.c
@@ -0,0 +1,9 @@
+#include <xed/xed-interface.h>
+#include <xed/xed-decode.h>
+#include <xed/xed-decoded-inst-api.h>
+
+int main(void)
+{
+ xed_tables_init();
+ return 0;
+}
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 03cf947755b9..fd798d118739 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -684,6 +684,25 @@ ifndef NO_ZLIB
endif
endif
+ifdef XED
+ ifdef XED_DIR
+ XED_CFLAGS := -DHAVE_XED_SUPPORT -I$(XED_DIR)/include
+ XED_LDFLAGS := -L$(XED_DIR)/lib
+ endif
+ FEATURE_CHECK_CFLAGS-xed := $(XED_CFLAGS)
+ # override for lib64?
+ FEATURE_CHECK_LDFLAGS-xed := $(XED_LDFLAGS) -lxed
+ $(call feature_check,xed)
+ ifeq ($(feature-xed), 1)
+ CFLAGS += $(XED_CFLAGS)
+ LDFLAGS += $(XED_LDFLAGS)
+ EXTLIBS += -lxed
+ $(call detected,CONFIG_XED)
+ else
+ msg := $(warning No xed found, disables x86 disassembler support, please install xed);
+ endif
+endif
+
ifndef NO_LZMA
ifeq ($(feature-lzma), 1)
CFLAGS += -DHAVE_LZMA_SUPPORT
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 4da19b6ba94a..f6760309edd3 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -84,6 +84,9 @@ include ../scripts/utilities.mak
# Define NO_SDT if you do not want to define SDT event in perf tools,
# note that it doesn't disable SDT scanning support.
#
+# Define XED=1 to build WITH the XED disassembler for perf script
+# Can also set XED_DIR=/path to set XED directory.
+#
# Define FEATURES_DUMP to provide features detection dump file
# and bypass the feature detection
#
--
2.9.3
next prev parent reply other threads:[~2017-01-25 13:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 13:53 [GIT PULL 00/23] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 01/23] perf unwind: Fix looking up dwarf unwind stack info Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 02/23] perf hists browser: Put hist_entry folding logic into single function Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 03/23] perf hists browser: Add e/c hotkeys to expand/collapse callchain for current entry Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 04/23] perf c2c report: Display Total records column in offset view Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 05/23] perf c2c report: Coalesce by default only by pid,iaddr Arnaldo Carvalho de Melo
2017-01-25 13:53 ` Arnaldo Carvalho de Melo [this message]
2017-01-25 13:53 ` [PATCH 07/23] perf tools: Add one liner warning for disabled features Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 08/23] perf tools: Add disassembler for x86 using the XED library Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 09/23] perf script: Add support for printing assembler Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 10/23] perf script: Add "brstackasm" output for branch stacks Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 11/23] perf probe: Fix wrong register name for arm64 Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 12/23] perf probe: Delete an unnecessary check in try_to_find_absolute_address() Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 13/23] perf probe: Delete an unnecessary assignment " Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 14/23] tools lib bpf: Fix map offsets in relocation Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 15/23] tools lib bpf: Define prog_type fns with macro Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 16/23] tools lib bpf: Add set/is helpers for all prog types Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 17/23] tools lib bpf: Add libbpf_get_error() Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 18/23] perf scripting perl: Do not die() when not founding event for a type Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 19/23] perf tools: Propagate perf_config() errors Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 20/23] perf util: Save pid-cmdline mapping into tracing header Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 21/23] perf util: Add more debug message on failure path Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 22/23] perf ftrace: Introduce new 'ftrace' tool Arnaldo Carvalho de Melo
2017-01-25 13:53 ` [PATCH 23/23] perf ftrace: Make 'function_graph' be the default tracer Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170125135350.22983-7-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox