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>
66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <linux/compiler.h>
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
#include "../../arch/x86/include/asm/barrier.h"
|
|
#elif defined(__arm__)
|
|
#include "../../arch/arm/include/asm/barrier.h"
|
|
#elif defined(__aarch64__)
|
|
#include "../../arch/arm64/include/asm/barrier.h"
|
|
#elif defined(__powerpc__)
|
|
#include "../../arch/powerpc/include/asm/barrier.h"
|
|
#elif defined(__s390__)
|
|
#include "../../arch/s390/include/asm/barrier.h"
|
|
#elif defined(__sh__)
|
|
#include "../../arch/sh/include/asm/barrier.h"
|
|
#elif defined(__sparc__)
|
|
#include "../../arch/sparc/include/asm/barrier.h"
|
|
#elif defined(__tile__)
|
|
#include "../../arch/tile/include/asm/barrier.h"
|
|
#elif defined(__alpha__)
|
|
#include "../../arch/alpha/include/asm/barrier.h"
|
|
#elif defined(__mips__)
|
|
#include "../../arch/mips/include/asm/barrier.h"
|
|
#elif defined(__ia64__)
|
|
#include "../../arch/ia64/include/asm/barrier.h"
|
|
#elif defined(__xtensa__)
|
|
#include "../../arch/xtensa/include/asm/barrier.h"
|
|
#elif defined(__nds32__)
|
|
#include "../../arch/nds32/include/asm/barrier.h"
|
|
#else
|
|
#include <asm-generic/barrier.h>
|
|
#endif
|
|
|
|
/*
|
|
* Generic fallback smp_*() definitions for archs that haven't
|
|
* been updated yet.
|
|
*/
|
|
|
|
#ifndef smp_rmb
|
|
# define smp_rmb() rmb()
|
|
#endif
|
|
|
|
#ifndef smp_wmb
|
|
# define smp_wmb() wmb()
|
|
#endif
|
|
|
|
#ifndef smp_mb
|
|
# define smp_mb() mb()
|
|
#endif
|
|
|
|
#ifndef smp_store_release
|
|
# define smp_store_release(p, v) \
|
|
do { \
|
|
smp_mb(); \
|
|
WRITE_ONCE(*p, v); \
|
|
} while (0)
|
|
#endif
|
|
|
|
#ifndef smp_load_acquire
|
|
# define smp_load_acquire(p) \
|
|
({ \
|
|
typeof(*p) ___p1 = READ_ONCE(*p); \
|
|
smp_mb(); \
|
|
___p1; \
|
|
})
|
|
#endif
|