All of lore.kernel.org
 help / color / mirror / Atom feed
From: He Kuang <hekuang@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<alexander.shishkin@linux.intel.com>, <jolsa@redhat.com>,
	<wangnan0@huawei.com>, <hekuang@huawei.com>,
	<jpoimboe@redhat.com>, <ak@linux.intel.com>, <eranian@google.com>,
	<namhyung@kernel.org>, <adrian.hunter@intel.com>,
	<sukadev@linux.vnet.ibm.com>, <masami.hiramatsu.pt@hitachi.com>,
	<tumanova@linux.vnet.ibm.com>, <kan.liang@intel.com>,
	<penberg@kernel.org>, <dsahern@gmail.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 8/8] perf callchain: Support aarch64 cross-platform
Date: Fri, 6 May 2016 08:59:14 +0000	[thread overview]
Message-ID: <1462525154-125656-9-git-send-email-hekuang@huawei.com> (raw)
In-Reply-To: <1462525154-125656-1-git-send-email-hekuang@huawei.com>

Support aarch64 cross platform callchain unwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 .../perf/arch/arm64/include/libunwind/libunwind-arch.h | 18 ++++++++++++++++++
 tools/perf/arch/arm64/util/unwind-libunwind.c          |  5 ++++-
 tools/perf/config/Makefile                             | 12 ++++++++++++
 tools/perf/util/Build                                  |  4 ++++
 tools/perf/util/thread.c                               | 12 ++++++++++++
 tools/perf/util/unwind.h                               |  3 +++
 6 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h

diff --git a/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h b/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
new file mode 100644
index 0000000..7bc8a00
--- /dev/null
+++ b/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
@@ -0,0 +1,18 @@
+#ifndef _LIBUNWIND_ARCH_H
+#define _LIBUNWIND_ARCH_H
+
+#include <libunwind-aarch64.h>
+#include <../perf_regs.h>
+#include <../../../../../../arch/arm64/include/uapi/asm/perf_regs.h>
+
+#define LIBUNWIND_AARCH64
+int libunwind__aarch64_reg_id(int regnum);
+
+#include <../../../arm64/util/unwind-libunwind.c>
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__aarch64_reg_id
+
+#define UNWT_PREFIX	UNW_PASTE(UNW_PASTE(_U, aarch64), _)
+#define UNWT_OBJ(fn)	UNW_PASTE(UNWT_PREFIX, fn)
+
+#endif /* _LIBUNWIND_ARCH_H */
diff --git a/tools/perf/arch/arm64/util/unwind-libunwind.c b/tools/perf/arch/arm64/util/unwind-libunwind.c
index a87afa9..5b557a5 100644
--- a/tools/perf/arch/arm64/util/unwind-libunwind.c
+++ b/tools/perf/arch/arm64/util/unwind-libunwind.c
@@ -1,11 +1,14 @@
 
 #include <errno.h>
-#include <libunwind.h>
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
 
+#ifndef LIBUNWIND_AARCH64
 int libunwind__arch_reg_id(int regnum)
