]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit
nds32: Perf porting
authorNickhu <nickhu@andestech.com>
Thu, 25 Oct 2018 02:24:15 +0000 (10:24 +0800)
committerGreentime Hu <greentime@andestech.com>
Tue, 6 Nov 2018 10:01:40 +0000 (18:01 +0800)
commitebd09753b5707cc083c52e1d0ec7f45dccdb73bf
treeb1ad878d81baf9e66080a310120b462d53d8f170
parent9aaafac8cffa1c1edb66e19a63841b7c86be07ca
nds32: Perf porting

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>
15 files changed:
arch/nds32/Kconfig
arch/nds32/boot/dts/ae3xx.dts
arch/nds32/include/asm/Kbuild
arch/nds32/include/asm/perf_event.h [new file with mode: 0644]
arch/nds32/include/asm/pmu.h [new file with mode: 0644]
arch/nds32/include/asm/stacktrace.h [new file with mode: 0644]
arch/nds32/kernel/Makefile
arch/nds32/kernel/perf_event_cpu.c [new file with mode: 0644]
arch/nds32/mm/fault.c
tools/include/asm/barrier.h
tools/perf/arch/nds32/Build [new file with mode: 0644]
tools/perf/arch/nds32/util/Build [new file with mode: 0644]
tools/perf/arch/nds32/util/header.c [new file with mode: 0644]
tools/perf/pmu-events/arch/nds32/mapfile.csv [new file with mode: 0644]
tools/perf/pmu-events/arch/nds32/n13/atcpmu.json [new file with mode: 0644]