csky: perf callchain dwarf support
Subsystems (2)
v4 cover csky: perf callchain dwarf support
This patch set add perf DWARF unwinding support for C-SKY. Including user registers/stack dump API, and libdw support.
Changes since v3:
- update with patch from Arnaldo
replace other hweight_long with hweight64
Changes since v2:
- use same registers name as struct pt_regs
- code convention
Changes since v1:
- seperate the callchain support using frame pointer
Mao Han (3):
perf evsel: Use hweight64() instead of
hweight_long(attr.sample_regs_user)
csky: Add support for perf registers sampling
csky: Add support for libdw
arch/csky/Kconfig | 2 + arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++ arch/csky/kernel/Makefile | 1 + arch/csky/kernel/perf_regs.c | 40 +++++++++++ tools/arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++ tools/perf/Makefile.config | 6 +- tools/perf/arch/csky/Build | 1 + tools/perf/arch/csky/Makefile | 3 + tools/perf/arch/csky/include/perf_regs.h | 100 +++++++++++++++++++++++++++ tools/perf/arch/csky/util/Build | 2 + tools/perf/arch/csky/util/dwarf-regs.c | 49 +++++++++++++ tools/perf/arch/csky/util/unwind-libdw.c | 78 +++++++++++++++++++++ tools/perf/util/evsel.c | 12 ++-- 13 files changed, 389 insertions(+), 7 deletions(-) create mode 100644 arch/csky/include/uapi/asm/perf_regs.h create mode 100644 arch/csky/kernel/perf_regs.c create mode 100644 tools/arch/csky/include/uapi/asm/perf_regs.h create mode 100644 tools/perf/arch/csky/Build create mode 100644 tools/perf/arch/csky/Makefile create mode 100644 tools/perf/arch/csky/include/perf_regs.h create mode 100644 tools/perf/arch/csky/util/Build create mode 100644 tools/perf/arch/csky/util/dwarf-regs.c create mode 100644 tools/perf/arch/csky/util/unwind-libdw.c
Signature · 1 line
2.7.4
PATCH v4 1/3 perf evsel: Use hweight64() instead of hweight_long(attr.sample_regs_user)
On 32-bits platform with more than 32 registers, the 64 bits mask is truncate to the lower 32 bits and the return value of hweight_long will always smaller than 32. When kernel outputs more than 32 registers, but the user perf program only counts 32, there will be a data mismatch result to overflow check fail.
: http://lkml.kernel.org/r/29ad7947dc8fd1ff0abd2093a72cc27a2446be9f.1554883878.git.han_mao@c-sky.com
--- tools/perf/util/evsel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/util/evsel.c +6 -6
@@ -2368,7 +2368,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,if (data->user_regs.abi) {u64 mask = evsel->attr.sample_regs_user; - sz =hweight_long (mask) *sizeof (u64); + sz =hweight64 (mask) *sizeof (u64);OVERFLOW_CHECK (array, sz, max_size); data->user_regs.mask = mask; data->user_regs.regs = (u64 *)array;
@@ -2424,7 +2424,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,if (data->intr_regs.abi !=PERF_SAMPLE_REGS_ABI_NONE ) {u64 mask = evsel->attr.sample_regs_intr; - sz =hweight_long (mask) *sizeof (u64); + sz =hweight64 (mask) *sizeof (u64);OVERFLOW_CHECK (array, sz, max_size); data->intr_regs.mask = mask; data->intr_regs.regs = (u64 *)array;
@@ -2552,7 +2552,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,if (type &PERF_SAMPLE_REGS_USER ) {if (sample->user_regs.abi) { result +=sizeof (u64); - sz =hweight_long (sample->user_regs.mask) *sizeof (u64); + sz =hweight64 (sample->user_regs.mask) *sizeof (u64); result += sz; }else { result +=sizeof (u64);
@@ -2580,7 +2580,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,if (type &PERF_SAMPLE_REGS_INTR ) {if (sample->intr_regs.abi) { result +=sizeof (u64); - sz =hweight_long (sample->intr_regs.mask) *sizeof (u64); + sz =hweight64 (sample->intr_regs.mask) *sizeof (u64); result += sz; }else { result +=sizeof (u64);
@@ -2710,7 +2710,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,if (type &PERF_SAMPLE_REGS_USER ) {if (sample->user_regs.abi) { *array++ = sample->user_regs.abi; - sz =hweight_long (sample->user_regs.mask) *sizeof (u64); + sz =hweight64 (sample->user_regs.mask) *sizeof (u64);memcpy (array, sample->user_regs.regs, sz); array = (void *)array + sz; }else {
@@ -2746,7 +2746,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,if (type &PERF_SAMPLE_REGS_INTR ) {if (sample->intr_regs.abi) { *array++ = sample->intr_regs.abi; - sz =hweight_long (sample->intr_regs.mask) *sizeof (u64); + sz =hweight64 (sample->intr_regs.mask) *sizeof (u64);memcpy (array, sample->intr_regs.regs, sz); array = (void *)array + sz; }else {
Signature · 1 line
2.7.4
PATCH v4 2/3 csky: Add support for perf registers sampling
In reply to Mao HanThis patch implements the perf registers sampling and validation API for csky arch. The valid registers and their register ID are defined in perf_regs.h. Perf tool can backtrace in userspace with unwind library and the registers/user stack dump support.
--- arch/csky/Kconfig | 2 ++ arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++++++++++++++++++++++ arch/csky/kernel/Makefile | 1 + arch/csky/kernel/perf_regs.c | 40 ++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 arch/csky/include/uapi/asm/perf_regs.h create mode 100644 arch/csky/kernel/perf_regs.c
arch/csky/Kconfig +2 -0
@@ -38,6 +38,8 @@ config CSKY select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA select HAVE_PERF_EVENTS + select HAVE_PERF_REGS + select HAVE_PERF_USER_STACK_DUMP select HAVE_DMA_API_DEBUG select HAVE_DMA_CONTIGUOUS select HAVE_SYSCALL_TRACEPOINTS
arch/csky/include/uapi/asm/perf_regs.h new file +51 -0
51 lines not on this page · raw message
arch/csky/kernel/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_CSKY_PMU_V1) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o +obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
arch/csky/kernel/perf_regs.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/perf_event.h> +#include <linux/bug.h> +#include <asm/perf_regs.h> +#include <asm/ptrace.h> + +u64 perf_reg_value (struct pt_regs *regs,int idx) +{ +if (WARN_ON_ONCE ((u32 )idx >=PERF_REG_CSKY_MAX )) +return 0 ; + +return ((long *)regs)[idx]; +} + +#define REG_RESERVED (~((1ULL << PERF_REG_CSKY_MAX) - 1)) + +int perf_reg_validate (u64 mask) +{ +if (!mask || mask ®_RESERVED ) +return -EINVAL ; + +return 0 ; +} + +u64 perf_reg_abi (struct task_struct *task) +{ +return PERF_SAMPLE_REGS_ABI_32 ; +} + +void perf_get_regs_user (struct perf_regs *regs_user, +struct pt_regs *regs, +struct pt_regs *regs_user_copy) +{ + regs_user->regs =task_pt_regs (current); + regs_user->abi =perf_reg_abi (current); +}
Signature · 1 line
2.7.4
Guo Ren
maintainerRe: [PATCH v4 2/3] csky: Add support for perf registers sampling
Hi Mao,
Quoted 111 lines · Mao Han
This patch implements the perf registers sampling and validation API for csky arch. The valid registers and their register ID are defined in
perf_regs.h. Perf tool can backtrace in userspace with unwind library and the registers/user stack dump support.CC Guo Ren <[email protected]>Signed-off-by Mao Han <[email protected]>--- arch/csky/Kconfig | 2 ++ arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++++++++++++++++++++++ arch/csky/kernel/Makefile | 1 + arch/csky/kernel/perf_regs.c | 40 ++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 arch/csky/include/uapi/asm/perf_regs.h create mode 100644 arch/csky/kernel/perf_regs.carch/csky/Kconfig +2
-0@@ -38,6 +38,8 @@ config CSKY select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA select HAVE_PERF_EVENTS + select HAVE_PERF_REGS + select HAVE_PERF_USER_STACK_DUMP select HAVE_DMA_API_DEBUG select HAVE_DMA_CONTIGUOUS select HAVE_SYSCALL_TRACEPOINTSarch/csky/include/uapi/asm/perf_regs.h new file +51
-0@@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#ifndef _ASM_CSKY_PERF_REGS_H +#define _ASM_CSKY_PERF_REGS_H + +/* Index of struct pt_regs */ +enum perf_event_csky_regs { +PERF_REG_CSKY_TLS , +PERF_REG_CSKY_LR , +PERF_REG_CSKY_PC , +PERF_REG_CSKY_SR , +PERF_REG_CSKY_SP , +PERF_REG_CSKY_ORIG_A0 , +PERF_REG_CSKY_A0 , +PERF_REG_CSKY_A1 , +PERF_REG_CSKY_A2 , +PERF_REG_CSKY_A3 , +PERF_REG_CSKY_REGS0 , +PERF_REG_CSKY_REGS1 , +PERF_REG_CSKY_REGS2 , +PERF_REG_CSKY_REGS3 , +PERF_REG_CSKY_REGS4 , +PERF_REG_CSKY_REGS5 , +PERF_REG_CSKY_REGS6 , +PERF_REG_CSKY_REGS7 , +PERF_REG_CSKY_REGS8 , +PERF_REG_CSKY_REGS9 , +#if defined(__CSKYABIV2__) +PERF_REG_CSKY_EXREGS0 , +PERF_REG_CSKY_EXREGS1 , +PERF_REG_CSKY_EXREGS2 , +PERF_REG_CSKY_EXREGS3 , +PERF_REG_CSKY_EXREGS4 , +PERF_REG_CSKY_EXREGS5 , +PERF_REG_CSKY_EXREGS6 , +PERF_REG_CSKY_EXREGS7 , +PERF_REG_CSKY_EXREGS8 , +PERF_REG_CSKY_EXREGS9 , +PERF_REG_CSKY_EXREGS10 , +PERF_REG_CSKY_EXREGS11 , +PERF_REG_CSKY_EXREGS12 , +PERF_REG_CSKY_EXREGS13 , +PERF_REG_CSKY_EXREGS14 , +PERF_REG_CSKY_HI , +PERF_REG_CSKY_LO , +PERF_REG_CSKY_DCSR , +#endif +PERF_REG_CSKY_MAX , +}; +#endif /* _ASM_CSKY_PERF_REGS_H */ arch/csky/kernel/Makefile +1
-0@@ -10,6 +10,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_CSKY_PMU_V1) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o +obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)arch/csky/kernel/perf_regs.c new file +6
-0@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/perf_event.h>
arch/csky/kernel/perf_regs.c line 16
Quoted 10 lines
arch/csky/kernel/perf_regs.c new file +10
-0+#include <linux/bug.h> +#include <asm/perf_regs.h> +#include <asm/ptrace.h> + +u64 perf_reg_value (struct pt_regs *regs,int idx) +{ +if (WARN_ON_ONCE ((u32 )idx >=PERF_REG_CSKY_MAX )) +return 0 ; + +return ((long *)regs)[idx];
Please use:
return (u64)((u32 *)regs + idx);
Quoted 14 lines
arch/csky/kernel/perf_regs.c new file +14
-0+} + +#define REG_RESERVED (~((1ULL << PERF_REG_CSKY_MAX) - 1)) + +int perf_reg_validate (u64 mask) +{ +if (!mask || mask ®_RESERVED ) +return -EINVAL ; + +return 0 ; +} + +u64 perf_reg_abi (struct task_struct *task) +{
arch/csky/kernel/perf_regs.c line 40
Quoted 10 lines
arch/csky/kernel/perf_regs.c new file +10
-0+return PERF_SAMPLE_REGS_ABI_32 ; +} + +void perf_get_regs_user (struct perf_regs *regs_user, +struct pt_regs *regs, +struct pt_regs *regs_user_copy) +{ + regs_user->regs =task_pt_regs (current); + regs_user->abi =perf_reg_abi (current); +}
Best Regards
Guo Ren
Guo Ren
maintainerRe: [PATCH v4 2/3] csky: Add support for perf registers sampling
In reply to Mao HanHi Mao,
Sorry, currect:
arch/csky/kernel/perf_regs.c line 16
Quoted 6 lines · Mao Han
This patch implements the perf registers sampling and validation API for csky arch. The valid registers and their register ID are defined in
perf_regs.h. Perf tool can backtrace in userspace with unwind library and the registers/user stack dump support.arch/csky/kernel/perf_regs.c new file +1
-0+return ((long *)regs)[idx];
return (u64)*((u32 *)regs + idx);
Best Regards
Guo Ren
PATCH v4 3/3 csky: Add support for libdw
In reply to Mao HanThis patch add support for DWARF register mappings and libdw registers initialization, which is used by perf callchain analyzing when --call-graph=dwarf is given.
--- tools/arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++ tools/perf/Makefile.config | 6 +- tools/perf/arch/csky/Build | 1 + tools/perf/arch/csky/Makefile | 3 + tools/perf/arch/csky/include/perf_regs.h | 100 +++++++++++++++++++++++++++ tools/perf/arch/csky/util/Build | 2 + tools/perf/arch/csky/util/dwarf-regs.c | 49 +++++++++++++ tools/perf/arch/csky/util/unwind-libdw.c | 78 +++++++++++++++++++++ 8 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 tools/arch/csky/include/uapi/asm/perf_regs.h create mode 100644 tools/perf/arch/csky/Build create mode 100644 tools/perf/arch/csky/Makefile create mode 100644 tools/perf/arch/csky/include/perf_regs.h create mode 100644 tools/perf/arch/csky/util/Build create mode 100644 tools/perf/arch/csky/util/dwarf-regs.c create mode 100644 tools/perf/arch/csky/util/unwind-libdw.c
tools/arch/csky/include/uapi/asm/perf_regs.h new file +51 -0
@@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#ifndef _ASM_CSKY_PERF_REGS_H +#define _ASM_CSKY_PERF_REGS_H + +/* Index of struct pt_regs */ +enum perf_event_csky_regs { +PERF_REG_CSKY_TLS , +PERF_REG_CSKY_LR , +PERF_REG_CSKY_PC , +PERF_REG_CSKY_SR , +PERF_REG_CSKY_SP , +PERF_REG_CSKY_ORIG_A0 , +PERF_REG_CSKY_A0 , +PERF_REG_CSKY_A1 , +PERF_REG_CSKY_A2 , +PERF_REG_CSKY_A3 , +PERF_REG_CSKY_REGS0 , +PERF_REG_CSKY_REGS1 , +PERF_REG_CSKY_REGS2 , +PERF_REG_CSKY_REGS3 , +PERF_REG_CSKY_REGS4 , +PERF_REG_CSKY_REGS5 , +PERF_REG_CSKY_REGS6 , +PERF_REG_CSKY_REGS7 , +PERF_REG_CSKY_REGS8 , +PERF_REG_CSKY_REGS9 , +#if defined(__CSKYABIV2__) +PERF_REG_CSKY_EXREGS0 , +PERF_REG_CSKY_EXREGS1 , +PERF_REG_CSKY_EXREGS2 , +PERF_REG_CSKY_EXREGS3 , +PERF_REG_CSKY_EXREGS4 , +PERF_REG_CSKY_EXREGS5 , +PERF_REG_CSKY_EXREGS6 , +PERF_REG_CSKY_EXREGS7 , +PERF_REG_CSKY_EXREGS8 , +PERF_REG_CSKY_EXREGS9 , +PERF_REG_CSKY_EXREGS10 , +PERF_REG_CSKY_EXREGS11 , +PERF_REG_CSKY_EXREGS12 , +PERF_REG_CSKY_EXREGS13 , +PERF_REG_CSKY_EXREGS14 , +PERF_REG_CSKY_HI , +PERF_REG_CSKY_LO , +PERF_REG_CSKY_DCSR , +#endif +PERF_REG_CSKY_MAX , +}; +#endif /* _ASM_CSKY_PERF_REGS_H */
tools/perf/Makefile.config +5 -1
@@ -59,6 +59,10 @@ ifeq ($(SRCARCH),arm64) LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 endif +ifeq ($(SRCARCH),csky) + NO_PERF_REGS := 0 +endif + ifeq ($(ARCH),s390) NO_PERF_REGS := 0 NO_SYSCALL_TABLE := 0
@@ -77,7 +81,7 @@ endif # Disable it on all other architectures in case libdw unwind # support is detected in system. Add supported architectures # to the check. -ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390)) +ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky)) NO_LIBDW_DWARF_UNWIND := 1 endif
tools/perf/arch/csky/Build new file +1 -0
@@ -0,0 +1 @@ +perf-y += util/
tools/perf/arch/csky/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +ifndef NO_DWARF +PERF_HAVE_DWARF_REGS := 1 +endif
tools/perf/arch/csky/include/perf_regs.h new file +100 -0
100 lines not on this page · raw message
tools/perf/arch/csky/util/Build new file +2 -0
@@ -0,0 +1,2 @@ +perf-$(CONFIG_DWARF) += dwarf-regs.o +perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
tools/perf/arch/csky/util/dwarf-regs.c new file +49 -0
49 lines not on this page · raw message
tools/perf/arch/csky/util/unwind-libdw.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.7.4
Guo Ren
maintainerRe: [PATCH v4 3/3] csky: Add support for libdw
Quoted 263 lines · Mao Han
This patch add support for DWARF register mappings and libdw registers initialization, which is used by perf callchain analyzing when --call-graph=dwarf is given.
CC Peter Zijlstra <[email protected]>CC Ingo Molnar <[email protected]>CC Arnaldo Carvalho de Melo <[email protected]>CC Alexander Shishkin <[email protected]>CC Jiri Olsa <[email protected]>CC Namhyung Kim <[email protected]>Signed-off-by Mao Han <[email protected]>--- tools/arch/csky/include/uapi/asm/perf_regs.h | 51 ++++++++++++++ tools/perf/Makefile.config | 6 +- tools/perf/arch/csky/Build | 1 + tools/perf/arch/csky/Makefile | 3 + tools/perf/arch/csky/include/perf_regs.h | 100 +++++++++++++++++++++++++++ tools/perf/arch/csky/util/Build | 2 + tools/perf/arch/csky/util/dwarf-regs.c | 49 +++++++++++++ tools/perf/arch/csky/util/unwind-libdw.c | 78 +++++++++++++++++++++ 8 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 tools/arch/csky/include/uapi/asm/perf_regs.h create mode 100644 tools/perf/arch/csky/Build create mode 100644 tools/perf/arch/csky/Makefile create mode 100644 tools/perf/arch/csky/include/perf_regs.h create mode 100644 tools/perf/arch/csky/util/Build create mode 100644 tools/perf/arch/csky/util/dwarf-regs.c create mode 100644 tools/perf/arch/csky/util/unwind-libdw.ctools/arch/csky/include/uapi/asm/perf_regs.h new file +51
-0@@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#ifndef _ASM_CSKY_PERF_REGS_H +#define _ASM_CSKY_PERF_REGS_H + +/* Index of struct pt_regs */ +enum perf_event_csky_regs { +PERF_REG_CSKY_TLS , +PERF_REG_CSKY_LR , +PERF_REG_CSKY_PC , +PERF_REG_CSKY_SR , +PERF_REG_CSKY_SP , +PERF_REG_CSKY_ORIG_A0 , +PERF_REG_CSKY_A0 , +PERF_REG_CSKY_A1 , +PERF_REG_CSKY_A2 , +PERF_REG_CSKY_A3 , +PERF_REG_CSKY_REGS0 , +PERF_REG_CSKY_REGS1 , +PERF_REG_CSKY_REGS2 , +PERF_REG_CSKY_REGS3 , +PERF_REG_CSKY_REGS4 , +PERF_REG_CSKY_REGS5 , +PERF_REG_CSKY_REGS6 , +PERF_REG_CSKY_REGS7 , +PERF_REG_CSKY_REGS8 , +PERF_REG_CSKY_REGS9 , +#if defined(__CSKYABIV2__) +PERF_REG_CSKY_EXREGS0 , +PERF_REG_CSKY_EXREGS1 , +PERF_REG_CSKY_EXREGS2 , +PERF_REG_CSKY_EXREGS3 , +PERF_REG_CSKY_EXREGS4 , +PERF_REG_CSKY_EXREGS5 , +PERF_REG_CSKY_EXREGS6 , +PERF_REG_CSKY_EXREGS7 , +PERF_REG_CSKY_EXREGS8 , +PERF_REG_CSKY_EXREGS9 , +PERF_REG_CSKY_EXREGS10 , +PERF_REG_CSKY_EXREGS11 , +PERF_REG_CSKY_EXREGS12 , +PERF_REG_CSKY_EXREGS13 , +PERF_REG_CSKY_EXREGS14 , +PERF_REG_CSKY_HI , +PERF_REG_CSKY_LO , +PERF_REG_CSKY_DCSR , +#endif +PERF_REG_CSKY_MAX , +}; +#endif /* _ASM_CSKY_PERF_REGS_H */ tools/perf/Makefile.config +5
-1@@ -59,6 +59,10 @@ ifeq ($(SRCARCH),arm64) LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 endif +ifeq ($(SRCARCH),csky) + NO_PERF_REGS := 0 +endif + ifeq ($(ARCH),s390) NO_PERF_REGS := 0 NO_SYSCALL_TABLE := 0@@ -77,7 +81,7 @@ endif # Disable it on all other architectures in case libdw unwind # support is detected in system. Add supported architectures # to the check. -ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390)) +ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky)) NO_LIBDW_DWARF_UNWIND := 1 endiftools/perf/arch/csky/Build new file +1
-0@@ -0,0 +1 @@ +perf-y += util/tools/perf/arch/csky/Makefile new file +3
-0@@ -0,0 +1,3 @@ +ifndef NO_DWARF +PERF_HAVE_DWARF_REGS := 1 +endiftools/perf/arch/csky/include/perf_regs.h new file +100
-0@@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#ifndef ARCH_PERF_REGS_H +#define ARCH_PERF_REGS_H + +#include <stdlib.h> +#include <linux/types.h> +#include <asm/perf_regs.h> + +#define PERF_REGS_MASK ((1ULL << PERF_REG_CSKY_MAX) - 1) +#define PERF_REGS_MAX PERF_REG_CSKY_MAX +#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 + +#define PERF_REG_IP PERF_REG_CSKY_PC +#define PERF_REG_SP PERF_REG_CSKY_SP + +static inline const char *perf_reg_name (int id) +{ +switch (id) { +case PERF_REG_CSKY_A0 : +return "a0" ; +case PERF_REG_CSKY_A1 : +return "a1" ; +case PERF_REG_CSKY_A2 : +return "a2" ; +case PERF_REG_CSKY_A3 : +return "a3" ; +case PERF_REG_CSKY_REGS0 : +return "regs0" ; +case PERF_REG_CSKY_REGS1 : +return "regs1" ; +case PERF_REG_CSKY_REGS2 : +return "regs2" ; +case PERF_REG_CSKY_REGS3 : +return "regs3" ; +case PERF_REG_CSKY_REGS4 : +return "regs4" ; +case PERF_REG_CSKY_REGS5 : +return "regs5" ; +case PERF_REG_CSKY_REGS6 : +return "regs6" ; +case PERF_REG_CSKY_REGS7 : +return "regs7" ; +case PERF_REG_CSKY_REGS8 : +return "regs8" ; +case PERF_REG_CSKY_REGS9 : +return "regs9" ; +case PERF_REG_CSKY_SP : +return "sp" ; +case PERF_REG_CSKY_LR : +return "lr" ; +case PERF_REG_CSKY_PC : +return "pc" ; +#if defined(__CSKYABIV2__) +case PERF_REG_CSKY_EXREGS0 : +return "exregs0" ; +case PERF_REG_CSKY_EXREGS1 : +return "exregs1" ; +case PERF_REG_CSKY_EXREGS2 : +return "exregs2" ; +case PERF_REG_CSKY_EXREGS3 : +return "exregs3" ; +case PERF_REG_CSKY_EXREGS4 : +return "exregs4" ; +case PERF_REG_CSKY_EXREGS5 : +return "exregs5" ; +case PERF_REG_CSKY_EXREGS6 : +return "exregs6" ; +case PERF_REG_CSKY_EXREGS7 : +return "exregs7" ; +case PERF_REG_CSKY_EXREGS8 : +return "exregs8" ; +case PERF_REG_CSKY_EXREGS9 : +return "exregs9" ; +case PERF_REG_CSKY_EXREGS10 : +return "exregs10" ; +case PERF_REG_CSKY_EXREGS11 : +return "exregs11" ; +case PERF_REG_CSKY_EXREGS12 : +return "exregs12" ; +case PERF_REG_CSKY_EXREGS13 : +return "exregs13" ; +case PERF_REG_CSKY_EXREGS14 : +return "exregs14" ; +case PERF_REG_CSKY_TLS : +return "tls" ; +case PERF_REG_CSKY_HI : +return "hi" ; +case PERF_REG_CSKY_LO : +return "lo" ; +#endif +default : +return NULL ; + } + +return NULL ; +} + +#endif /* ARCH_PERF_REGS_H */ tools/perf/arch/csky/util/Build new file +2
-0@@ -0,0 +1,2 @@ +perf-$(CONFIG_DWARF) += dwarf-regs.o +perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.otools/perf/arch/csky/util/dwarf-regs.c new file +16
-0@@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. +// Mapping of DWARF debug register numbers into register names. + +#include <stddef.h> +#include <dwarf-regs.h> + +#if defined(__CSKYABIV2__) +#define CSKY_MAX_REGS 71 +const char *csky_dwarf_regs_table[CSKY_MAX_REGS ] = { +/* r0 ~ r8 */ +"%a0" ,"%a1" ,"%a2" ,"%a3" ,"%regs0" ,"%regs1" ,"%regs2" ,"%regs3" , +/* r9 ~ r15 */ +"%regs4" ,"%regs5" ,"%regs6" ,"%regs7" ,"%regs8" ,"%regs9" ,"%sp" , +"%lr" , + /* r16 ~ r23 */
tools/perf/arch/csky/util/dwarf-regs.c line 26
Quoted 10 lines
tools/perf/arch/csky/util/dwarf-regs.c new file +10
-0+"%exregs0" ,"%exregs1" ,"%exregs2" ,"%exregs3" ,"%exregs4" , +"%exregs5" ,"%exregs6" ,"%exregs7" , +/* r24 ~ r31 */ +"%exregs8" ,"%exregs9" ,"%exregs10" ,"%exregs11" ,"%exregs12" , +"%exregs13" ,"%exregs14" ,"%tls" , +"%pc" ,"%cc" ,"%hi" ,"%lo" ,NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL ,"%vr0" ,"%vr1" ,"%vr2" ,"%vr3" , +"%vr4" ,"%vr5" ,"%vr6" ,"%vr7" ,"%vr8" ,"%vr9" ,"%vr10" ,"%vr11" , + "%vr12", "%vr13", "%vr14", "%vr15", NULL, NULL, "%epc",
Remove vr0-vr15 first.
Quoted 6 lines
tools/perf/arch/csky/util/dwarf-regs.c new file +6
-0+}; +#else +#define CSKY_MAX_REGS 70 +const char *csky_dwarf_regs_table[CSKY_MAX_REGS ] = { +/* r0 ~ r8 */ + "%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1",
tools/perf/arch/csky/util/dwarf-regs.c line 42
Quoted 10 lines
tools/perf/arch/csky/util/dwarf-regs.c new file +10
-0+/* r9 ~ r15 */ +"%regs2" ,"%regs3" ,"%regs4" ,"%regs5" ,"%regs6" ,"%regs7" ,"%regs8" , +"%lr" , +NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +"%vap" ,"%cc" ,"%vfp" ,"%epc" ,"%hi" ,"%lo" ,"%fr0" ,"%fr1" , +"%fr2" ,"%fr3" ,"%fr4" ,"%fr5" ,"%fr6" ,"%fr7" ,"%fr8" ,"%fr9" , +"%fr10" ,"%fr11" ,"%fr12" ,"%fr13" ,"%fr14" ,"%fr15" ,"%fr16" ,"%fr17" , +"%fr18" ,"%fr19" ,"%fr20" ,"%fr21" ,"%fr22" ,"%fr23" ,"%fr24" ,"%fr25" , +"%fr26" ,"%fr27" ,"%fr28" ,"%fr29" ,"%fr30" ,"%fr31"
Please remove vap cc vfp hi lo fr0~fr31, current abiv1 linux couldn't suppport them.
Best Regards
Guo Ren