Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1410168 > unrolled thread

[PATCH v7 00/14] Add support for remote unwind

Started byHe Kuang <hekuang@huawei.com>
First post2016-05-31 13:30 +0200
Last post2016-06-01 12:10 +0200
Articles 19 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v7 00/14] Add support for remote unwind He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
    [PATCH v7 11/14] perf tools: Change fixed name of libunwind__arch_reg_id to macro He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
    [PATCH v7 06/14] perf tools: Separate local/remote libunwind config He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
      Re: [PATCH v7 06/14] perf tools: Separate local/remote libunwind  config Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:40 +0200
    [PATCH v7 07/14] perf tools: Rename unwind-libunwind.c to unwind-libunwind-local.c He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
    [PATCH v7 13/14] perf callchain: Support x86 target platform He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
      Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:50 +0200
        Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-01 14:50 +0200
          Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-06-01 15:20 +0200
      Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:50 +0200
        Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Hekuang <hekuang@huawei.com> - 2016-06-01 12:00 +0200
      Re: [PATCH v7 13/14] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:50 +0200
    [PATCH v7 09/14] perf tools: Export normalize_arch() function He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
    [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
      Re: [PATCH v7 03/14] perf tools: Introducing struct  unwind_libunwind_ops for local unwind Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:40 +0200
      Re: [PATCH v7 03/14] perf tools: Introducing struct  unwind_libunwind_ops for local unwind Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:50 +0200
    [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform He Kuang <hekuang@huawei.com> - 2016-05-31 13:30 +0200
      Re: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform Jiri Olsa <jolsa@redhat.com> - 2016-06-01 10:50 +0200
        Re: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform Hekuang <hekuang@huawei.com> - 2016-06-01 12:10 +0200

#1410168 — [PATCH v7 00/14] Add support for remote unwind

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 00/14] Add support for remote unwind
Message-ID<rEPSh-20r-5@gated-at.bofh.it>
v6 url:
  http://thread.gmane.org/gmane.linux.kernel/2229396

Currently, perf script uses host unwind methods(local unwind) to parse
perf.data callchain info regardless of the target architecture. So we
get wrong result and no promotion when do remote unwind on other
platforms/machines.

This patchset checks whether a dso is 32-bit or 64-bit according to
elf class info for each thread to let perf use the correct remote
unwind methods instead.

Only x86 and aarch64 is added in this patchset to show the work flow,
other platforms can be added easily.

We can see the right result for unwind info on different machines, for
example: perf.data recorded on i686 qemu with '-g' option and parsed
on x86_64 machine.

before this patchset:

  hello  1219 [001] 72190.667975: probe:sys_close: (c1169d60)
                  c1169d61 sys_close ([kernel.kallsyms])
                  c189c0d7 sysenter_past_esp ([kernel.kallsyms])
                  b777aba9 [unknown] ([vdso32])

after:
(Add vdso into buildid-cache first by 'perf buildid-cache -a' and
libraries are provided in symfs dir)

  hello  1219 [001] 72190.667975: probe:sys_close: (c1169d60)
                  c1169d61 sys_close ([kernel.kallsyms])
                  c189c0d7 sysenter_past_esp ([kernel.kallsyms])
                  b777aba9 __kernel_vsyscall ([vdso32])
                  b76971cc close (/lib/libc-2.22.so)
                   804842e fib (/tmp/hello)
                   804849d main (/tmp/hello)
                  b75d746e __libc_start_main (/lib/libc-2.22.so)
                   8048341 _start (/tmp/hello)

For using remote libunwind libraries, reference this:
  http://thread.gmane.org/gmane.linux.kernel/2224430

and now we can use LIBUNWIND_DIR to specific custom dirctories
containing libunwind libs.

v7:
  By following the advises from Jiri Olsa:

  - Move unwind ops struct to unwind.h
  - Add return value to function thread__insert_map()
  - Split "Separate local/remote libunwind config" into two patches,
    make commit message consistent with patch content.    
  - Move not supported warnings to "Support x86 target platform" 
  - Export $(ARCH)_unwind_libunwind_ops variables instead of
    functions.    
  - Move arch/$(ARCH)/util/unwind-libunwind-$(ARCH).c into
    util/libunwind/ folder.

Thanks.

He Kuang (14):
  perf tools: Use LIBUNWIND_DIR for remote libunwind feature check
  perf tools: Decouple thread->address_space on libunwind
  perf tools: Introducing struct unwind_libunwind_ops for local unwind
  perf tools: Move unwind__prepare_access from thread_new into
    thread__insert_map
  perf tools: Don't mix LIBUNWIND_LIBS into LIBUNWIND_LDFLAGS
  perf tools: Separate local/remote libunwind config
  perf tools: Rename unwind-libunwind.c to unwind-libunwind-local.c
  perf tools: Extract common API out of unwind-libunwind-local.c
  perf tools: Export normalize_arch() function
  perf tools: Check the target platform before assigning unwind methods
  perf tools: Change fixed name of libunwind__arch_reg_id to macro
  perf tools: Introduce flag to separate local/remote unwind compilation
  perf callchain: Support x86 target platform
  perf callchain: Support aarch64 cross-platform

 tools/perf/arch/arm/util/Build                |   2 +-
 tools/perf/arch/arm64/util/Build              |   2 +-
 tools/perf/arch/arm64/util/unwind-libunwind.c |   4 +-
 tools/perf/arch/common.c                      |   2 +-
 tools/perf/arch/common.h                      |   1 +
 tools/perf/arch/x86/util/Build                |   2 +-
 tools/perf/arch/x86/util/unwind-libunwind.c   |   6 +-
 tools/perf/config/Makefile                    |  53 +-
 tools/perf/util/Build                         |   3 +
 tools/perf/util/libunwind/arm64.c             |  18 +
 tools/perf/util/libunwind/x86_32.c            |  18 +
 tools/perf/util/machine.c                     |  10 +-
 tools/perf/util/thread.c                      |   7 +-
 tools/perf/util/thread.h                      |   9 +-
 tools/perf/util/unwind-libunwind-local.c      | 697 ++++++++++++++++++++++++++
 tools/perf/util/unwind-libunwind.c            | 694 ++-----------------------
 tools/perf/util/unwind.h                      |  27 +-
 17 files changed, 880 insertions(+), 675 deletions(-)
 create mode 100644 tools/perf/util/libunwind/arm64.c
 create mode 100644 tools/perf/util/libunwind/x86_32.c
 create mode 100644 tools/perf/util/unwind-libunwind-local.c

-- 
1.8.5.2

[toc] | [next] | [standalone]


#1410173 — [PATCH v7 11/14] perf tools: Change fixed name of libunwind__arch_reg_id to macro

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 11/14] perf tools: Change fixed name of libunwind__arch_reg_id to macro
Message-ID<rEQ1Y-24b-35@gated-at.bofh.it>
In reply to#1410168
For local libunwind, it uses the fixed methods to convert register id
according to the host platform, but in remote libunwind, this convert
function should be the one for remote architecture. This patch changes
the fixed name to macro and code for each remote platform can be
compiled indivadually.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/unwind-libunwind-local.c | 2 +-
 tools/perf/util/unwind.h                 | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 9c70486..631b40d 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -508,7 +508,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
 		return 0;
 	}
 