+#else
+int libunwind__aarch64_reg_id(int regnum)
+#endif
 {
 	switch (regnum) {
 	case UNW_AARCH64_X0:
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 16f14b1..c1bfc5e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -353,6 +353,18 @@ ifndef NO_LIBUNWIND
     have_libunwind = 1
   endif
 
+  ifeq ($(feature-libunwind-aarch64), 1)
+    $(call detected,CONFIG_LIBUNWIND_AARCH64)
+    CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
+    LDFLAGS += -lunwind -lunwind-aarch64
+    have_libunwind = 1
+    $(call feature_check,libunwind-debug-frame-aarch64)
+    ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
+      msg := $(warning No debug_frame support found in libunwind-aarch64);
+      CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
+    endif
+  endif
+
   ifneq ($(feature-libunwind), 1)
     msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
     NO_LOCAL_LIBUNWIND := 1
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 2dd3939..10e42ad 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -102,10 +102,14 @@ libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind.o
 libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind_common.o
 libperf-$(CONFIG_LIBUNWIND_X86)      += unwind-libunwind_x86_32.o
+libperf-$(CONFIG_LIBUNWIND_AARCH64)  += unwind-libunwind_arm64.o
 
 $(OUTPUT)util/unwind-libunwind_x86_32.o: util/unwind-libunwind.c arch/x86/util/unwind-libunwind.c
 	$(QUIET_CC)$(CC) $(CFLAGS) -DARCH_UNWIND_LIBUNWIND -Iarch/x86/include/libunwind -c -o $@ util/unwind-libunwind.c
 
+$(OUTPUT)util/unwind-libunwind_arm64.o: util/unwind-libunwind.c arch/arm64/util/unwind-libunwind.c
+	$(QUIET_CC)$(CC) $(CFLAGS) -DARCH_UNWIND_LIBUNWIND -Iarch/arm64/include/libunwind -c -o $@ util/unwind-libunwind.c
+
 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
 
 libperf-y += scripting-engines/
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 2b93856..ba3e597 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -221,6 +221,18 @@ void thread__insert_map(struct thread *thread, struct map *map)
 			goto err;
 #endif
 		}
+	} else if (!strcmp(arch, "aarch64") || !strncmp(arch, "arm", 3)) {
+		pr_debug("Thread map is ARM, 64bit is %d, dso=%s\n",
+			 is_64_bit, map->dso->name);
+		if (is_64_bit) {
+#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT
+			register_unwind_libunwind_ops(
+				&_Uaarch64_unwind_libunwind_ops, thread);
+#else
+			register_null_unwind_libunwind_ops(thread);
+			goto err;
+#endif
+		}
 	} else {
 		register_local_unwind_libunwind_ops(thread);
 	}
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 98d40bd..d215717 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -59,6 +59,9 @@ static inline void unwind__finish_access(struct thread *thread __maybe_unused) {
 #ifdef HAVE_LIBUNWIND_X86_SUPPORT
 extern struct unwind_libunwind_ops _Ux86_unwind_libunwind_ops;
 #endif
+#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT
+extern struct unwind_libunwind_ops _Uaarch64_unwind_libunwind_ops;
+#endif
 
 #else
 static inline int
-- 
1.8.5.2

  parent reply	other threads:[~2016-05-06  9:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06  8:59 [PATCH 0/8] Add support for remote unwind He Kuang
2016-05-06  8:59 ` [PATCH 1/8] perf tools: Omit DWARF judgement when recording dwarf callchain He Kuang
2016-05-06 11:47   ` Arnaldo Carvalho de Melo
2016-05-07 18:03   ` Jiri Olsa
2016-05-09 16:16     ` Arnaldo Carvalho de Melo
2016-05-10  1:44       ` Hekuang
2016-05-10 20:30   ` [tip:perf/core] perf callchain: Recording 'dwarf' callchains do not need DWARF unwinding support tip-bot for He Kuang
2016-05-06  8:59 ` [PATCH 2/8] perf script: Add options for custom vdso name He Kuang
2016-05-06 11:49   ` Arnaldo Carvalho de Melo
2016-05-07 18:14   ` Jiri Olsa
2016-05-06  8:59 ` [PATCH 3/8] perf build: Add build-test for libunwind cross-platforms support He Kuang
2016-05-07 18:20   ` Jiri Olsa
2016-05-06  8:59 ` [PATCH 4/8] perf build: Add build-test for debug-frame on arm/arm64 He Kuang
2016-05-07 18:24   ` Jiri Olsa
2016-05-06  8:59 ` [PATCH 5/8] perf tools: Promote proper messages for cross-platform unwind He Kuang
2016-05-07 18:41   ` Jiri Olsa
2016-05-07 18:42   ` Jiri Olsa
2016-05-06  8:59 ` [PATCH 6/8] perf callchain: Add support " He Kuang
2016-05-06 11:56   ` Arnaldo Carvalho de Melo
2016-05-06  8:59 ` [PATCH 7/8] perf callchain: Support x86 target platform He Kuang
2016-05-06  8:59 ` He Kuang [this message]
2016-05-06 11:58 ` [PATCH 0/8] Add support for remote unwind 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=1462525154-125656-9-git-send-email-hekuang@huawei.com \
    --to=hekuang@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=penberg@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=tumanova@linux.vnet.ibm.com \
    --cc=wangnan0@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.