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


Groups > linux.kernel > #1395728 > unrolled thread

[PATCH 0/8] Add support for remote unwind

Started byHe Kuang <hekuang@huawei.com>
First post2016-05-06 11:10 +0200
Last post2016-05-06 14:00 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/8] Add support for remote unwind He Kuang <hekuang@huawei.com> - 2016-05-06 11:10 +0200
    [PATCH 7/8] perf callchain: Support x86 target platform He Kuang <hekuang@huawei.com> - 2016-05-06 11:10 +0200
    [PATCH 2/8] perf script: Add options for custom vdso name He Kuang <hekuang@huawei.com> - 2016-05-06 11:10 +0200
      Re: [PATCH 2/8] perf script: Add options for custom vdso name Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-06 13:50 +0200
      Re: [PATCH 2/8] perf script: Add options for custom vdso name Jiri Olsa <jolsa@redhat.com> - 2016-05-07 20:20 +0200
    Re: [PATCH 0/8] Add support for remote unwind Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-06 14:00 +0200

#1395728 — [PATCH 0/8] Add support for remote unwind

FromHe Kuang <hekuang@huawei.com>
Date2016-05-06 11:10 +0200
Subject[PATCH 0/8] Add support for remote unwind
Message-ID<rvJVM-2eU-17@gated-at.bofh.it>
Currently, perf script uses host unwind methods 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 patch set adds build tests for the supported platforms for remote
unwinding, and checks the map elf info for each thread, use remote
unwind methods instead.

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

We can see the right result for unwind infos on different machines,
for example: we record perf.data on i686 qemu with '-g' option and
parse it on x86_64 machine.

before this patchset:

  hello  1071 [000]   417.567832: probe:sys_close: (c1169d60)
                  c1169d61 sys_close ([kernel.kallsyms])
                  c189c0d7 sysenter_past_esp ([kernel.kallsyms])
                  b77c8ba9 [unknown] ([vdso32])
  
after:

  hello  1071 [000]   417.567832: probe:sys_close: (c1169d60)
                  c1169d61 sys_close ([kernel.kallsyms])
                  c189c0d7 sysenter_past_esp ([kernel.kallsyms])
                  b77c8ba9 [unknown] ([vdso32])
                  b76e51cc close (/lib/libc-2.22.so)
                   804842e fib (/tmp/hello)
                   804849d main (/tmp/hello)
                  b762546e __libc_start_main (/lib/libc-2.22.so)
                   8048341 _start (/tmp/hello)

Thanks, discussion welcomed.

He Kuang (8):
  perf tools: Omit DWARF judgement when recording dwarf callchain
  perf script: Add options for custom vdso name
  perf build: Add build-test for libunwind cross-platforms support
  perf build: Add build-test for debug-frame on arm/arm64
  perf tools: Promote proper messages for cross-platform unwind
  perf callchain: Add support for cross-platform unwind
  perf callchain: Support x86 target platform
  perf callchain: Support aarch64 cross-platform

 tools/build/Makefile.feature                       | 11 +++-
 tools/build/feature/Makefile                       | 26 +++++++-
 tools/build/feature/test-libunwind-aarch64.c       | 26 ++++++++
 tools/build/feature/test-libunwind-arm.c           | 27 +++++++++
 .../feature/test-libunwind-debug-frame-aarch64.c   | 16 +++++
 .../build/feature/test-libunwind-debug-frame-arm.c | 16 +++++
 tools/build/feature/test-libunwind-debug-frame.c   | 16 -----
 tools/build/feature/test-libunwind-x86.c           | 27 +++++++++
 tools/build/feature/test-libunwind-x86_64.c        | 27 +++++++++
 .../arch/arm64/include/libunwind/libunwind-arch.h  | 18 ++++++
 tools/perf/arch/arm64/util/unwind-libunwind.c      |  5 +-
 .../arch/x86/include/libunwind/libunwind-arch.h    | 18 ++++++
 tools/perf/arch/x86/util/unwind-libunwind.c        | 42 +++++++++++++
 tools/perf/builtin-script.c                        |  2 +
 tools/perf/config/Makefile                         | 35 ++++++++++-
 tools/perf/util/Build                              | 13 +++-
 tools/perf/util/dso.c                              |  7 +++
 tools/perf/util/dso.h                              |  1 +
 tools/perf/util/symbol-elf.c                       | 16 +++++
 tools/perf/util/symbol.c                           | 50 ++++++++++++++++
 tools/perf/util/symbol.h                           |  3 +
 tools/perf/util/thread.c                           | 70 ++++++++++++++++++++--
 tools/perf/util/thread.h                           | 14 ++++-
 tools/perf/util/unwind-libunwind.c                 | 50 +++++++++++++---
 tools/perf/util/unwind-libunwind_common.c          | 60 +++++++++++++++++++
 tools/perf/util/unwind.h                           | 30 ++++++++++
 tools/perf/util/util.c                             |  2 -
 27 files changed, 589 insertions(+), 39 deletions(-)
 create mode 100644 tools/build/feature/test-libunwind-aarch64.c
 create mode 100644 tools/build/feature/test-libunwind-arm.c
 create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c
 create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c
 delete mode 100644 tools/build/feature/test-libunwind-debug-frame.c
 create mode 100644 tools/build/feature/test-libunwind-x86.c
 create mode 100644 tools/build/feature/test-libunwind-x86_64.c
 create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
 create mode 100644 tools/perf/arch/x86/include/libunwind/libunwind-arch.h
 create mode 100644 tools/perf/util/unwind-libunwind_common.c