-	id = libunwind__arch_reg_id(regnum);
+	id = LIBUNWIND__ARCH_REG_ID(regnum);
 	if (id < 0)
 		return -EINVAL;
 
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index dda2156..c155f8b 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -29,7 +29,10 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 			struct perf_sample *data, int max_stack);
 /* libunwind specific */
 #ifdef HAVE_LIBUNWIND_SUPPORT
-int libunwind__arch_reg_id(int regnum);
+#ifndef LIBUNWIND__ARCH_REG_ID
+#define LIBUNWIND__ARCH_REG_ID libunwind__arch_reg_id
+#endif
+int LIBUNWIND__ARCH_REG_ID(int regnum);
 int unwind__prepare_access(struct thread *thread, struct map *map);
 void unwind__flush_access(struct thread *thread);
 void unwind__finish_access(struct thread *thread);
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410174 — [PATCH v7 06/14] perf tools: Separate local/remote libunwind config

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 06/14] perf tools: Separate local/remote libunwind config
Message-ID<rEQ1Z-24b-45@gated-at.bofh.it>
In reply to#1410168
CONFIG_LIBUNWIND/NO_LIBUNWIND are changed to
CONFIG_LOCAL_LIBUNWIND/NO_LOCAL_LIBUNWIND for retaining local unwind
features. The new CONFIG_LIBUNWIND stands for either local or remote
or both unwind are supported, and NO_LIBUNWIND means that neither
local nor remote unwind is supported.

LIBUNWIND_LIBS is eliminated in LDFLAGS if local libunwind is not
supported.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/arch/arm/util/Build   |  2 +-
 tools/perf/arch/arm64/util/Build |  2 +-
 tools/perf/arch/x86/util/Build   |  2 +-
 tools/perf/config/Makefile       | 21 ++++++++++++++++++---
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build
index d22e3d0..f98da17 100644
--- a/tools/perf/arch/arm/util/Build
+++ b/tools/perf/arch/arm/util/Build
@@ -1,4 +1,4 @@
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 
-libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind.o
 libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index e58123a8..02f41db 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -1,2 +1,2 @@
 libperf-$(CONFIG_DWARF)     += dwarf-regs.o
-libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build
index 4659703..bc24b75 100644
--- a/tools/perf/arch/x86/util/Build
+++ b/tools/perf/arch/x86/util/Build
@@ -7,7 +7,7 @@ libperf-y += perf_regs.o
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 libperf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o
 
-libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind.o
 libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 
 libperf-$(CONFIG_AUXTRACE) += auxtrace.o
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 118df2d..2a8915d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -353,10 +353,21 @@ ifeq ($(ARCH),powerpc)
 endif
 
 ifndef NO_LIBUNWIND
+  have_libunwind :=
   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
+  else
+    have_libunwind := 1
+    CFLAGS += -DHAVE_LIBUNWIND_LOCAL_SUPPORT
+    $(call detected,CONFIG_LOCAL_LIBUNWIND)
+  endif
+
+  ifneq ($(have_libunwind), 1)
     NO_LIBUNWIND := 1
   endif
+else
+  NO_LOCAL_LIBUNWIND := 1
 endif
 
 ifndef NO_LIBBPF
@@ -394,7 +405,7 @@ else
   NO_DWARF_UNWIND := 1
 endif
 
