mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
ebd09753b5
This is the commit that porting the perf for nds32. 1.Raw event: The raw events start with 'r'. Usage: perf stat -e rXYZ ./app X: the index of performance counter. YZ: the index(convert to hexdecimal) of events Example: 'perf stat -e r101 ./app' means the counter 1 will count the instruction event. The index of counter and events can be found in "Andes System Privilege Architecture Version 3 Manual". Or you can perform the 'perf list' to find the symbolic name of raw events. 2.Perf mmap2: Fix unexpected perf mmap2() page fault When the mmap2() called by perf application, you will encounter such condition:"failed to write." With return value -EFAULT This is due to the page fault caused by "reading" buffer from the mapped legal address region to write to the descriptor. The page_fault handler will get a VM_FAULT_SIGBUS return value, which should not happens here.(Due to this is a read request.) You can refer to kernel/events/core.c:perf_mmap_fault(...) If "(vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE))" is evaluated as true, you will get VM_FAULT_SIGBUS as return value. However, this is not an write request. The flags which indicated why the page fault happens is wrong. Furthermore, NDS32 SPAv3 is not able to detect it is read or write. It only know either it is instruction fetch or data access. Therefore, by removing the wrong flag assignment(actually, the hardware is not able to show the reason), we can fix this bug. 3.Perf multiple events map to same counter. When there are multiple events map to the same counter, the counter counts inaccurately. This is because each counter only counts one event in the same time. So when there are multiple events map to same counter, they have to take turns in each context. There are two solution: 1. Print the error message when multiple events map to the same counter. But print the error message would let the program hang in loop. The ltp (linux test program) would be failed when the program hang in loop. 2. Don't print the error message, the ltp would pass. But the user need to have the knowledge that don't count the events which map to the same counter, or the user will get the inaccurate results. We choose method 2 for the solution Signed-off-by: Nickhu <nickhu@andestech.com> Acked-by: Greentime Hu <greentime@andestech.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
40 lines
884 B
C
40 lines
884 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (C) 2008-2018 Andes Technology Corporation */
|
|
|
|
#ifndef __ASM_STACKTRACE_H
|
|
#define __ASM_STACKTRACE_H
|
|
|
|
/* Kernel callchain */
|
|
struct stackframe {
|
|
unsigned long fp;
|
|
unsigned long sp;
|
|
unsigned long lp;
|
|
};
|
|
|
|
/*
|
|
* struct frame_tail: User callchain
|
|
* IMPORTANT:
|
|
* This struct is used for call-stack walking,
|
|
* the order and types matters.
|
|
* Do not use array, it only stores sizeof(pointer)
|
|
*
|
|
* The details can refer to arch/arm/kernel/perf_event.c
|
|
*/
|
|
struct frame_tail {
|
|
unsigned long stack_fp;
|
|
unsigned long stack_lp;
|
|
};
|
|
|
|
/* For User callchain with optimize for size */
|
|
struct frame_tail_opt_size {
|
|
unsigned long stack_r6;
|
|
unsigned long stack_fp;
|
|
unsigned long stack_gp;
|
|
unsigned long stack_lp;
|
|
};
|
|
|
|
extern void
|
|
get_real_ret_addr(unsigned long *addr, struct task_struct *tsk, int *graph);
|
|
|
|
#endif /* __ASM_STACKTRACE_H */
|