-- 
1.8.5.2

[toc] | [next] | [standalone]


#1395729 — [PATCH 7/8] perf callchain: Support x86 target platform

FromHe Kuang <hekuang@huawei.com>
Date2016-05-06 11:10 +0200
Subject[PATCH 7/8] perf callchain: Support x86 target platform
Message-ID<rvJVN-2eU-39@gated-at.bofh.it>
In reply to#1395728
Support x86(32bit) cross platform callchain unwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 .../arch/x86/include/libunwind/libunwind-arch.h    | 18 ++++++++++
 tools/perf/arch/x86/util/unwind-libunwind.c        | 42 ++++++++++++++++++++++
 tools/perf/util/Build                              |  6 ++++
 tools/perf/util/thread.c                           | 10 +++---
 tools/perf/util/unwind-libunwind.c                 |  2 +-
 tools/perf/util/unwind.h                           |  5 +++
 6 files changed, 77 insertions(+), 6 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/libunwind/libunwind-arch.h

diff --git a/tools/perf/arch/x86/include/libunwind/libunwind-arch.h b/tools/perf/arch/x86/include/libunwind/libunwind-arch.h
new file mode 100644
index 0000000..265f14d
--- /dev/null
+++ b/tools/perf/arch/x86/include/libunwind/libunwind-arch.h
@@ -0,0 +1,18 @@
+#ifndef _LIBUNWIND_ARCH_H
+#define _LIBUNWIND_ARCH_H
+
+#include <libunwind-x86.h>
+#include <../perf_regs.h>
+#include <../../../../../../arch/x86/include/uapi/asm/perf_regs.h>
+
+#define LIBUNWIND_X86_32
+int libunwind__x86_reg_id(int regnum);
+
+#include <../../../x86/util/unwind-libunwind.c>
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id
+
+#define UNWT_PREFIX	UNW_PASTE(UNW_PASTE(_U, x86), _)
+#define UNWT_OBJ(fn)	UNW_PASTE(UNWT_PREFIX, fn)
+
+#endif /* _LIBUNWIND_ARCH_H */
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
index db25e93..d422fbf 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -5,6 +5,7 @@
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
 
+#ifndef LIBUNWIND_X86_32
 #ifdef HAVE_ARCH_X86_64_SUPPORT
 int libunwind__arch_reg_id(int regnum)
 {
@@ -110,3 +111,44 @@ int libunwind__arch_reg_id(int regnum)
 	return id;
 }
 #endif /* HAVE_ARCH_X86_64_SUPPORT */