-ifndef NO_LIBUNWIND
+ifndef NO_LOCAL_LIBUNWIND
   ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
     $(call feature_check,libunwind-debug-frame)
     ifneq ($(feature-libunwind-debug-frame), 1)
@@ -405,10 +416,14 @@ ifndef NO_LIBUNWIND
     # non-ARM has no dwarf_find_debug_frame() function:
     CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
   endif
-  CFLAGS  += -DHAVE_LIBUNWIND_SUPPORT
   EXTLIBS += $(LIBUNWIND_LIBS)
+  LDFLAGS += $(LIBUNWIND_LIBS)
+endif
+
+ifndef NO_LIBUNWIND
+  CFLAGS  += -DHAVE_LIBUNWIND_SUPPORT
   CFLAGS  += $(LIBUNWIND_CFLAGS)
-  LDFLAGS += $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
+  LDFLAGS += $(LIBUNWIND_LDFLAGS)
 endif
 
 ifndef NO_LIBAUDIT
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410951 — Re: [PATCH v7 06/14] perf tools: Separate local/remote libunwind config

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:40 +0200
SubjectRe: [PATCH v7 06/14] perf tools: Separate local/remote libunwind config
Message-ID<rF9R1-641-45@gated-at.bofh.it>
In reply to#1410174
On Tue, May 31, 2016 at 11:19:04AM +0000, He Kuang wrote:

SNIP

>  ifndef NO_LIBUNWIND
> +  have_libunwind :=
>    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
> +  else
> +    have_libunwind := 1
> +    CFLAGS += -DHAVE_LIBUNWIND_LOCAL_SUPPORT

I dont see this defined being used..

jirka

[toc] | [prev] | [next] | [standalone]


#1410175 — [PATCH v7 07/14] perf tools: Rename unwind-libunwind.c to unwind-libunwind-local.c

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 07/14] perf tools: Rename unwind-libunwind.c to unwind-libunwind-local.c
Message-ID<rEQ1Y-24b-37@gated-at.bofh.it>
In reply to#1410168
Since unwind-libunwind.c contains code for specific arithecture, we
change it's name to unwind-libunwind-local.c, and let it only be built
if local libunwind is supported.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/Build                                            | 2 +-
 tools/perf/util/{unwind-libunwind.c => unwind-libunwind-local.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/perf/util/{unwind-libunwind.c => unwind-libunwind-local.c} (100%)

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 8c6c8a0..5e23d85 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -99,7 +99,7 @@ libperf-$(CONFIG_DWARF) += probe-finder.o
 libperf-$(CONFIG_DWARF) += dwarf-aux.o
 
 libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
-libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
 
 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
 
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind-local.c
similarity index 100%
rename from tools/perf/util/unwind-libunwind.c
rename to tools/perf/util/unwind-libunwind-local.c
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410178 — [PATCH v7 13/14] perf callchain: Support x86 target platform

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rEQ1Z-24b-47@gated-at.bofh.it>
In reply to#1410168
Support x86(32-bit) cross platform callchain unwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/arch/x86/util/unwind-libunwind.c |  6 ++++--
 tools/perf/config/Makefile                  |  8 ++++++++
 tools/perf/util/Build                       |  1 +
 tools/perf/util/libunwind/x86_32.c          | 18 ++++++++++++++++++
 tools/perf/util/unwind-libunwind.c          |  9 ++++++++-
 5 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/util/libunwind/x86_32.c

diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
index db25e93..4f16661 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -1,12 +1,14 @@
 
+#ifndef REMOTE_UNWIND_LIBUNWIND
 #include <errno.h>
 #include <libunwind.h>
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
+#endif
 
 #ifdef HAVE_ARCH_X86_64_SUPPORT
-int libunwind__arch_reg_id(int regnum)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
 	int id;
 
@@ -70,7 +72,7 @@ int libunwind__arch_reg_id(int regnum)
 	return id;
 }
 #else
-int libunwind__arch_reg_id(int regnum)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
 	int id;
 
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 2a8915d..b8d8a77 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -354,6 +354,14 @@ endif
 
 ifndef NO_LIBUNWIND
   have_libunwind :=
+
+  ifeq ($(feature-libunwind-x86), 1)
+    $(call detected,CONFIG_LIBUNWIND_X86)
+    CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
+    LDFLAGS += -lunwind-x86
+    have_libunwind = 1
+  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 004fb1d..7746e09 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -101,6 +101,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
 libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
 libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
+libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
 
 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
 
diff --git a/tools/perf/util/libunwind/x86_32.c b/tools/perf/util/libunwind/x86_32.c
new file mode 100644
index 0000000..46b4111
--- /dev/null
+++ b/tools/perf/util/libunwind/x86_32.c
@@ -0,0 +1,18 @@
+#define REMOTE_UNWIND_LIBUNWIND
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id
+
+#include "unwind.h"
+#include "debug.h"
+#include "libunwind-x86.h"
+#include <../../../../arch/x86/include/uapi/asm/perf_regs.h>
+
+#undef HAVE_ARCH_X86_64_SUPPORT
+#include "../../arch/x86/util/unwind-libunwind.c"
+
+#undef NO_LIBUNWIND_DEBUG_FRAME
+#define NO_LIBUNWIND_DEBUG_FRAME
+#include "util/unwind-libunwind-local.c"
+
+struct unwind_libunwind_ops *
+x86_32_unwind_libunwind_ops = &_unwind_libunwind_ops;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index e183390..5774317 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -5,6 +5,7 @@
 #include "arch/common.h"
 
 struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
+struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
 
 void unwind__register_ops(struct thread *thread,
 			  struct unwind_libunwind_ops *ops)
@@ -30,7 +31,13 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
 			 dso_type == DSO__TYPE_64BIT, map->dso->name);
 
 	arch = normalize_arch(thread->mg->machine->env->arch);
-	pr_debug("unwind: target platform=%s\n", arch);
+
+	if (!strcmp(arch, "x86"))
+		if (dso_type != DSO__TYPE_64BIT)
+			ops = x86_32_unwind_libunwind_ops;
+
+	if (!ops)
+		pr_err("unwind: target platform=%s is not supported\n", arch);
 
 	unwind__register_ops(thread, ops);
 
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410974 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:50 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFa0G-67A-21@gated-at.bofh.it>
In reply to#1410178
On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:

SNIP

> +
> +  ifeq ($(feature-libunwind-x86), 1)
> +    $(call detected,CONFIG_LIBUNWIND_X86)
> +    CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
> +    LDFLAGS += -lunwind-x86
> +    have_libunwind = 1
> +  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 004fb1d..7746e09 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -101,6 +101,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
>  libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
>  libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
>  libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
> +libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o

seems odd but I dont have any better idea.. let's see what
others have to say ;-)

thanks,
jirka

[toc] | [prev] | [next] | [standalone]


#1411165 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-06-01 14:50 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFdKW-8sS-15@gated-at.bofh.it>
In reply to#1410974
Em Wed, Jun 01, 2016 at 10:40:15AM +0200, Jiri Olsa escreveu:
> On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:
 
> SNIP
> > +  ifeq ($(feature-libunwind-x86), 1)
> > +    $(call detected,CONFIG_LIBUNWIND_X86)
> > +    CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
> > +    LDFLAGS += -lunwind-x86
> > +    have_libunwind = 1
> > +  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
> > +++ b/tools/perf/util/Build
> > @@ -101,6 +101,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
> >  libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
> >  libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
> >  libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
> > +libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
> 
> seems odd but I dont have any better idea.. let's see what
> others have to say ;-)

There was a lot of discussion in this patchkit, so I lost track of why I
should consider the above odd :-)

I.e. I take the above as: if x86 libunwind was detected or explicitely
selected, link support for it when generating the perf tool in any
architecture, which seems sensible, no?

- Arnaldo

[toc] | [prev] | [next] | [standalone]


#1411207 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 15:20 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFedY-qG-43@gated-at.bofh.it>
In reply to#1411165
On Wed, Jun 01, 2016 at 09:47:50AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jun 01, 2016 at 10:40:15AM +0200, Jiri Olsa escreveu:
> > On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:
>  
> > SNIP
> > > +  ifeq ($(feature-libunwind-x86), 1)
> > > +    $(call detected,CONFIG_LIBUNWIND_X86)
> > > +    CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
> > > +    LDFLAGS += -lunwind-x86
> > > +    have_libunwind = 1
> > > +  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
> > > +++ b/tools/perf/util/Build
> > > @@ -101,6 +101,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
> > >  libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
> > >  libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
> > >  libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
> > > +libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
> > 
> > seems odd but I dont have any better idea.. let's see what
> > others have to say ;-)
> 
> There was a lot of discussion in this patchkit, so I lost track of why I
> should consider the above odd :-)
> 
> I.e. I take the above as: if x86 libunwind was detected or explicitely
> selected, link support for it when generating the perf tool in any
> architecture, which seems sensible, no?

yep.. the x86_32 name under generic dir is what seems odd to me,
but it's like you said.. anyway we can always change if we find
some better solution ;-)

jirka

[toc] | [prev] | [next] | [standalone]


#1410977 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:50 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFa0G-67A-37@gated-at.bofh.it>
In reply to#1410178
On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:

SNIP

> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> index e183390..5774317 100644
> --- a/tools/perf/util/unwind-libunwind.c
> +++ b/tools/perf/util/unwind-libunwind.c
> @@ -5,6 +5,7 @@
>  #include "arch/common.h"
>  
>  struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
> +struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
>  
>  void unwind__register_ops(struct thread *thread,
>  			  struct unwind_libunwind_ops *ops)
> @@ -30,7 +31,13 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
>  			 dso_type == DSO__TYPE_64BIT, map->dso->name);
>  
>  	arch = normalize_arch(thread->mg->machine->env->arch);
> -	pr_debug("unwind: target platform=%s\n", arch);
> +
> +	if (!strcmp(arch, "x86"))
> +		if (dso_type != DSO__TYPE_64BIT)
> +			ops = x86_32_unwind_libunwind_ops;
> +
> +	if (!ops)
> +		pr_err("unwind: target platform=%s is not supported\n", arch);

how could ops become NULL in here? it starts with local_unwind_libunwind_ops
I dont think this check is needed in here

jirka

[toc] | [prev] | [next] | [standalone]


