Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1408448 > unrolled thread
| Started by | He Kuang <hekuang@huawei.com> |
|---|---|
| First post | 2016-05-28 14:10 +0200 |
| Last post | 2016-05-30 11:00 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v6 10/11] perf callchain: Support x86 target platform He Kuang <hekuang@huawei.com> - 2016-05-28 14:10 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-05-30 11:00 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Hekuang <hekuang@huawei.com> - 2016-05-30 11:20 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-05-30 11:40 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Hekuang <hekuang@huawei.com> - 2016-05-30 13:10 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-05-30 16:30 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-05-30 11:00 +0200
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform Jiri Olsa <jolsa@redhat.com> - 2016-05-30 11:00 +0200
| From | He Kuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-28 14:10 +0200 |
| Subject | [PATCH v6 10/11] perf callchain: Support x86 target platform |
| Message-ID | <rDLe1-kx-5@gated-at.bofh.it> |
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
tools/perf/arch/Build | 1 +
tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++---
tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++
tools/perf/util/unwind-libunwind-local.c | 4 ++++
tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------
tools/perf/util/unwind.h | 10 ++++++++++
6 files changed, 53 insertions(+), 9 deletions(-)
create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c
diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build
index 109eb75..3fc4af1 100644
--- a/tools/perf/arch/Build
+++ b/tools/perf/arch/Build
@@ -1,2 +1,3 @@
libperf-y += common.o
libperf-y += $(ARCH)/
+libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
index db25e93..3b0be69 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -1,12 +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
#ifdef HAVE_ARCH_X86_64_SUPPORT
-int libunwind__arch_reg_id(int regnum)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
{
int id;
@@ -70,7 +71,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/arch/x86/util/unwind-libunwind_x86_32.c b/tools/perf/arch/x86/util/unwind-libunwind_x86_32.c
new file mode 100644
index 0000000..9d5359e
--- /dev/null
+++ b/tools/perf/arch/x86/util/unwind-libunwind_x86_32.c
@@ -0,0 +1,21 @@
+#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 "unwind-libunwind.c"
+
+#undef NO_LIBUNWIND_DEBUG_FRAME
+#define NO_LIBUNWIND_DEBUG_FRAME
+#include "util/unwind-libunwind-local.c"
+
+int register_x86_32_unwind_libunwind_ops(struct thread *thread)
+{
+ thread->unwind_libunwind_ops = &_unwind_libunwind_ops;
+ return 0;
+}
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index b391e3e..849fec1 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -5,7 +5,9 @@
#include <unistd.h>
#include <sys/mman.h>
#include <linux/list.h>
+#ifndef REMOTE_UNWIND_LIBUNWIND
#include <libunwind.h>
+#endif
#include "callchain.h"
#include "thread.h"
#include "session.h"
@@ -671,7 +673,9 @@ _unwind_libunwind_ops = {
.get_entries = _unwind__get_entries,
};
+#ifndef REMOTE_UNWIND_LIBUNWIND
void register_local_unwind_libunwind_ops(struct thread *thread)
{
thread->unwind_libunwind_ops = &_unwind_libunwind_ops;
}
+#endif
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 037ee72..c1d9d36 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -8,6 +8,9 @@ int unwind__prepare_access(struct thread *thread, struct map *map)
{
const char *arch;
enum dso_type dso_type;
+ int use_local_unwind = 1;
+ int ret;
+ int (*register_func)(struct thread *thread) = NULL;
if (!thread->mg->machine->env)
return -1;
@@ -22,16 +25,20 @@ 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)
-#ifdef HAVE_LIBUNWIND_X86_SUPPORT
- pr_err("unwind: target platform=%s is not implemented\n", arch);
-#else
+ register_func = register_x86_32_unwind_libunwind_ops;
+
+ if (register_func) {
+ ret = register_func(thread);
+ if (!ret)
+ use_local_unwind = 0;
+ else
pr_err("unwind: target platform=%s is not supported\n", arch);
-#endif
}
- register_local_unwind_libunwind_ops(thread);
+ if (use_local_unwind)
+ register_local_unwind_libunwind_ops(thread);
return thread->unwind_libunwind_ops->prepare_access(thread);
}
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 9e4f545..43f9f66 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -46,6 +46,16 @@ static inline void
register_local_unwind_libunwind_ops(struct thread *thread __maybe_unused) {}
#endif
+#ifdef HAVE_LIBUNWIND_X86_SUPPORT
+int register_x86_32_unwind_libunwind_ops(struct thread *thread);
+#else
+static inline int
+register_x86_32_unwind_libunwind_ops(struct thread *thread __maybe_unused)
+{
+ return -1;
+}
+#endif
+
#else
static inline int
unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
--
1.8.5.2
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-30 11:00 +0200 |
| Message-ID | <rErdg-1TA-45@gated-at.bofh.it> |
| In reply to | #1408448 |
On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote: > Support x86(32-bit) cross platform callchain unwind. > > Signed-off-by: He Kuang <hekuang@huawei.com> > --- > tools/perf/arch/Build | 1 + > tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- > tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ > tools/perf/util/unwind-libunwind-local.c | 4 ++++ > tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ > tools/perf/util/unwind.h | 10 ++++++++++ > 6 files changed, 53 insertions(+), 9 deletions(-) > create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c > > diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build > index 109eb75..3fc4af1 100644 > --- a/tools/perf/arch/Build > +++ b/tools/perf/arch/Build > @@ -1,2 +1,3 @@ > libperf-y += common.o > libperf-y += $(ARCH)/ > +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o we have Build file directly in arch/x86/util/ if you do it like this to include generic file easily we better fix the include then jirka
[toc] | [prev] | [next] | [standalone]
| From | Hekuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-30 11:20 +0200 |
| Message-ID | <rErwC-2fk-19@gated-at.bofh.it> |
| In reply to | #1408888 |
hi 在 2016/5/30 16:53, Jiri Olsa 写道: > On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote: >> Support x86(32-bit) cross platform callchain unwind. >> >> Signed-off-by: He Kuang <hekuang@huawei.com> >> --- >> tools/perf/arch/Build | 1 + >> tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- >> tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ >> tools/perf/util/unwind-libunwind-local.c | 4 ++++ >> tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ >> tools/perf/util/unwind.h | 10 ++++++++++ >> 6 files changed, 53 insertions(+), 9 deletions(-) >> create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c >> >> diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build >> index 109eb75..3fc4af1 100644 >> --- a/tools/perf/arch/Build >> +++ b/tools/perf/arch/Build >> @@ -1,2 +1,3 @@ >> libperf-y += common.o >> libperf-y += $(ARCH)/ >> +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o > we have Build file directly in arch/x86/util/ > > if you do it like this to include generic file easily > we better fix the include then This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, for example on x86_64, only tools/perf/arch/x86 will be built. But for remote libunwind, we also need 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is not added to libperf-y. Is there a gracefull to deal with this? > jirka >
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-30 11:40 +0200 |
| Message-ID | <rErQ3-2lt-15@gated-at.bofh.it> |
| In reply to | #1408914 |
On Mon, May 30, 2016 at 05:11:35PM +0800, Hekuang wrote: > hi > > 在 2016/5/30 16:53, Jiri Olsa 写道: > > On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote: > > > Support x86(32-bit) cross platform callchain unwind. > > > > > > Signed-off-by: He Kuang <hekuang@huawei.com> > > > --- > > > tools/perf/arch/Build | 1 + > > > tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- > > > tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ > > > tools/perf/util/unwind-libunwind-local.c | 4 ++++ > > > tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ > > > tools/perf/util/unwind.h | 10 ++++++++++ > > > 6 files changed, 53 insertions(+), 9 deletions(-) > > > create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c > > > > > > diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build > > > index 109eb75..3fc4af1 100644 > > > --- a/tools/perf/arch/Build > > > +++ b/tools/perf/arch/Build > > > @@ -1,2 +1,3 @@ > > > libperf-y += common.o > > > libperf-y += $(ARCH)/ > > > +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o > > we have Build file directly in arch/x86/util/ > > > > if you do it like this to include generic file easily > > we better fix the include then > > This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, > for example on x86_64, only tools/perf/arch/x86 will be built. But for > remote libunwind, we also need > 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is > not added to libperf-y. Is there a gracefull to deal with this? you just need to include the file, right? I think it's ok to include arch/arm/....c from arch/x86/util/unwind-libunwind-arm64.c jirka
[toc] | [prev] | [next] | [standalone]
| From | Hekuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-30 13:10 +0200 |
| Message-ID | <rEtf3-3mA-3@gated-at.bofh.it> |
| In reply to | #1408940 |
在 2016/5/30 17:30, Jiri Olsa 写道: > On Mon, May 30, 2016 at 05:11:35PM +0800, Hekuang wrote: >> hi >> >> 在 2016/5/30 16:53, Jiri Olsa 写道: >>> On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote: >>>> Support x86(32-bit) cross platform callchain unwind. >>>> >>>> Signed-off-by: He Kuang <hekuang@huawei.com> >>>> --- >>>> tools/perf/arch/Build | 1 + >>>> tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- >>>> tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ >>>> tools/perf/util/unwind-libunwind-local.c | 4 ++++ >>>> tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ >>>> tools/perf/util/unwind.h | 10 ++++++++++ >>>> 6 files changed, 53 insertions(+), 9 deletions(-) >>>> create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c >>>> >>>> diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build >>>> index 109eb75..3fc4af1 100644 >>>> --- a/tools/perf/arch/Build >>>> +++ b/tools/perf/arch/Build >>>> @@ -1,2 +1,3 @@ >>>> libperf-y += common.o >>>> libperf-y += $(ARCH)/ >>>> +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o >>> we have Build file directly in arch/x86/util/ >>> >>> if you do it like this to include generic file easily >>> we better fix the include then >> This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, >> for example on x86_64, only tools/perf/arch/x86 will be built. But for >> remote libunwind, we also need >> 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is >> not added to libperf-y. Is there a gracefull to deal with this? > you just need to include the file, right? > > I think it's ok to include arch/arm/....c > from arch/x86/util/unwind-libunwind-arm64.c > > jirka By following your advise, if ARCH=x86, the file tree will be like this: arch/x86 - arch/x86/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-arm.c And for ARCH=arm (host machine is arm, it should be considered) arch/arm - arch/arm/util/unwind-libunwind-arm64.c - arch/arm/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-x86_64.c - arch/arm/util/unwind-libunwind-arm.c For arm64: arch/arm64 - arch/arm64/util/unwind-libunwind-arm64.c - arch/arm64/util/unwind-libunwind-x86_32.c - arch/arm64/util/unwind-libunwind-x86_64.c - arch/arm64/util/unwind-libunwind-arm.c But in my patch, the file tree is like this: arch - arch/arm64/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-arm.c I admit that +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o is not so good, but do you think the above file tree is too redunctant? Thank you. >
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-30 16:30 +0200 |
| Message-ID | <rEwmC-5kR-19@gated-at.bofh.it> |
| In reply to | #1408987 |
On Mon, May 30, 2016 at 06:58:40PM +0800, Hekuang wrote: SNIP > > I think it's ok to include arch/arm/....c > > from arch/x86/util/unwind-libunwind-arm64.c > > > > jirka > > By following your advise, if ARCH=x86, the file tree will > be like this: > > arch/x86 > - arch/x86/util/unwind-libunwind-arm64.c > - arch/x86/util/unwind-libunwind-x86_32.c > - arch/x86/util/unwind-libunwind-x86_64.c > - arch/x86/util/unwind-libunwind-arm.c > > And for ARCH=arm (host machine is arm, it should be considered) > arch/arm > - arch/arm/util/unwind-libunwind-arm64.c > - arch/arm/util/unwind-libunwind-x86_32.c > - arch/arm/util/unwind-libunwind-x86_64.c > - arch/arm/util/unwind-libunwind-arm.c > > For arm64: > arch/arm64 > - arch/arm64/util/unwind-libunwind-arm64.c > - arch/arm64/util/unwind-libunwind-x86_32.c > - arch/arm64/util/unwind-libunwind-x86_64.c > - arch/arm64/util/unwind-libunwind-arm.c > > But in my patch, the file tree is like this: > > arch > - arch/arm64/util/unwind-libunwind-arm64.c > - arch/x86/util/unwind-libunwind-x86_64.c > - arch/x86/util/unwind-libunwind-x86_32.c > - arch/arm/util/unwind-libunwind-arm.c > > I admit that > > +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o > > is not so good, but do you think the above file tree is > too redunctant? i see.. we could leave it like that, I just wish it'd be more clear.. one last thought: how about moving libunwind arch files into special folder: util/libunwind/arm64.c util/libunwind/x86_32.c util/libunwind/x86_64.c util/libunwind/arm.c thanks, jirka
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-30 11:00 +0200 |
| Message-ID | <rErdg-1TA-43@gated-at.bofh.it> |
| In reply to | #1408448 |
On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote:
SNIP
> --- /dev/null
> +++ b/tools/perf/arch/x86/util/unwind-libunwind_x86_32.c
> @@ -0,0 +1,21 @@
> +#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 "unwind-libunwind.c"
> +
> +#undef NO_LIBUNWIND_DEBUG_FRAME
> +#define NO_LIBUNWIND_DEBUG_FRAME
> +#include "util/unwind-libunwind-local.c"
> +
> +int register_x86_32_unwind_libunwind_ops(struct thread *thread)
> +{
> + thread->unwind_libunwind_ops = &_unwind_libunwind_ops;
> + return 0;
> +}
hum, how about export the arch ops:
struct unwind_libunwind_ops *x86_32_unwind_libunwind_ops = &_unwind_libunwind_ops;
and have single unwind__register_ops(ops) function
jirka
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-30 11:00 +0200 |
| Message-ID | <rErdh-1TA-55@gated-at.bofh.it> |
| In reply to | #1408448 |
On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote:
SNIP
> diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
> index b391e3e..849fec1 100644
> --- a/tools/perf/util/unwind-libunwind-local.c
> +++ b/tools/perf/util/unwind-libunwind-local.c
> @@ -5,7 +5,9 @@
> #include <unistd.h>
> #include <sys/mman.h>
> #include <linux/list.h>
> +#ifndef REMOTE_UNWIND_LIBUNWIND
> #include <libunwind.h>
> +#endif
> #include "callchain.h"
> #include "thread.h"
> #include "session.h"
> @@ -671,7 +673,9 @@ _unwind_libunwind_ops = {
> .get_entries = _unwind__get_entries,
> };
>
> +#ifndef REMOTE_UNWIND_LIBUNWIND
> void register_local_unwind_libunwind_ops(struct thread *thread)
> {
> thread->unwind_libunwind_ops = &_unwind_libunwind_ops;
> }
> +#endif
above hunks should go to separate patch
however I still think it'd be more clear if we separate the code like:
code template - util/unwind-libunwind.c
arch template - arch/x86/util/unwind-libunwind.c
wrapper for local - util/unwind-libunwind-local.c
wrapper for x86_32 - arch/x86/util/unwind-libunwind-x86_32.c
wrapper for arm64 - arch/x86/util/unwind-libunwind-arm64.c
jirka
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web