+#else
+int libunwind__x86_reg_id(int regnum)
+{
+	int id;
+
+	switch (regnum) {
+	case UNW_X86_EAX:
+		id = PERF_REG_X86_AX;
+		break;
+	case UNW_X86_EDX:
+		id = PERF_REG_X86_DX;
+		break;
+	case UNW_X86_ECX:
+		id = PERF_REG_X86_CX;
+		break;
+	case UNW_X86_EBX:
+		id = PERF_REG_X86_BX;
+		break;
+	case UNW_X86_ESI:
+		id = PERF_REG_X86_SI;
+		break;
+	case UNW_X86_EDI:
+		id = PERF_REG_X86_DI;
+		break;
+	case UNW_X86_EBP:
+		id = PERF_REG_X86_BP;
+		break;
+	case UNW_X86_ESP:
+		id = PERF_REG_X86_SP;
+		break;
+	case UNW_X86_EIP:
+		id = PERF_REG_X86_IP;
+		break;
+	default:
+		pr_err("unwind: invalid reg id %d\n", regnum);
+		return -EINVAL;
+	}
+
+	return id;
+}
+#endif /* LIBUNWIND_X86_32 */
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 2e21529..2dd3939 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -1,3 +1,5 @@
+include ../scripts/Makefile.include
+
 libperf-y += alias.o
 libperf-y += annotate.o
 libperf-y += build-id.o
@@ -99,6 +101,10 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
 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
+
+$(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
 
 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
 
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index cf60db1..2b93856 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -214,12 +214,12 @@ void thread__insert_map(struct thread *thread, struct map *map)
 		pr_debug("Thread map is X86, 64bit is %d\n", is_64_bit);
 		if (!is_64_bit) {
 #ifdef HAVE_LIBUNWIND_X86_SUPPORT
-			pr_err("target platform=%s is not implemented!\n",
-			       arch);
+			register_unwind_libunwind_ops(
+				&_Ux86_unwind_libunwind_ops, thread);
 #else
-			pr_err("target platform=%s is not supported!\n", arch);
-#endif
+			register_null_unwind_libunwind_ops(thread);
 			goto err;
+#endif
 		}
 	} else {
 		register_local_unwind_libunwind_ops(thread);
@@ -231,7 +231,7 @@ void thread__insert_map(struct thread *thread, struct map *map)
 	return;
 
 err: __maybe_unused
-	register_null_unwind_libunwind_ops(thread);
+	pr_err("target platform=%s not support!\n", arch);
 	return;
 #endif
 }
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 2558bf3..a195b56 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -527,7 +527,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 61b44a6..98d40bd 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -55,6 +55,11 @@ 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) {}
 #endif
+
+#ifdef HAVE_LIBUNWIND_X86_SUPPORT
+extern struct unwind_libunwind_ops _Ux86_unwind_libunwind_ops;
+#endif
+
 #else
 static inline int
 unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
-- 
1.8.5.2

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


#1395730 — [PATCH 2/8] perf script: Add options for custom vdso name

FromHe Kuang <hekuang@huawei.com>
Date2016-05-06 11:10 +0200
Subject[PATCH 2/8] perf script: Add options for custom vdso name
Message-ID<rvJVN-2eU-37@gated-at.bofh.it>
In reply to#1395728
When unwinding callchain on different machine, vdso info should be
provided so the unwind process won't be interrupted if address fell
into vdso region.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/builtin-script.c | 2 ++
 tools/perf/util/dso.c       | 7 +++++++
 tools/perf/util/dso.h       | 1 +
 tools/perf/util/symbol.c    | 1 +
 tools/perf/util/symbol.h    | 1 +
 5 files changed, 12 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8f6ab2a..c88b547 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2001,6 +2001,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "file", "vmlinux pathname"),
 	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
 		   "file", "kallsyms pathname"),
+	OPT_STRING(0, "vdso", &symbol_conf.vdso_name,
+		   "file", "vdso pathname"),
 	OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
 		    "When printing symbols do not display call chain"),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8e639543..344db10 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -21,6 +21,7 @@ char dso__symtab_origin(const struct dso *dso)
 		[DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO]	= 'o',
 		[DSO_BINARY_TYPE__BUILDID_DEBUGINFO]		= 'b',
 		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO]		= 'd',
+		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM]	= 'r',
 		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE]		= 'K',
 		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP]	= 'm',
 		[DSO_BINARY_TYPE__GUEST_KALLSYMS]		= 'g',
@@ -113,6 +114,11 @@ int dso__read_binary_type_filename(const struct dso *dso,
 			 build_id_hex, build_id_hex + 2);
 		break;
 
+	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM:
+	{
+		snprintf(filename, size, "%s", symbol_conf.vdso_name);
+		break;
+	}
 	case DSO_BINARY_TYPE__VMLINUX:
 	case DSO_BINARY_TYPE__GUEST_VMLINUX:
 	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