#1411048 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromHekuang <hekuang@huawei.com>
Date2016-06-01 12:00 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFb6q-6Mh-17@gated-at.bofh.it>
In reply to#1410977

在 2016/6/1 16:40, Jiri Olsa 写道:
> On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:
>
> SNIP
>
>> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
>> index e183390..5774317 100644
>> --- a/tools/perf/util/unwind-libunwind.c
>> +++ b/tools/perf/util/unwind-libunwind.c
>> @@ -5,6 +5,7 @@
>>   #include "arch/common.h"
>>   
>>   struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
>> +struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
>>   
>>   void unwind__register_ops(struct thread *thread,
>>   			  struct unwind_libunwind_ops *ops)
>> @@ -30,7 +31,13 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
>>   			 dso_type == DSO__TYPE_64BIT, map->dso->name);
>>   
>>   	arch = normalize_arch(thread->mg->machine->env->arch);
>> -	pr_debug("unwind: target platform=%s\n", arch);
>> +
>> +	if (!strcmp(arch, "x86"))
>> +		if (dso_type != DSO__TYPE_64BIT)
>> +			ops = x86_32_unwind_libunwind_ops;
>> +
>> +	if (!ops)
>> +		pr_err("unwind: target platform=%s is not supported\n", arch);
> how could ops become NULL in here? it starts with local_unwind_libunwind_ops
> I dont think this check is needed in here

x86_32_unwind_libunwind_ops is a null pointer when x86_32
libunwind is not supported.

There's a weak defination if CONFIG_LIBUNWIND_X86 is not set.

    struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;

In this case, ops is null and "x86_32 is not supported" error
message is showed up.

> jirka
>

[toc] | [prev] | [next] | [standalone]


#1410979 — Re: [PATCH v7 13/14] perf callchain: Support x86 target platform

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:50 +0200
SubjectRe: [PATCH v7 13/14] perf callchain: Support x86 target platform
Message-ID<rFa0G-67A-39@gated-at.bofh.it>
In reply to#1410178
On Tue, May 31, 2016 at 11:19:11AM +0000, He Kuang wrote:

SNIP

> diff --git a/tools/perf/util/libunwind/x86_32.c b/tools/perf/util/libunwind/x86_32.c
> new file mode 100644
> index 0000000..46b4111
> --- /dev/null
> +++ b/tools/perf/util/libunwind/x86_32.c
> @@ -0,0 +1,18 @@
> +#define REMOTE_UNWIND_LIBUNWIND
> +
> +#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id
> +
> +#include "unwind.h"
> +#include "debug.h"
> +#include "libunwind-x86.h"
> +#include <../../../../arch/x86/include/uapi/asm/perf_regs.h>
> +
> +#undef HAVE_ARCH_X86_64_SUPPORT
> +#include "../../arch/x86/util/unwind-libunwind.c"
> +
> +#undef NO_LIBUNWIND_DEBUG_FRAME
> +#define NO_LIBUNWIND_DEBUG_FRAME

so debug_frame is explicitly switched off for remote unwind? 2 things:

  - could we have some comments/reasonning for un/setting defines in here
    (and the other arch files)
  - could you please use the #ifndef XXX #define XXX #endif way

thanks,
jirka

[toc] | [prev] | [next] | [standalone]


#1410179 — [PATCH v7 09/14] perf tools: Export normalize_arch() function

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 09/14] perf tools: Export normalize_arch() function
Message-ID<rEQ1Z-24b-59@gated-at.bofh.it>
In reply to#1410168
Export normalize_arch() function, so other part of perf can get
normalized form of arch string.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/arch/common.c | 2 +-
 tools/perf/arch/common.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index e83c8ce..fa090a9 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -102,7 +102,7 @@ static int lookup_triplets(const char *const *triplets, const char *name)
  * Return architecture name in a normalized form.
  * The conversion logic comes from the Makefile.
  */
