Skip to contentSkip to conversation

perf tools: Add MIPS userspace DWARF callchains.

PATCH In review Ralf Baechle 5 participants 7 messages Apr 8, 2015 – Sep 27, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover perf tools: Add MIPS userspace DWARF callchains.

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
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/2 perf tools: Add support for MIPS userspace DWARF callchains.

From: David Daney <[email protected]>

Hack up the Makefile and add support code for mips unwinding and dwarf-regs.

Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

Patchwork: https://patchwork.linux-mips.org/patch/5249/

---
 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
tools/perf/Makefile +3 -0
index cb2e586..c2a089a 100644
@@ -28,6 +28,9 @@ ifeq ($(JOBS),)
   ifeq ($(JOBS),)
     JOBS := 1
   endif
+  ifeq ($(ARCH),mips)
+    LIB_H += arch/mips/include/perf_regs.h
+  endif
 endif
 
 #
tools/perf/arch/mips/Makefile new file +7 -0
new file mode 100644
index 0000000..fe9b61e
@@ -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
tools/perf/arch/mips/include/perf_regs.h new file +84 -0

84 lines not on this page · raw message

tools/perf/arch/mips/util/dwarf-regs.c new file +37 -0
new file mode 100644
index 0000000..165e017
@@ -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;
+}
tools/perf/arch/mips/util/unwind.c new file +20 -0
new file mode 100644
index 0000000..612949b
@@ -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;
+	}
+}
Signature · 1 line
1.9.3
#2 lore raw

Re: [PATCH 1/2] perf tools: Add support for MIPS userspace DWARF callchains.

Quoted 4 lines · David Daney

From: David Daney <[email protected]>

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

Quoted 28 lines
Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

Patchwork: https://patchwork.linux-mips.org/patch/5249/

---
 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
tools/perf/Makefile +0 -0
index cb2e586..c2a089a 100644

tools/perf/Makefile ifeq ($(JOBS),) · line 34

Quoted 7 lines
tools/perf/Makefile +3 -0
@@ -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

Quoted 8 lines
tools/perf/Makefile +0 -0
 #
tools/perf/arch/mips/Makefile new file +0 -0
new file mode 100644
index 0000000..fe9b61e

tools/perf/arch/mips/Makefile line 7

Quoted 7 lines
tools/perf/arch/mips/Makefile new file +7 -0
@@ -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

#3 lore raw

PATCH 2/2 perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile

In reply to Ralf Baechle

From: David Daney <[email protected]>

Define a new symbol (ARCH_SUPPORTS_LIBUNWIND) in config/Makefile. Use this from x86 and MIPS to gate testing of libunwind.

Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

Patchwork: https://patchwork.linux-mips.org/patch/5250/

---
 tools/perf/config/Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/perf/config/Makefile +10 -0
index cc22408..0d0595e 100644
@@ -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
Signature · 1 line
1.9.3
#4 lore raw

Re: [PATCH 2/2] perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile

Quoted 4 lines · David Daney

From: David Daney <[email protected]>

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

#5 lore raw
In reply to Ralf Baechle
Quoted 10 lines · Ralf Baechle

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?

Quoted 6 lines

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.

#6 lore raw
Quoted 18 lines · Rabin Vincent
Quoted 10 lines · Ralf Baechle

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?

Quoted 3 lines

David's original patches are archived at:

Quoted 8 lines
Quoted 3 lines
   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