@@ -487,6 +493,7 @@ static void try_to_open_dso(struct dso *dso, struct machine *machine)
 	enum dso_binary_type binary_type_data[] = {
 		DSO_BINARY_TYPE__BUILD_ID_CACHE,
 		DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
+		DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM,
 		DSO_BINARY_TYPE__NOT_FOUND,
 	};
 	int i = 0;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 0953280..f55ce5b 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -23,6 +23,7 @@ enum dso_binary_type {
 	DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
 	DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
 	DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
+	DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM,
 	DSO_BINARY_TYPE__GUEST_KMODULE,
 	DSO_BINARY_TYPE__GUEST_KMODULE_COMP,
 	DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7588dc..93f348f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1359,6 +1359,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
 	case DSO_BINARY_TYPE__JAVA_JIT:
 	case DSO_BINARY_TYPE__DEBUGLINK:
 	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
+	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM:
 	case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
 	case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
 	case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index c8b7544..4e6910e 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -114,6 +114,7 @@ struct symbol_conf {
 			report_hierarchy;
 	const char	*vmlinux_name,
 			*kallsyms_name,
+			*vdso_name,
 			*source_prefix,
 			*field_sep;
 	const char	*default_guest_vmlinux_name,
-- 
1.8.5.2

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


#1395804 — Re: [PATCH 2/8] perf script: Add options for custom vdso name

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-06 13:50 +0200
SubjectRe: [PATCH 2/8] perf script: Add options for custom vdso name
Message-ID<rvMqD-4be-21@gated-at.bofh.it>
In reply to#1395730
Em Fri, May 06, 2016 at 08:59:08AM +0000, He Kuang escreveu:
> When unwinding callchain on different machine, vdso info should be
> provided so the unwind process won't be interrupted if address fell
> into vdso region.
> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/builtin-script.c | 2 ++
>  tools/perf/util/dso.c       | 7 +++++++
>  tools/perf/util/dso.h       | 1 +
>  tools/perf/util/symbol.c    | 1 +
>  tools/perf/util/symbol.h    | 1 +
>  5 files changed, 12 insertions(+)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 8f6ab2a..c88b547 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2001,6 +2001,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
>  		   "file", "vmlinux pathname"),
>  	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
>  		   "file", "kallsyms pathname"),
> +	OPT_STRING(0, "vdso", &symbol_conf.vdso_name,
> +		   "file", "vdso pathname"),
>  	OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
>  		    "When printing symbols do not display call chain"),
>  	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 8e639543..344db10 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -21,6 +21,7 @@ char dso__symtab_origin(const struct dso *dso)
>  		[DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO]	= 'o',
>  		[DSO_BINARY_TYPE__BUILDID_DEBUGINFO]		= 'b',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO]		= 'd',
> +		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM]	= 'r',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE]		= 'K',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP]	= 'm',
>  		[DSO_BINARY_TYPE__GUEST_KALLSYMS]		= 'g',
> @@ -113,6 +114,11 @@ int dso__read_binary_type_filename(const struct dso *dso,
>  			 build_id_hex, build_id_hex + 2);
>  		break;
>  
> +	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM:
> +	{
> +		snprintf(filename, size, "%s", symbol_conf.vdso_name);
> +		break;
> +	}

Remove the {}, not needed at all.