-static const char *normalize_arch(char *arch)
+const char *normalize_arch(char *arch)
 {
 	if (!strcmp(arch, "x86_64"))
 		return "x86";
diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h
index 7529cfb..6b01c73 100644
--- a/tools/perf/arch/common.h
+++ b/tools/perf/arch/common.h
@@ -6,5 +6,6 @@
 extern const char *objdump_path;
 
 int perf_env__lookup_objdump(struct perf_env *env);
+const char *normalize_arch(char *arch);
 
 #endif /* ARCH_PERF_COMMON_H */
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410182 — [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind
Message-ID<rEQ1Z-24b-61@gated-at.bofh.it>
In reply to#1410168
Currently, libunwind operations are fixed, and they are chosen
according to the host architecture. This will lead a problem that if a
thread is run as x86_32 on x86_64 machine, perf will use libunwind
methods for x86_64 to parse the callchain and get wrong result.

This patch changes the fixed methods of libunwind operations to
thread/map related, and each thread can have indivadual libunwind
operations. Local libunwind methods are registered as default value.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/thread.c           |  6 ++++
 tools/perf/util/thread.h           |  4 ++-
 tools/perf/util/unwind-libunwind.c | 58 +++++++++++++++++++++++++++++++++++---
 tools/perf/util/unwind.h           | 19 +++++++++++++
 4 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 45fcb71..95ff1b8 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -43,6 +43,12 @@ struct thread *thread__new(pid_t pid, pid_t tid)
 		thread->cpu = -1;
 		INIT_LIST_HEAD(&thread->comm_list);
 
+#ifdef HAVE_LIBUNWIND_SUPPORT
+		unwind__register_ops(thread, local_unwind_libunwind_ops);
+#else
+		unwind__register_ops(thread, NULL);
+#endif
+
 		if (unwind__prepare_access(thread) < 0)
 			goto err_thread;
 
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index aa3a8ff..152fb9a 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -11,6 +11,7 @@
 #include <intlist.h>
 
 struct thread_stack;
+struct unwind_libunwind_ops;
 
 struct thread {
 	union {
@@ -33,7 +34,8 @@ struct thread {
 	void			*priv;
 	struct thread_stack	*ts;
 #ifdef HAVE_LIBUNWIND_SUPPORT
-	void			*addr_space;
+	void				*addr_space;
+	struct unwind_libunwind_ops	*unwind_libunwind_ops;
 #endif
 };
 
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 63687d3..77b8521 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -579,7 +579,7 @@ static unw_accessors_t accessors = {
 	.get_proc_name		= get_proc_name,
 };
 
-int unwind__prepare_access(struct thread *thread)
+static int _unwind__prepare_access(struct thread *thread)
 {
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return 0;
@@ -594,7 +594,7 @@ int unwind__prepare_access(struct thread *thread)
 	return 0;
 }
 
-void unwind__flush_access(struct thread *thread)
+static void _unwind__flush_access(struct thread *thread)
 {
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
@@ -602,7 +602,7 @@ void unwind__flush_access(struct thread *thread)
 	unw_flush_cache(thread->addr_space, 0, 0);
 }
 
-void unwind__finish_access(struct thread *thread)
+static void _unwind__finish_access(struct thread *thread)
 {
 	if (callchain_param.record_mode != CALLCHAIN_DWARF)
 		return;
@@ -662,7 +662,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 	return ret;
 }
 
-int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
+static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 			struct thread *thread,
 			struct perf_sample *data, int max_stack)
 {
@@ -680,3 +680,53 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 
 	return get_entries(&ui, cb, arg, max_stack);
 }
+
+static struct unwind_libunwind_ops
+_unwind_libunwind_ops = {
+	.prepare_access = _unwind__prepare_access,
+	.flush_access   = _unwind__flush_access,
+	.finish_access  = _unwind__finish_access,
+	.get_entries    = _unwind__get_entries,
+};
+
+struct unwind_libunwind_ops *
+local_unwind_libunwind_ops = &_unwind_libunwind_ops;
+
+void unwind__register_ops(struct thread *thread,
+			  struct unwind_libunwind_ops *ops)
+{
+	thread->unwind_libunwind_ops = ops;
+}
+
+int unwind__prepare_access(struct thread *thread)
+{
+	if (thread->unwind_libunwind_ops)
+		return thread->unwind_libunwind_ops->prepare_access(thread);
+	else
+		return 0;
+}
+
+void unwind__flush_access(struct thread *thread)
+{
+	if (thread->unwind_libunwind_ops)
+		thread->unwind_libunwind_ops->flush_access(thread);
+}
+
+void unwind__finish_access(struct thread *thread)
+{
+	if (thread->unwind_libunwind_ops)
+		thread->unwind_libunwind_ops->finish_access(thread);
+}
+
+int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
+			 struct thread *thread,
+			 struct perf_sample *data, int max_stack)
+{
+	if (thread->unwind_libunwind_ops)
+		return thread->unwind_libunwind_ops->get_entries(cb, arg,
+								 thread,
+								 data,
+								 max_stack);
+	else
+		return 0;
+}
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 12790cf..bd7377b 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -14,6 +14,17 @@ struct unwind_entry {
 
 typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
 
+struct unwind_libunwind_ops {
+	int (*prepare_access)(struct thread *thread);
+	void (*flush_access)(struct thread *thread);
+	void (*finish_access)(struct thread *thread);
+	int (*get_entries)(unwind_entry_cb_t cb, void *arg,
+			   struct thread *thread,
+			   struct perf_sample *data, int max_stack);
+};
+
+struct unwind_libunwind_ops *local_unwind_libunwind_ops;
+
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 			struct thread *thread,
@@ -24,6 +35,8 @@ int libunwind__arch_reg_id(int regnum);
 int unwind__prepare_access(struct thread *thread);
 void unwind__flush_access(struct thread *thread);
 void unwind__finish_access(struct thread *thread);
+void unwind__register_ops(struct thread *thread,
+			  struct unwind_libunwind_ops *ops);
 #else
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
 {
@@ -32,6 +45,9 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
 
 static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
 static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
+static inline void
+unwind__register_ops(struct thread *thread __maybe_unused,
+		     struct unwind_libunwind_ops *ops __maybe_unused) {}
 #endif
 #else
 static inline int
@@ -51,5 +67,8 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
 
 static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
 static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
+static inline void
+unwind__register_ops(struct thread *thread __maybe_unused,
+		     struct unwind_libunwind_ops *ops __maybe_unused) {}
 #endif /* HAVE_DWARF_UNWIND_SUPPORT */
 #endif /* __UNWIND_H */
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410956 — Re: [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:40 +0200
SubjectRe: [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind
Message-ID<rF9R0-641-41@gated-at.bofh.it>
In reply to#1410182
On Tue, May 31, 2016 at 11:19:01AM +0000, He Kuang wrote:
> Currently, libunwind operations are fixed, and they are chosen
> according to the host architecture. This will lead a problem that if a
> thread is run as x86_32 on x86_64 machine, perf will use libunwind
> methods for x86_64 to parse the callchain and get wrong result.
> 
> This patch changes the fixed methods of libunwind operations to
> thread/map related, and each thread can have indivadual libunwind
> operations. Local libunwind methods are registered as default value.
> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/thread.c           |  6 ++++
>  tools/perf/util/thread.h           |  4 ++-
>  tools/perf/util/unwind-libunwind.c | 58 +++++++++++++++++++++++++++++++++++---
>  tools/perf/util/unwind.h           | 19 +++++++++++++
>  4 files changed, 82 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index 45fcb71..95ff1b8 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -43,6 +43,12 @@ struct thread *thread__new(pid_t pid, pid_t tid)
>  		thread->cpu = -1;
>  		INIT_LIST_HEAD(&thread->comm_list);
>  
> +#ifdef HAVE_LIBUNWIND_SUPPORT
> +		unwind__register_ops(thread, local_unwind_libunwind_ops);
> +#else
> +		unwind__register_ops(thread, NULL);
> +#endif

is it needed to register NULL? it's there by init right?

jirka

[toc] | [prev] | [next] | [standalone]


#1410964 — Re: [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:50 +0200
SubjectRe: [PATCH v7 03/14] perf tools: Introducing struct unwind_libunwind_ops for local unwind
Message-ID<rFa0F-67A-9@gated-at.bofh.it>
In reply to#1410182
On Tue, May 31, 2016 at 11:19:01AM +0000, He Kuang wrote:
> Currently, libunwind operations are fixed, and they are chosen
> according to the host architecture. This will lead a problem that if a
> thread is run as x86_32 on x86_64 machine, perf will use libunwind
> methods for x86_64 to parse the callchain and get wrong result.
> 
> This patch changes the fixed methods of libunwind operations to
> thread/map related, and each thread can have indivadual libunwind
> operations. Local libunwind methods are registered as default value.
> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/thread.c           |  6 ++++
>  tools/perf/util/thread.h           |  4 ++-
>  tools/perf/util/unwind-libunwind.c | 58 +++++++++++++++++++++++++++++++++++---
>  tools/perf/util/unwind.h           | 19 +++++++++++++
>  4 files changed, 82 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index 45fcb71..95ff1b8 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -43,6 +43,12 @@ struct thread *thread__new(pid_t pid, pid_t tid)
>  		thread->cpu = -1;
>  		INIT_LIST_HEAD(&thread->comm_list);
>  
> +#ifdef HAVE_LIBUNWIND_SUPPORT
> +		unwind__register_ops(thread, local_unwind_libunwind_ops);
> +#else
> +		unwind__register_ops(thread, NULL);
> +#endif
> +

I think we should put unwind__register_ops call into unwind__prepare_access
in this patch (like you do in patch 4) and without the #else clause

this way you can keep unwind__register_ops local

thanks,
jirka

[toc] | [prev] | [next] | [standalone]


#1410183 — [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform

FromHe Kuang <hekuang@huawei.com>
Date2016-05-31 13:30 +0200
Subject[PATCH v7 14/14] perf callchain: Support aarch64 cross-platform
Message-ID<rEQ20-24b-75@gated-at.bofh.it>
In reply to#1410168
Support aarch64 cross platform callchain unwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/arch/arm64/util/unwind-libunwind.c |  4 +++-
 tools/perf/config/Makefile                    | 12 ++++++++++++
 tools/perf/util/Build                         |  1 +
 tools/perf/util/libunwind/arm64.c             | 18 ++++++++++++++++++
 tools/perf/util/unwind-libunwind.c            |  7 ++++++-
 5 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/util/libunwind/arm64.c

diff --git a/tools/perf/arch/arm64/util/unwind-libunwind.c b/tools/perf/arch/arm64/util/unwind-libunwind.c
index a87afa9..c116b71 100644
--- a/tools/perf/arch/arm64/util/unwind-libunwind.c
+++ b/tools/perf/arch/arm64/util/unwind-libunwind.c
@@ -1,11 +1,13 @@
 
+#ifndef REMOTE_UNWIND_LIBUNWIND
 #include <errno.h>
 #include <libunwind.h>
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
+#endif
 
-int libunwind__arch_reg_id(int regnum)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
 	switch (regnum) {
 	case UNW_AARCH64_X0:
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index b8d8a77..00bd141 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -362,6 +362,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-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 7746e09..fced833 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -102,6 +102,7 @@ libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
 libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
 libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
+libperf-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
 
 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
 
diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
new file mode 100644
index 0000000..99c0d42
--- /dev/null
+++ b/tools/perf/util/libunwind/arm64.c
@@ -0,0 +1,18 @@
+#define REMOTE_UNWIND_LIBUNWIND
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__arm64_reg_id
+
+#include "unwind.h"
+#include "debug.h"
+#include "libunwind-aarch64.h"
+#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
+#include "../../arch/arm64/util/unwind-libunwind.c"
+
+#undef NO_LIBUNWIND_DEBUG_FRAME
+#ifdef NO_LIBUNWIND_DEBUG_FRAME_AARCH64
+#define NO_LIBUNWIND_DEBUG_FRAME
+#endif
+#include "util/unwind-libunwind-local.c"
+
+struct unwind_libunwind_ops *
+arm64_unwind_libunwind_ops = &_unwind_libunwind_ops;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 5774317..b5f6ca2 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -6,6 +6,7 @@
 
 struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
 struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
+struct unwind_libunwind_ops __weak *arm64_unwind_libunwind_ops;
 
 void unwind__register_ops(struct thread *thread,
 			  struct unwind_libunwind_ops *ops)
@@ -32,9 +33,13 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
 
 	arch = normalize_arch(thread->mg->machine->env->arch);
 
-	if (!strcmp(arch, "x86"))
+	if (!strcmp(arch, "x86")) {
 		if (dso_type != DSO__TYPE_64BIT)
 			ops = x86_32_unwind_libunwind_ops;
+	} else if (!strcmp(arch, "arm64") || !strcmp(arch, "arm")) {
+		if (dso_type == DSO__TYPE_64BIT)
+			ops = arm64_unwind_libunwind_ops;
+	}
 
 	if (!ops)
 		pr_err("unwind: target platform=%s is not supported\n", arch);
-- 
1.8.5.2

[toc] | [prev] | [next] | [standalone]


#1410970 — Re: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform

FromJiri Olsa <jolsa@redhat.com>
Date2016-06-01 10:50 +0200
SubjectRe: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform
Message-ID<rFa0G-67A-19@gated-at.bofh.it>
In reply to#1410183
On Tue, May 31, 2016 at 11:19:12AM +0000, He Kuang wrote:

SNIP

> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 7746e09..fced833 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -102,6 +102,7 @@ libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
>  libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
>  libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
>  libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
> +libperf-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
>  
>  libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
>  
> diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
> new file mode 100644
> index 0000000..99c0d42
> --- /dev/null
> +++ b/tools/perf/util/libunwind/arm64.c
> @@ -0,0 +1,18 @@

also please add some comments in here describing how this file works
like that it setups defines to compile arch specific binary from the
generic one, which is then represented by the arm64_unwind_libunwind_ops,
which get assigned for each arm64 thread 

or something along those lines

thanks,
jirka

> +#define REMOTE_UNWIND_LIBUNWIND
> +
> +#define LIBUNWIND__ARCH_REG_ID libunwind__arm64_reg_id
> +
> +#include "unwind.h"
> +#include "debug.h"
> +#include "libunwind-aarch64.h"
> +#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
> +#include "../../arch/arm64/util/unwind-libunwind.c"
> +
> +#undef NO_LIBUNWIND_DEBUG_FRAME
> +#ifdef NO_LIBUNWIND_DEBUG_FRAME_AARCH64
> +#define NO_LIBUNWIND_DEBUG_FRAME
> +#endif
> +#include "util/unwind-libunwind-local.c"
> +
> +struct unwind_libunwind_ops *
> +arm64_unwind_libunwind_ops = &_unwind_libunwind_ops;

SNIP

[toc] | [prev] | [next] | [standalone]


#1411055 — Re: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform

FromHekuang <hekuang@huawei.com>
Date2016-06-01 12:10 +0200
SubjectRe: [PATCH v7 14/14] perf callchain: Support aarch64 cross-platform
Message-ID<rFbg5-74G-17@gated-at.bofh.it>
In reply to#1410970

在 2016/6/1 16:40, Jiri Olsa 写道:
> On Tue, May 31, 2016 at 11:19:12AM +0000, He Kuang wrote:
>
> SNIP
>
>> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
>> index 7746e09..fced833 100644
>> --- a/tools/perf/util/Build
>> +++ b/tools/perf/util/Build
>> @@ -102,6 +102,7 @@ libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
>>   libperf-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
>>   libperf-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
>>   libperf-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
>> +libperf-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
>>   
>>   libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
>>   
>> diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
>> new file mode 100644
>> index 0000000..99c0d42
>> --- /dev/null
>> +++ b/tools/perf/util/libunwind/arm64.c
>> @@ -0,0 +1,18 @@
> also please add some comments in here describing how this file works
> like that it setups defines to compile arch specific binary from the
> generic one, which is then represented by the arm64_unwind_libunwind_ops,
> which get assigned for each arm64 thread
>
> or something along those lines
>
> thanks,
> jirka
ok
>> +#define REMOTE_UNWIND_LIBUNWIND
>> +
>> +#define LIBUNWIND__ARCH_REG_ID libunwind__arm64_reg_id
>> +
>> +#include "unwind.h"
>> +#include "debug.h"
>> +#include "libunwind-aarch64.h"
>> +#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
>> +#include "../../arch/arm64/util/unwind-libunwind.c"
>> +
>> +#undef NO_LIBUNWIND_DEBUG_FRAME
>> +#ifdef NO_LIBUNWIND_DEBUG_FRAME_AARCH64
>> +#define NO_LIBUNWIND_DEBUG_FRAME
>> +#endif
>> +#include "util/unwind-libunwind-local.c"
>> +
>> +struct unwind_libunwind_ops *
>> +arm64_unwind_libunwind_ops = &_unwind_libunwind_ops;
> SNIP
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web