* [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains.
@ 2015-04-07 23:58 Ralf Baechle
2015-04-07 23:58 ` [PATCH 1/2] perf tools: Add support for " David Daney
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ralf Baechle @ 2015-04-07 23:58 UTC (permalink / raw)
To: David Daney, linux-mips, Jiri Olsa, linux-kernel, Peter Zijlstra,
Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo
This is a refresh of a David Daney's patch set to implement MIPS support
for perf. It has been posted before but not received any comments or
(N)Acks.
This series depends on
http://patchwork.linux-mips.org/patch/5246/
which currently is pending for 4.1 in the MIPS tree so I'd like to upstream
these two patches through the MIPS tree as well.
David's original patches are archived at:
http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1368817238-11548-1-git-send-email-ddaney.cavm%40gmail.com
http://patchwork.linux-mips.org/patch/5249/
http://patchwork.linux-mips.org/patch/5250/
Cheers,
Ralf
David Daney (2):
perf tools: Add support for MIPS userspace DWARF callchains.
perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile
tools/perf/Makefile | 3 ++
tools/perf/arch/mips/Makefile | 7 +++
tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++
tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++
tools/perf/arch/mips/util/unwind.c | 20 ++++++++
tools/perf/config/Makefile | 10 ++++
6 files changed, 161 insertions(+)
create mode 100644 tools/perf/arch/mips/Makefile
create mode 100644 tools/perf/arch/mips/include/perf_regs.h
create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c
create mode 100644 tools/perf/arch/mips/util/unwind.c
--
1.9.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] perf tools: Add support for MIPS userspace DWARF callchains.
2015-04-07 23:58 [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Ralf Baechle
@ 2015-04-07 23:58 ` David Daney
2015-04-08 9:46 ` Jiri Olsa
2015-04-07 23:58 ` [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile David Daney
2015-09-27 16:05 ` [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Rabin Vincent
2 siblings, 1 reply; 9+ messages in thread
From: David Daney @ 2015-04-07 23:58 UTC (permalink / raw)
To: David Daney, linux-mips, Jiri Olsa, linux-kernel, Peter Zijlstra,
Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo
From: David Daney <david.daney@cavium.com>
Hack up the Makefile and add support code for mips unwinding
and dwarf-regs.
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Patchwork: https://patchwork.linux-mips.org/patch/5249/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
tools/perf/Makefile | 3 ++
tools/perf/arch/mips/Makefile | 7 +++
tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++
tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++
tools/perf/arch/mips/util/unwind.c | 20 ++++++++
5 files changed, 151 insertions(+)
create mode 100644 tools/perf/arch/mips/Makefile
create mode 100644 tools/perf/arch/mips/include/perf_regs.h
create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c
create mode 100644 tools/perf/arch/mips/util/unwind.c
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index cb2e586..c2a089a 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -28,6 +28,9 @@ ifeq ($(JOBS),)
ifeq ($(JOBS),)
JOBS := 1
endif
+ ifeq ($(ARCH),mips)
+ LIB_H += arch/mips/include/perf_regs.h
+ endif
endif
#
diff --git a/tools/perf/arch/mips/Makefile b/tools/perf/arch/mips/Makefile
new file mode 100644
index 0000000..fe9b61e
--- /dev/null
+++ b/tools/perf/arch/mips/Makefile
@@ -0,0 +1,7 @@
+ifndef NO_DWARF
+PERF_HAVE_DWARF_REGS := 1
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
+endif
+ifndef NO_LIBUNWIND
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o
+endif
diff --git a/tools/perf/arch/mips/include/perf_regs.h b/tools/perf/arch/mips/include/perf_regs.h
new file mode 100644
index 0000000..a91b904
--- /dev/null
+++ b/tools/perf/arch/mips/include/perf_regs.h
@@ -0,0 +1,84 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include <stdlib.h>
+#include "../../util/types.h"
+#include <asm/perf_regs.h>
+
+#define PERF_REG_IP PERF_REG_MIPS_PC
+#define PERF_REG_SP PERF_REG_MIPS_R29
+
+#define PERF_REGS_MASK ((1ULL << PERF_REG_MIPS_MAX) - 1)
+
+static inline const char *perf_reg_name(int id)
+{
+ switch (id) {
+ case PERF_REG_MIPS_PC:
+ return "PC";
+ case PERF_REG_MIPS_R1:
+ return "$1";
+ case PERF_REG_MIPS_R2:
+ return "$2";
+ case PERF_REG_MIPS_R3:
+ return "$3";
+ case PERF_REG_MIPS_R4:
+ return "$4";
+ case PERF_REG_MIPS_R5:
+ return "$5";
+ case PERF_REG_MIPS_R6:
+ return "$6";
+ case PERF_REG_MIPS_R7:
+ return "$7";
+ case PERF_REG_MIPS_R8:
+ return "$8";
+ case PERF_REG_MIPS_R9:
+ return "$9";
+ case PERF_REG_MIPS_R10:
+ return "$10";
+ case PERF_REG_MIPS_R11:
+ return "$11";
+ case PERF_REG_MIPS_R12:
+ return "$12";
+ case PERF_REG_MIPS_R13:
+ return "$13";
+ case PERF_REG_MIPS_R14:
+ return "$14";
+ case PERF_REG_MIPS_R15:
+ return "$15";
+ case PERF_REG_MIPS_R16:
+ return "$16";
+ case PERF_REG_MIPS_R17:
+ return "$17";
+ case PERF_REG_MIPS_R18:
+ return "$18";
+ case PERF_REG_MIPS_R19:
+ return "$19";
+ case PERF_REG_MIPS_R20:
+ return "$20";
+ case PERF_REG_MIPS_R21:
+ return "$21";
+ case PERF_REG_MIPS_R22:
+ return "$22";
+ case PERF_REG_MIPS_R23:
+ return "$23";
+ case PERF_REG_MIPS_R24:
+ return "$24";
+ case PERF_REG_MIPS_R25:
+ return "$25";
+
+ case PERF_REG_MIPS_R28:
+ return "$28";
+ case PERF_REG_MIPS_R29:
+ return "$29";
+ case PERF_REG_MIPS_R30:
+ return "$30";
+ case PERF_REG_MIPS_R31:
+ return "$31";
+ default:
+ break;
+ }
+ return NULL;
+}
+
+
+#endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/mips/util/dwarf-regs.c b/tools/perf/arch/mips/util/dwarf-regs.c
new file mode 100644
index 0000000..165e017
--- /dev/null
+++ b/tools/perf/arch/mips/util/dwarf-regs.c
@@ -0,0 +1,37 @@
+/*
+ * dwarf-regs.c : Mapping of DWARF debug register numbers into register names.
+ *
+ * Copyright (C) 2013 Cavium, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <libio.h>
+#include <dwarf-regs.h>
+
+static const char *mips_gpr_names[32] = {
+ "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ "$10", "$11", "$12", "$13", "$14", "$15", "$16", "$17", "$18", "$19",
+ "$20", "$21", "$22", "$23", "$24", "$25", "$26", "$27", "$28", "$29",
+ "$30", "$31"
+};
+
+const char *get_arch_regstr(unsigned int n)
+{
+ if (n < 32)
+ return mips_gpr_names[n];
+ if (n == 64)
+ return "hi";
+ if (n == 65)
+ return "lo";
+ return NULL;
+}
diff --git a/tools/perf/arch/mips/util/unwind.c b/tools/perf/arch/mips/util/unwind.c
new file mode 100644
index 0000000..612949b
--- /dev/null
+++ b/tools/perf/arch/mips/util/unwind.c
@@ -0,0 +1,20 @@
+
+#include <errno.h>
+#include <libunwind.h>
+#include "perf_regs.h"
+#include "../../util/unwind.h"
+
+int unwind__arch_reg_id(int regnum)
+{
+ switch (regnum) {
+ case UNW_MIPS_R1 ... UNW_MIPS_R25:
+ return regnum - UNW_MIPS_R1 + PERF_REG_MIPS_R1;
+ case UNW_MIPS_R28 ... UNW_MIPS_R31:
+ return regnum - UNW_MIPS_R28 + PERF_REG_MIPS_R28;
+ case UNW_MIPS_PC:
+ return PERF_REG_MIPS_PC;
+ default:
+ pr_err("unwind: invalid reg id %d\n", regnum);
+ return -EINVAL;
+ }
+}
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile
2015-04-07 23:58 [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Ralf Baechle
2015-04-07 23:58 ` [PATCH 1/2] perf tools: Add support for " David Daney
@ 2015-04-07 23:58 ` David Daney
2015-04-08 9:58 ` Jiri Olsa
2015-09-27 16:05 ` [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Rabin Vincent
2 siblings, 1 reply; 9+ messages in thread
From: David Daney @ 2015-04-07 23:58 UTC (permalink / raw)
To: David Daney, linux-mips, Jiri Olsa, linux-kernel, Peter Zijlstra,
Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo
From: David Daney <david.daney@cavium.com>
Define a new symbol (ARCH_SUPPORTS_LIBUNWIND) in config/Makefile.
Use this from x86 and MIPS to gate testing of libunwind.
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Patchwork: https://patchwork.linux-mips.org/patch/5250/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
tools/perf/config/Makefile | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index cc22408..0d0595e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -27,19 +27,29 @@ ifeq ($(ARCH),x86)
else
LIBUNWIND_LIBS = -lunwind -lunwind-x86
endif
+ ARCH_SUPPORTS_LIBUNWIND := 1
NO_PERF_REGS := 0
endif
ifeq ($(ARCH),arm)
NO_PERF_REGS := 0
+ ARCH_SUPPORTS_LIBUNWIND := 1
LIBUNWIND_LIBS = -lunwind -lunwind-arm
endif
ifeq ($(ARCH),arm64)
NO_PERF_REGS := 0
+ ARCH_SUPPORTS_LIBUNWIND := 1
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
endif
+# Additional ARCH settings for MIPS
+ifeq ($(ARCH),mips)
+ ARCH_SUPPORTS_LIBUNWIND := 1
+ NO_PERF_REGS := 0
+ LIBUNWIND_LIBS = -lunwind -lunwind-mips
+endif
+
# So far there's only x86 and arm libdw unwind support merged in perf.
# Disable it on all other architectures in case libdw unwind
# support is detected in system. Add supported architectures
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] perf tools: Add support for MIPS userspace DWARF callchains.
2015-04-07 23:58 ` [PATCH 1/2] perf tools: Add support for " David Daney
@ 2015-04-08 9:46 ` Jiri Olsa
0 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2015-04-08 9:46 UTC (permalink / raw)
To: David Daney
Cc: linux-mips, linux-kernel, Peter Zijlstra, Paul Mackerras,
Ingo Molnar, Arnaldo Carvalho de Melo
On Wed, Apr 08, 2015 at 01:58:46AM +0200, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
>
> Hack up the Makefile and add support code for mips unwinding
> and dwarf-regs.
hi,
we changed our build system just recently and this patch
is made over the old one.. comments below
>
> Signed-off-by: David Daney <david.daney@cavium.com>
> Cc: linux-mips@linux-mips.org
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Patchwork: https://patchwork.linux-mips.org/patch/5249/
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> ---
> tools/perf/Makefile | 3 ++
> tools/perf/arch/mips/Makefile | 7 +++
> tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++
> tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++
> tools/perf/arch/mips/util/unwind.c | 20 ++++++++
> 5 files changed, 151 insertions(+)
> create mode 100644 tools/perf/arch/mips/Makefile
> create mode 100644 tools/perf/arch/mips/include/perf_regs.h
> create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c
> create mode 100644 tools/perf/arch/mips/util/unwind.c
>
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index cb2e586..c2a089a 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -28,6 +28,9 @@ ifeq ($(JOBS),)
> ifeq ($(JOBS),)
> JOBS := 1
> endif
> + ifeq ($(ARCH),mips)
> + LIB_H += arch/mips/include/perf_regs.h
> + endif
> endif
LIB_H is no longer supported, the build now detects
all headers automatically
>
> #
> diff --git a/tools/perf/arch/mips/Makefile b/tools/perf/arch/mips/Makefile
> new file mode 100644
> index 0000000..fe9b61e
> --- /dev/null
> +++ b/tools/perf/arch/mips/Makefile
> @@ -0,0 +1,7 @@
> +ifndef NO_DWARF
> +PERF_HAVE_DWARF_REGS := 1
> +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
> +endif
> +ifndef NO_LIBUNWIND
> +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o
> +endif
the tools/perf/arch/mips/Makefile now provides make arch's
dependent variables setup, so your's should be:
---
ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
endif
---
from building side mips seems similar to arch/powerpc/ setup:
---
[jolsa@krava perf]$ cat arch/powerpc/Build
libperf-y += util/
[jolsa@krava perf]$ cat arch/powerpc/util/Build
libperf-y += header.o
libperf-$(CONFIG_DWARF) += dwarf-regs.o
libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
---
so arch/mips/Build should be identical to arch/powerpc/Build
and arch/mips/util/Build should look like:
---
libperf-$(CONFIG_DWARF) += dwarf-regs.o
libperf-$(CONFIG_LIBUNWIND) += unwind.o
---
could you please also rename 'unwind.c' to 'unwind-libunwind.c',
cause we have also libdw unwind and we try to keep them separated
thanks,
jirka
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile
2015-04-07 23:58 ` [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile David Daney
@ 2015-04-08 9:58 ` Jiri Olsa
0 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2015-04-08 9:58 UTC (permalink / raw)
To: David Daney
Cc: linux-mips, linux-kernel, Peter Zijlstra, Paul Mackerras,
Ingo Molnar, Arnaldo Carvalho de Melo
On Wed, Apr 08, 2015 at 01:58:47AM +0200, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
>
> Define a new symbol (ARCH_SUPPORTS_LIBUNWIND) in config/Makefile.
> Use this from x86 and MIPS to gate testing of libunwind.
hum.. hows ARCH_SUPPORTS_LIBUNWIND being used?
I dont see it.. are there more patches? ;-)
jirka
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains.
2015-04-07 23:58 [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Ralf Baechle
2015-04-07 23:58 ` [PATCH 1/2] perf tools: Add support for " David Daney
2015-04-07 23:58 ` [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile David Daney
@ 2015-09-27 16:05 ` Rabin Vincent
2015-09-27 20:39 ` David Daney
2 siblings, 1 reply; 9+ messages in thread
From: Rabin Vincent @ 2015-09-27 16:05 UTC (permalink / raw)
To: Ralf Baechle
Cc: David Daney, linux-mips, Jiri Olsa, linux-kernel, Peter Zijlstra,
Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo
On Wed, Apr 08, 2015 at 01:58:45AM +0200, Ralf Baechle wrote:
> This is a refresh of a David Daney's patch set to implement MIPS support
> for perf. It has been posted before but not received any comments or
> (N)Acks.
>
> This series depends on
>
> http://patchwork.linux-mips.org/patch/5246/
>
> which currently is pending for 4.1 in the MIPS tree so I'd like to upstream
> these two patches through the MIPS tree as well.
Looks like this "MIPS: Add user stack and registers to perf" patch
didn't get merged in 4.1? Could it please be queued now?
>
> David's original patches are archived at:
>
> http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1368817238-11548-1-git-send-email-ddaney.cavm%40gmail.com
> http://patchwork.linux-mips.org/patch/5249/
> http://patchwork.linux-mips.org/patch/5250/
I've taken these tools/perf patches and made them work with the latest
mainline (this addresses the comments Jiri had) and can send them out if
you'd like, but they need the arch/mips patch to build.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains.
@ 2015-09-27 20:39 ` David Daney
0 siblings, 0 replies; 9+ messages in thread
From: David Daney @ 2015-09-27 20:39 UTC (permalink / raw)
To: Rabin Vincent
Cc: Ralf Baechle, David Daney, linux-mips, Jiri Olsa, linux-kernel,
Peter Zijlstra, Paul Mackerras, Ingo Molnar,
Arnaldo Carvalho de Melo
On 09/27/2015 09:05 AM, Rabin Vincent wrote:
> On Wed, Apr 08, 2015 at 01:58:45AM +0200, Ralf Baechle wrote:
>> This is a refresh of a David Daney's patch set to implement MIPS support
>> for perf. It has been posted before but not received any comments or
>> (N)Acks.
>>
>> This series depends on
>>
>> http://patchwork.linux-mips.org/patch/5246/
>>
>> which currently is pending for 4.1 in the MIPS tree so I'd like to upstream
>> these two patches through the MIPS tree as well.
>
> Looks like this "MIPS: Add user stack and registers to perf" patch
> didn't get merged in 4.1? Could it please be queued now?
>
>>
>> David's original patches are archived at:
>>
>> http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1368817238-11548-1-git-send-email-ddaney.cavm%40gmail.com
>> http://patchwork.linux-mips.org/patch/5249/
>> http://patchwork.linux-mips.org/patch/5250/
>
> I've taken these tools/perf patches and made them work with the latest
> mainline (this addresses the comments Jiri had) and can send them out if
> you'd like, but they need the arch/mips patch to build.
>
FWIW: I don't have time to work on these at the moment, but I still
support merging them. If anybody wants to take the time to get them
into a mergable state, I would fully support, and bless, that effort.
Thanks,
David Daney
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains.
@ 2015-09-27 20:39 ` David Daney
0 siblings, 0 replies; 9+ messages in thread
From: David Daney @ 2015-09-27 20:39 UTC (permalink / raw)
To: Rabin Vincent
Cc: Ralf Baechle, David Daney, linux-mips, Jiri Olsa, linux-kernel,
Peter Zijlstra, Paul Mackerras, Ingo Molnar,
Arnaldo Carvalho de Melo
On 09/27/2015 09:05 AM, Rabin Vincent wrote:
> On Wed, Apr 08, 2015 at 01:58:45AM +0200, Ralf Baechle wrote:
>> This is a refresh of a David Daney's patch set to implement MIPS support
>> for perf. It has been posted before but not received any comments or
>> (N)Acks.
>>
>> This series depends on
>>
>> http://patchwork.linux-mips.org/patch/5246/
>>
>> which currently is pending for 4.1 in the MIPS tree so I'd like to upstream
>> these two patches through the MIPS tree as well.
>
> Looks like this "MIPS: Add user stack and registers to perf" patch
> didn't get merged in 4.1? Could it please be queued now?
>
>>
>> David's original patches are archived at:
>>
>> http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1368817238-11548-1-git-send-email-ddaney.cavm%40gmail.com
>> http://patchwork.linux-mips.org/patch/5249/
>> http://patchwork.linux-mips.org/patch/5250/
>
> I've taken these tools/perf patches and made them work with the latest
> mainline (this addresses the comments Jiri had) and can send them out if
> you'd like, but they need the arch/mips patch to build.
>
FWIW: I don't have time to work on these at the moment, but I still
support merging them. If anybody wants to take the time to get them
into a mergable state, I would fully support, and bless, that effort.
Thanks,
David Daney
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] perf tools: Add support for MIPS userspace DWARF callchains.
2013-05-17 19:00 David Daney
@ 2013-05-17 19:00 ` David Daney
0 siblings, 0 replies; 9+ messages in thread
From: David Daney @ 2013-05-17 19:00 UTC (permalink / raw)
To: linux-mips, ralf, Jiri Olsa
Cc: linux-kernel, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
Arnaldo Carvalho de Melo, David Daney
From: David Daney <david.daney@cavium.com>
Hack up the Makefile and add support code for mips unwinding
and dwarf-regs.
Signed-off-by: David Daney <david.daney@cavium.com>
---
tools/perf/Makefile | 3 ++
tools/perf/arch/mips/Makefile | 7 +++
tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++
tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++
tools/perf/arch/mips/util/unwind.c | 20 ++++++++
5 files changed, 151 insertions(+)
create mode 100644 tools/perf/arch/mips/Makefile
create mode 100644 tools/perf/arch/mips/include/perf_regs.h
create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c
create mode 100644 tools/perf/arch/mips/util/unwind.c
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 55b42b2..b1aaca2 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -505,6 +505,9 @@ ifeq ($(NO_PERF_REGS),0)
ifeq ($(ARCH),x86)
LIB_H += arch/x86/include/perf_regs.h
endif
+ ifeq ($(ARCH),mips)
+ LIB_H += arch/mips/include/perf_regs.h
+ endif
endif
ifndef NO_LIBNUMA
diff --git a/tools/perf/arch/mips/Makefile b/tools/perf/arch/mips/Makefile
new file mode 100644
index 0000000..fe9b61e
--- /dev/null
+++ b/tools/perf/arch/mips/Makefile
@@ -0,0 +1,7 @@
+ifndef NO_DWARF
+PERF_HAVE_DWARF_REGS := 1
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
+endif
+ifndef NO_LIBUNWIND
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o
+endif
diff --git a/tools/perf/arch/mips/include/perf_regs.h b/tools/perf/arch/mips/include/perf_regs.h
new file mode 100644
index 0000000..a91b904
--- /dev/null
+++ b/tools/perf/arch/mips/include/perf_regs.h
@@ -0,0 +1,84 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include <stdlib.h>
+#include "../../util/types.h"
+#include <asm/perf_regs.h>
+
+#define PERF_REG_IP PERF_REG_MIPS_PC
+#define PERF_REG_SP PERF_REG_MIPS_R29
+
+#define PERF_REGS_MASK ((1ULL << PERF_REG_MIPS_MAX) - 1)
+
+static inline const char *perf_reg_name(int id)
+{
+ switch (id) {
+ case PERF_REG_MIPS_PC:
+ return "PC";
+ case PERF_REG_MIPS_R1:
+ return "$1";
+ case PERF_REG_MIPS_R2:
+ return "$2";
+ case PERF_REG_MIPS_R3:
+ return "$3";
+ case PERF_REG_MIPS_R4:
+ return "$4";
+ case PERF_REG_MIPS_R5:
+ return "$5";
+ case PERF_REG_MIPS_R6:
+ return "$6";
+ case PERF_REG_MIPS_R7:
+ return "$7";
+ case PERF_REG_MIPS_R8:
+ return "$8";
+ case PERF_REG_MIPS_R9:
+ return "$9";
+ case PERF_REG_MIPS_R10:
+ return "$10";
+ case PERF_REG_MIPS_R11:
+ return "$11";
+ case PERF_REG_MIPS_R12:
+ return "$12";
+ case PERF_REG_MIPS_R13:
+ return "$13";
+ case PERF_REG_MIPS_R14:
+ return "$14";
+ case PERF_REG_MIPS_R15:
+ return "$15";
+ case PERF_REG_MIPS_R16:
+ return "$16";
+ case PERF_REG_MIPS_R17:
+ return "$17";
+ case PERF_REG_MIPS_R18:
+ return "$18";
+ case PERF_REG_MIPS_R19:
+ return "$19";
+ case PERF_REG_MIPS_R20:
+ return "$20";
+ case PERF_REG_MIPS_R21:
+ return "$21";
+ case PERF_REG_MIPS_R22:
+ return "$22";
+ case PERF_REG_MIPS_R23:
+ return "$23";
+ case PERF_REG_MIPS_R24:
+ return "$24";
+ case PERF_REG_MIPS_R25:
+ return "$25";
+
+ case PERF_REG_MIPS_R28:
+ return "$28";
+ case PERF_REG_MIPS_R29:
+ return "$29";
+ case PERF_REG_MIPS_R30:
+ return "$30";
+ case PERF_REG_MIPS_R31:
+ return "$31";
+ default:
+ break;
+ }
+ return NULL;
+}
+
+
+#endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/mips/util/dwarf-regs.c b/tools/perf/arch/mips/util/dwarf-regs.c
new file mode 100644
index 0000000..165e017
--- /dev/null
+++ b/tools/perf/arch/mips/util/dwarf-regs.c
@@ -0,0 +1,37 @@
+/*
+ * dwarf-regs.c : Mapping of DWARF debug register numbers into register names.
+ *
+ * Copyright (C) 2013 Cavium, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <libio.h>
+#include <dwarf-regs.h>
+
+static const char *mips_gpr_names[32] = {
+ "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ "$10", "$11", "$12", "$13", "$14", "$15", "$16", "$17", "$18", "$19",
+ "$20", "$21", "$22", "$23", "$24", "$25", "$26", "$27", "$28", "$29",
+ "$30", "$31"
+};
+
+const char *get_arch_regstr(unsigned int n)
+{
+ if (n < 32)
+ return mips_gpr_names[n];
+ if (n == 64)
+ return "hi";
+ if (n == 65)
+ return "lo";
+ return NULL;
+}
diff --git a/tools/perf/arch/mips/util/unwind.c b/tools/perf/arch/mips/util/unwind.c
new file mode 100644
index 0000000..612949b
--- /dev/null
+++ b/tools/perf/arch/mips/util/unwind.c
@@ -0,0 +1,20 @@
+
+#include <errno.h>
+#include <libunwind.h>
+#include "perf_regs.h"
+#include "../../util/unwind.h"
+
+int unwind__arch_reg_id(int regnum)
+{
+ switch (regnum) {
+ case UNW_MIPS_R1 ... UNW_MIPS_R25:
+ return regnum - UNW_MIPS_R1 + PERF_REG_MIPS_R1;
+ case UNW_MIPS_R28 ... UNW_MIPS_R31:
+ return regnum - UNW_MIPS_R28 + PERF_REG_MIPS_R28;
+ case UNW_MIPS_PC:
+ return PERF_REG_MIPS_PC;
+ default:
+ pr_err("unwind: invalid reg id %d\n", regnum);
+ return -EINVAL;
+ }
+}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-09-27 20:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 23:58 [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Ralf Baechle
2015-04-07 23:58 ` [PATCH 1/2] perf tools: Add support for " David Daney
2015-04-08 9:46 ` Jiri Olsa
2015-04-07 23:58 ` [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile David Daney
2015-04-08 9:58 ` Jiri Olsa
2015-09-27 16:05 ` [PATCH 0/2] perf tools: Add MIPS userspace DWARF callchains Rabin Vincent
2015-09-27 20:39 ` David Daney
2015-09-27 20:39 ` David Daney
-- strict thread matches above, loose matches on Subject: below --
2013-05-17 19:00 David Daney
2013-05-17 19:00 ` [PATCH 1/2] perf tools: Add support for " David Daney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.