>  	case DSO_BINARY_TYPE__VMLINUX:
>  	case DSO_BINARY_TYPE__GUEST_VMLINUX:
>  	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
> @@ -487,6 +493,7 @@ static void try_to_open_dso(struct dso *dso, struct machine *machine)
>  	enum dso_binary_type binary_type_data[] = {
>  		DSO_BINARY_TYPE__BUILD_ID_CACHE,
>  		DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
> +		DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM,

Why do you call it a "DSO_CUSTOM" in some places while in others you
call it vdso_name?

>  		DSO_BINARY_TYPE__NOT_FOUND,
>  	};
>  	int i = 0;
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index 0953280..f55ce5b 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
> @@ -23,6 +23,7 @@ enum dso_binary_type {
>  	DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
>  	DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
>  	DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
> +	DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM,
>  	DSO_BINARY_TYPE__GUEST_KMODULE,
>  	DSO_BINARY_TYPE__GUEST_KMODULE_COMP,
>  	DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index e7588dc..93f348f 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1359,6 +1359,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
>  	case DSO_BINARY_TYPE__JAVA_JIT:
>  	case DSO_BINARY_TYPE__DEBUGLINK:
>  	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
> +	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM:
>  	case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
>  	case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
>  	case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
> diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
> index c8b7544..4e6910e 100644
> --- a/tools/perf/util/symbol.h
> +++ b/tools/perf/util/symbol.h
> @@ -114,6 +114,7 @@ struct symbol_conf {
>  			report_hierarchy;
>  	const char	*vmlinux_name,
>  			*kallsyms_name,
> +			*vdso_name,
>  			*source_prefix,
>  			*field_sep;
>  	const char	*default_guest_vmlinux_name,
> -- 
> 1.8.5.2

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


#1396341 — Re: [PATCH 2/8] perf script: Add options for custom vdso name

FromJiri Olsa <jolsa@redhat.com>
Date2016-05-07 20:20 +0200
SubjectRe: [PATCH 2/8] perf script: Add options for custom vdso name
Message-ID<rweZz-6wi-5@gated-at.bofh.it>
In reply to#1395730
On Fri, May 06, 2016 at 08:59:08AM +0000, He Kuang wrote:
> When unwinding callchain on different machine, vdso info should be
> provided so the unwind process won't be interrupted if address fell
> into vdso region.
> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/builtin-script.c | 2 ++
>  tools/perf/util/dso.c       | 7 +++++++
>  tools/perf/util/dso.h       | 1 +
>  tools/perf/util/symbol.c    | 1 +
>  tools/perf/util/symbol.h    | 1 +
>  5 files changed, 12 insertions(+)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 8f6ab2a..c88b547 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2001,6 +2001,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
>  		   "file", "vmlinux pathname"),
>  	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
>  		   "file", "kallsyms pathname"),
> +	OPT_STRING(0, "vdso", &symbol_conf.vdso_name,
> +		   "file", "vdso pathname"),
>  	OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
>  		    "When printing symbols do not display call chain"),
>  	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 8e639543..344db10 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -21,6 +21,7 @@ char dso__symtab_origin(const struct dso *dso)
>  		[DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO]	= 'o',
>  		[DSO_BINARY_TYPE__BUILDID_DEBUGINFO]		= 'b',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO]		= 'd',
> +		[DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM]	= 'r',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE]		= 'K',
>  		[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP]	= 'm',
>  		[DSO_BINARY_TYPE__GUEST_KALLSYMS]		= 'g',
> @@ -113,6 +114,11 @@ int dso__read_binary_type_filename(const struct dso *dso,
>  			 build_id_hex, build_id_hex + 2);
>  		break;
>  
> +	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM:
> +	{
> +		snprintf(filename, size, "%s", symbol_conf.vdso_name);
> +		break;
> +	}
>  	case DSO_BINARY_TYPE__VMLINUX:
>  	case DSO_BINARY_TYPE__GUEST_VMLINUX:
>  	case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
> @@ -487,6 +493,7 @@ static void try_to_open_dso(struct dso *dso, struct machine *machine)
>  	enum dso_binary_type binary_type_data[] = {
>  		DSO_BINARY_TYPE__BUILD_ID_CACHE,
>  		DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
> +		DSO_BINARY_TYPE__SYSTEM_PATH_DSO_CUSTOM,

could you please elaborate on how this one gets set?
don't we already store it under .debug?

also it seems fairly vdso specific, we shouldn't call it DSO_CUSTOM

thanks,
jirka

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


#1395809

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-06 14:00 +0200
Message-ID<rvMAi-4gY-5@gated-at.bofh.it>
In reply to#1395728
Em Fri, May 06, 2016 at 08:59:06AM +0000, He Kuang escreveu:
> Currently, perf script uses host unwind methods 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.

Thanks for working on this, being able to record on one machine and do
analysis in another, of a different hw architectures is indeed a goal
for the perf tools!

Jiri, if you could please take a look, that would be really great!

- Arnaldo
 
> This patch set adds build tests for the supported platforms for remote
> unwinding, and checks the map elf info for each thread, use remote
> unwind methods instead.
> 
> Only x86 and aarch64 is added in this patch set to show the work flow,
> other platforms can be added easily.
> 
> We can see the right result for unwind infos on different machines,
> for example: we record perf.data on i686 qemu with '-g' option and
> parse it on x86_64 machine.
> 
> before this patchset:
> 
>   hello  1071 [000]   417.567832: probe:sys_close: (c1169d60)
>                   c1169d61 sys_close ([kernel.kallsyms])
>                   c189c0d7 sysenter_past_esp ([kernel.kallsyms])
>                   b77c8ba9 [unknown] ([vdso32])
>   
> after:
> 
>   hello  1071 [000]   417.567832: probe:sys_close: (c1169d60)
>                   c1169d61 sys_close ([kernel.kallsyms])
>                   c189c0d7 sysenter_past_esp ([kernel.kallsyms])
>                   b77c8ba9 [unknown] ([vdso32])
>                   b76e51cc close (/lib/libc-2.22.so)
>                    804842e fib (/tmp/hello)
>                    804849d main (/tmp/hello)
>                   b762546e __libc_start_main (/lib/libc-2.22.so)
>                    8048341 _start (/tmp/hello)
> 
> Thanks, discussion welcomed.
> 
> He Kuang (8):
>   perf tools: Omit DWARF judgement when recording dwarf callchain
>   perf script: Add options for custom vdso name
>   perf build: Add build-test for libunwind cross-platforms support
>   perf build: Add build-test for debug-frame on arm/arm64
>   perf tools: Promote proper messages for cross-platform unwind
>   perf callchain: Add support for cross-platform unwind
>   perf callchain: Support x86 target platform
>   perf callchain: Support aarch64 cross-platform
> 
>  tools/build/Makefile.feature                       | 11 +++-
>  tools/build/feature/Makefile                       | 26 +++++++-
>  tools/build/feature/test-libunwind-aarch64.c       | 26 ++++++++
>  tools/build/feature/test-libunwind-arm.c           | 27 +++++++++
>  .../feature/test-libunwind-debug-frame-aarch64.c   | 16 +++++
>  .../build/feature/test-libunwind-debug-frame-arm.c | 16 +++++
>  tools/build/feature/test-libunwind-debug-frame.c   | 16 -----
>  tools/build/feature/test-libunwind-x86.c           | 27 +++++++++
>  tools/build/feature/test-libunwind-x86_64.c        | 27 +++++++++
>  .../arch/arm64/include/libunwind/libunwind-arch.h  | 18 ++++++
>  tools/perf/arch/arm64/util/unwind-libunwind.c      |  5 +-
>  .../arch/x86/include/libunwind/libunwind-arch.h    | 18 ++++++
>  tools/perf/arch/x86/util/unwind-libunwind.c        | 42 +++++++++++++
>  tools/perf/builtin-script.c                        |  2 +
>  tools/perf/config/Makefile                         | 35 ++++++++++-
>  tools/perf/util/Build                              | 13 +++-
>  tools/perf/util/dso.c                              |  7 +++
>  tools/perf/util/dso.h                              |  1 +
>  tools/perf/util/symbol-elf.c                       | 16 +++++
>  tools/perf/util/symbol.c                           | 50 ++++++++++++++++
>  tools/perf/util/symbol.h                           |  3 +
>  tools/perf/util/thread.c                           | 70 ++++++++++++++++++++--
>  tools/perf/util/thread.h                           | 14 ++++-
>  tools/perf/util/unwind-libunwind.c                 | 50 +++++++++++++---
>  tools/perf/util/unwind-libunwind_common.c          | 60 +++++++++++++++++++
>  tools/perf/util/unwind.h                           | 30 ++++++++++
>  tools/perf/util/util.c                             |  2 -
>  27 files changed, 589 insertions(+), 39 deletions(-)
>  create mode 100644 tools/build/feature/test-libunwind-aarch64.c
>  create mode 100644 tools/build/feature/test-libunwind-arm.c
>  create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c
>  create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c
>  delete mode 100644 tools/build/feature/test-libunwind-debug-frame.c
>  create mode 100644 tools/build/feature/test-libunwind-x86.c
>  create mode 100644 tools/build/feature/test-libunwind-x86_64.c
>  create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
>  create mode 100644 tools/perf/arch/x86/include/libunwind/libunwind-arch.h
>  create mode 100644 tools/perf/util/unwind-libunwind_common.c
> 
> -- 
> 1.8.5.2

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web