perf: The new configuration supports hardware performance counting
Adding the CONFIG_ARCH_PERF_EVENTS configuration to enable hardware performance counting,solve the problem that some platform hardware counting support is not perfect, you can choose to use software interface. This is configured using CONFIG_ARCH_PERF_EVENTS, so weak_functions are removed to prevent confusion To use hardware performance counting, must: 1. Configure CONFIG_ARCH_PERF_EVENTS, default selection 2. Call up_perf_init for initialization Signed-off-by: wangming9 <wangming9@xiaomi.com>
This commit is contained in:
parent
d0613fa165
commit
c928acc9ff
@ -487,6 +487,13 @@ config ARCH_HAVE_BACKTRACE
|
|||||||
config ARCH_HAVE_PERF_EVENTS
|
config ARCH_HAVE_PERF_EVENTS
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
---help---
|
||||||
|
The architecture supports hardware performance counting.
|
||||||
|
|
||||||
|
config ARCH_PERF_EVENTS
|
||||||
|
bool "Configure hardware performance counting"
|
||||||
|
default y
|
||||||
|
depends on ARCH_HAVE_PERF_EVENTS
|
||||||
---help---
|
---help---
|
||||||
Enable hardware performance counter support for perf events. If
|
Enable hardware performance counter support for perf events. If
|
||||||
disabled, perf events will use software events only.
|
disabled, perf events will use software events only.
|
||||||
|
@ -47,9 +47,12 @@ list(
|
|||||||
arm_syscall.c
|
arm_syscall.c
|
||||||
arm_tcbinfo.c
|
arm_tcbinfo.c
|
||||||
arm_undefinedinsn.c
|
arm_undefinedinsn.c
|
||||||
arm_perf.c
|
|
||||||
cp15_cacheops.c)
|
cp15_cacheops.c)
|
||||||
|
|
||||||
|
if(CONFIG_ARCH_PERF_EVENTS)
|
||||||
|
list(APPEND SRCS arm_perf.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARMV7A_HAVE_PTM)
|
if(CONFIG_ARMV7A_HAVE_PTM)
|
||||||
list(APPEND SRCS arm_timer.c)
|
list(APPEND SRCS arm_timer.c)
|
||||||
endif()
|
endif()
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "arm_internal.h"
|
#include "arm_internal.h"
|
||||||
#include "sctlr.h"
|
#include "sctlr.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -85,3 +87,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * g_cpu_freq;
|
left = elapsed - ts->tv_sec * g_cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -31,7 +31,6 @@ set(SRCS
|
|||||||
arm_initialstate.c
|
arm_initialstate.c
|
||||||
arm_itm.c
|
arm_itm.c
|
||||||
arm_memfault.c
|
arm_memfault.c
|
||||||
arm_perf.c
|
|
||||||
arm_schedulesigaction.c
|
arm_schedulesigaction.c
|
||||||
arm_sigdeliver.c
|
arm_sigdeliver.c
|
||||||
arm_svcall.c
|
arm_svcall.c
|
||||||
@ -41,6 +40,10 @@ set(SRCS
|
|||||||
arm_usagefault.c
|
arm_usagefault.c
|
||||||
arm_vectors.c)
|
arm_vectors.c)
|
||||||
|
|
||||||
|
if(CONFIG_ARCH_PERF_EVENTS)
|
||||||
|
list(APPEND SRCS arm_perf.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARMV7M_SYSTICK)
|
if(CONFIG_ARMV7M_SYSTICK)
|
||||||
list(APPEND SRCS arm_systick.c)
|
list(APPEND SRCS arm_systick.c)
|
||||||
endif()
|
endif()
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "itm.h"
|
#include "itm.h"
|
||||||
#include "nvic.h"
|
#include "nvic.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -74,3 +76,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * g_cpu_freq;
|
left = elapsed - ts->tv_sec * g_cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "arm_internal.h"
|
#include "arm_internal.h"
|
||||||
#include "sctlr.h"
|
#include "sctlr.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -85,3 +87,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * g_cpu_freq;
|
left = elapsed - ts->tv_sec * g_cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -29,7 +29,6 @@ set(SRCS
|
|||||||
arm_initialstate.c
|
arm_initialstate.c
|
||||||
arm_itm.c
|
arm_itm.c
|
||||||
arm_memfault.c
|
arm_memfault.c
|
||||||
arm_perf.c
|
|
||||||
arm_sau.c
|
arm_sau.c
|
||||||
arm_schedulesigaction.c
|
arm_schedulesigaction.c
|
||||||
arm_securefault.c
|
arm_securefault.c
|
||||||
@ -42,6 +41,10 @@ set(SRCS
|
|||||||
arm_usagefault.c
|
arm_usagefault.c
|
||||||
arm_vectors.c)
|
arm_vectors.c)
|
||||||
|
|
||||||
|
if(CONFIG_ARCH_PERF_EVENTS)
|
||||||
|
list(APPEND SRCS arm_perf.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARMV8M_SYSTICK)
|
if(CONFIG_ARMV8M_SYSTICK)
|
||||||
list(APPEND SRCS arm_systick.c)
|
list(APPEND SRCS arm_systick.c)
|
||||||
endif()
|
endif()
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "itm.h"
|
#include "itm.h"
|
||||||
#include "nvic.h"
|
#include "nvic.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -74,3 +76,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * g_cpu_freq;
|
left = elapsed - ts->tv_sec * g_cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "arm64_pmu.h"
|
#include "arm64_pmu.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -58,3 +60,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * cpu_freq;
|
left = elapsed - ts->tv_sec * cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * left / cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * left / cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "hardware/esp32c3_system.h"
|
#include "hardware/esp32c3_system.h"
|
||||||
#include "esp32c3_clockconfig.h"
|
#include "esp32c3_clockconfig.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -82,3 +84,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
elapsed -= ts->tv_sec * CYCLE_PER_SEC;
|
elapsed -= ts->tv_sec * CYCLE_PER_SEC;
|
||||||
ts->tv_nsec = elapsed * NSEC_PER_CYCLE;
|
ts->tv_nsec = elapsed * NSEC_PER_CYCLE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "xtensa_counter.h"
|
#include "xtensa_counter.h"
|
||||||
#include "xtensa.h"
|
#include "xtensa.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_PERF_EVENTS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -61,3 +63,4 @@ void up_perf_convert(unsigned long elapsed, struct timespec *ts)
|
|||||||
left = elapsed - ts->tv_sec * g_cpu_freq;
|
left = elapsed - ts->tv_sec * g_cpu_freq;
|
||||||
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -74,7 +74,6 @@ CONFIG_SYSTEM_SPITOOL=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -77,7 +77,6 @@ CONFIG_TASK_NAME_SIZE=12
|
|||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TESTING_OSTEST=y
|
CONFIG_TESTING_OSTEST=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_TLS_NELEM=4
|
CONFIG_TLS_NELEM=4
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
|
@ -69,7 +69,6 @@ CONFIG_TASK_NAME_SIZE=12
|
|||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TESTING_OSTEST=y
|
CONFIG_TESTING_OSTEST=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -69,7 +69,6 @@ CONFIG_SYSTEM_NSH=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -70,7 +70,6 @@ CONFIG_SYSTEM_NSH=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -67,7 +67,6 @@ CONFIG_SYSTEM_NSH=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -71,7 +71,6 @@ CONFIG_SYSTEM_SPITOOL=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -70,7 +70,6 @@ CONFIG_SYSTEM_NSH=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -75,7 +75,6 @@ CONFIG_SYSTEM_NSH=y
|
|||||||
CONFIG_TASK_NAME_SIZE=12
|
CONFIG_TASK_NAME_SIZE=12
|
||||||
CONFIG_TESTING_GETPRIME=y
|
CONFIG_TESTING_GETPRIME=y
|
||||||
CONFIG_TIMER=y
|
CONFIG_TIMER=y
|
||||||
CONFIG_TIMER_ARCH=y
|
|
||||||
CONFIG_UART0_BAUD=2000000
|
CONFIG_UART0_BAUD=2000000
|
||||||
CONFIG_UART0_RXBUFSIZE=128
|
CONFIG_UART0_RXBUFSIZE=128
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
|
@ -356,13 +356,13 @@ int weak_function up_alarm_tick_start(clock_t ticks)
|
|||||||
* units.
|
* units.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_HAVE_PERF_EVENTS
|
#ifndef CONFIG_ARCH_PERF_EVENTS
|
||||||
void weak_function up_perf_init(FAR void *arg)
|
void up_perf_init(FAR void *arg)
|
||||||
{
|
{
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long weak_function up_perf_gettime(void)
|
unsigned long up_perf_gettime(void)
|
||||||
{
|
{
|
||||||
unsigned long ret = 0;
|
unsigned long ret = 0;
|
||||||
|
|
||||||
@ -377,17 +377,17 @@ unsigned long weak_function up_perf_gettime(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long weak_function up_perf_getfreq(void)
|
unsigned long up_perf_getfreq(void)
|
||||||
{
|
{
|
||||||
return USEC_PER_SEC;
|
return USEC_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void weak_function up_perf_convert(unsigned long elapsed,
|
void up_perf_convert(unsigned long elapsed,
|
||||||
FAR struct timespec *ts)
|
FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
timespec_from_usec(ts, elapsed);
|
timespec_from_usec(ts, elapsed);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ARCH_HAVE_PERF_EVENTS */
|
#endif /* CONFIG_ARCH_PERF_EVENTS */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_mdelay
|
* Name: up_mdelay
|
||||||
|
@ -395,13 +395,13 @@ int weak_function up_timer_tick_start(clock_t ticks)
|
|||||||
* units.
|
* units.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_HAVE_PERF_EVENTS
|
#ifndef CONFIG_ARCH_PERF_EVENTS
|
||||||
void weak_function up_perf_init(FAR void *arg)
|
void up_perf_init(FAR void *arg)
|
||||||
{
|
{
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long weak_function up_perf_gettime(void)
|
unsigned long up_perf_gettime(void)
|
||||||
{
|
{
|
||||||
unsigned long ret = 0;
|
unsigned long ret = 0;
|
||||||
|
|
||||||
@ -413,17 +413,17 @@ unsigned long weak_function up_perf_gettime(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long weak_function up_perf_getfreq(void)
|
unsigned long up_perf_getfreq(void)
|
||||||
{
|
{
|
||||||
return USEC_PER_SEC;
|
return USEC_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void weak_function up_perf_convert(unsigned long elapsed,
|
void up_perf_convert(unsigned long elapsed,
|
||||||
FAR struct timespec *ts)
|
FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
timespec_from_usec(ts, elapsed);
|
timespec_from_usec(ts, elapsed);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ARCH_HAVE_PERF_EVENTS */
|
#endif /* CONFIG_ARCH_PERF_EVENTS */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_mdelay
|
* Name: up_mdelay
|
||||||
|
Loading…
Reference in New Issue
Block a user