WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Perf
Perf 的协作图:

结构体

struct  PerfEventConfig
 
struct  PerfConfigAttr
 

宏定义

#define PERF_MAX_FILTER_TSKS   32
 
#define PERF_MAX_EVENT   7
 
#define PERF_MAX_CALLCHAIN_DEPTH   10
 
#define PERF_BUFFER_WATERMARK_ONE_N   2
 
#define LOS_ERRNO_PERF_STATUS_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x00)
 
#define LOS_ERRNO_PERF_HW_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x01)
 
#define LOS_ERRNO_PERF_TIMED_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x02)
 
#define LOS_ERRNO_PERF_SW_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x03)
 
#define LOS_ERRNO_PERF_BUF_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x04)
 
#define LOS_ERRNO_PERF_INVALID_PMU   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x05)
 
#define LOS_ERRNO_PERF_PMU_CONFIG_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x06)
 
#define LOS_ERRNO_PERF_CONFIG_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x07)
 
#define LOS_ERRNO_PERF_CONFIG_TASK_FILTER_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x08)
 
#define LOS_ERRNO_PERF_INIT_NO_MEMERY   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x09)
 

类型定义

typedef void(* PERF_BUF_NOTIFY_HOOK) (void)
 
typedef void(* PERF_BUF_FLUSH_HOOK) (void *addr, UINT32 size)
 

枚举

enum  PerfStatus {
  PERF_UNINIT , PERF_STARTING , PERF_STARTED , PERF_STOPPING ,
  PERF_STOPED
}
 
enum  PerfEventType {
  PERF_EVENT_TYPE_HW , PERF_EVENT_TYPE_TIMED , PERF_EVENT_TYPE_SW , PERF_EVENT_TYPE_RAW ,
  PERF_EVENT_TYPE_MAX
}
 
enum  PmuHwId {
  PERF_COUNT_HW_CPU_CYCLES = 0 , PERF_COUNT_HW_INSTRUCTIONS , PERF_COUNT_HW_DCACHE_REFERENCES , PERF_COUNT_HW_DCACHE_MISSES ,
  PERF_COUNT_HW_ICACHE_REFERENCES , PERF_COUNT_HW_ICACHE_MISSES , PERF_COUNT_HW_BRANCH_INSTRUCTIONS , PERF_COUNT_HW_BRANCH_MISSES ,
  PERF_COUNT_HW_MAX
}
 
enum  PmuTimedId { PERF_COUNT_CPU_CLOCK = 0 }
 
enum  PmuSwId {
  PERF_COUNT_SW_TASK_SWITCH = 1 , PERF_COUNT_SW_IRQ_RESPONSE , PERF_COUNT_SW_MEM_ALLOC , PERF_COUNT_SW_MUX_PEND ,
  PERF_COUNT_SW_MAX
}
 
enum  PerfSampleType {
  PERF_RECORD_CPU = 1U << 0 , PERF_RECORD_TID = 1U << 1 , PERF_RECORD_TYPE = 1U << 2 , PERF_RECORD_PERIOD = 1U << 3 ,
  PERF_RECORD_TIMESTAMP = 1U << 4 , PERF_RECORD_IP = 1U << 5 , PERF_RECORD_CALLCHAIN = 1U << 6
}
 

函数

UINT32 LOS_PerfInit (void *buf, UINT32 size)
 Init perf.
 
void LOS_PerfStart (UINT32 sectionId)
 Start perf sampling.
 
void LOS_PerfStop (void)
 Stop perf sampling.
 
UINT32 LOS_PerfConfig (PerfConfigAttr *attr)
 Config perf parameters.
 
UINT32 LOS_PerfDataRead (CHAR *dest, UINT32 size)
 Read data from perf sample data buffer.
 
void LOS_PerfNotifyHookReg (const PERF_BUF_NOTIFY_HOOK func)
 Register perf sample data buffer water mark hook function.
 
void LOS_PerfFlushHookReg (const PERF_BUF_FLUSH_HOOK func)
 Register perf sample data buffer flush hook function.
 
UINT32 LOS_PerfDeinit (void)
 Deinit perf.
 

详细描述

宏定义说明

◆ LOS_ERRNO_PERF_BUF_ERROR

#define LOS_ERRNO_PERF_BUF_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x04)

Perf error code: Perf buffer init failed.

Value: 0x02002004

Solution: Check the buffer init size.

◆ LOS_ERRNO_PERF_CONFIG_NULL

#define LOS_ERRNO_PERF_CONFIG_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x07)

Perf error code: Perf pmu config attr is null.

Value: 0x02002007

Solution: Check if the input params of attr is null.

◆ LOS_ERRNO_PERF_CONFIG_TASK_FILTER_ERROR

#define LOS_ERRNO_PERF_CONFIG_TASK_FILTER_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x08)

Perf error code: Perf pmu config memcpy_s failed.

Value: 0x02002008

Solution: Check the validity of the memcpy_s parameter.

◆ LOS_ERRNO_PERF_HW_INIT_ERROR

#define LOS_ERRNO_PERF_HW_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x01)

Perf error code: Hardware pmu init failed.

Value: 0x02002001

Solution: Check the pmu hwi irq.

◆ LOS_ERRNO_PERF_INIT_NO_MEMERY

#define LOS_ERRNO_PERF_INIT_NO_MEMERY   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x09)

Perf error code: Perf init failed due to no memory.

Value: 0x02002009

Solution: Check system memory usage or disable perf per-task mode to reduce memory usage.

◆ LOS_ERRNO_PERF_INVALID_PMU

#define LOS_ERRNO_PERF_INVALID_PMU   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x05)

Perf error code: Perf pmu type error.

Value: 0x02002005

Solution: Check whether the corresponding pmu is enabled in the menuconfig.

◆ LOS_ERRNO_PERF_PMU_CONFIG_ERROR

#define LOS_ERRNO_PERF_PMU_CONFIG_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x06)

Perf error code: Perf pmu config error.

Value: 0x02002006

Solution: Check the config attr of event id and event period and event number.

◆ LOS_ERRNO_PERF_STATUS_INVALID

#define LOS_ERRNO_PERF_STATUS_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x00)

Perf error code: Bad status.

Value: 0x02002000

Solution: Follow the perf state machine.

◆ LOS_ERRNO_PERF_SW_INIT_ERROR

#define LOS_ERRNO_PERF_SW_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x03)

Perf error code: Software pmu init failed.

Value: 0x02002003

Solution: Check the Perf software events init.

◆ LOS_ERRNO_PERF_TIMED_INIT_ERROR

#define LOS_ERRNO_PERF_TIMED_INIT_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x02)

Perf error code: Hrtimer init failed for hrtimer timed pmu init.

Value: 0x02002002

Solution: Check the Hrtimer init.

◆ PERF_BUFFER_WATERMARK_ONE_N

#define PERF_BUFFER_WATERMARK_ONE_N   2

Perf sample data buffer's water mark 1/N.

◆ PERF_MAX_CALLCHAIN_DEPTH

#define PERF_MAX_CALLCHAIN_DEPTH   10

Perf max backtrace depth.

◆ PERF_MAX_EVENT

#define PERF_MAX_EVENT   7

Perf max sample event counter's number.

◆ PERF_MAX_FILTER_TSKS

#define PERF_MAX_FILTER_TSKS   32

Perf max sample filter task number.

类型定义说明

◆ PERF_BUF_FLUSH_HOOK

typedef void(* PERF_BUF_FLUSH_HOOK) (void *addr, UINT32 size)

Define the type of the perf sample data buffer flush hook function.

◆ PERF_BUF_NOTIFY_HOOK

typedef void(* PERF_BUF_NOTIFY_HOOK) (void)

Define the type of the perf sample data buffer water mark hook function.

枚举类型说明

◆ PerfEventType

Perf types

枚举值
PERF_EVENT_TYPE_HW 

boards common hw events

PERF_EVENT_TYPE_TIMED 

hrtimer timed events

PERF_EVENT_TYPE_SW 

software trace events

PERF_EVENT_TYPE_RAW 

boards special hw events, see enum PmuEventType in corresponding arch headfile

PERF_EVENT_TYPE_MAX 

◆ PerfSampleType

perf sample data types Config it through PerfConfigAttr->sampleType.

枚举值
PERF_RECORD_CPU 

record current cpuid

PERF_RECORD_TID 

record current task id

PERF_RECORD_TYPE 

record event type

PERF_RECORD_PERIOD 

record event period

PERF_RECORD_TIMESTAMP 

record timestamp

PERF_RECORD_IP 

record instruction pointer

PERF_RECORD_CALLCHAIN 

record backtrace

◆ PerfStatus

enum PerfStatus

Perf state.

枚举值
PERF_UNINIT 

perf isn't inited

PERF_STARTING 

perf is starting process

PERF_STARTED 

perf is started

PERF_STOPPING 

perf in stopping process

PERF_STOPED 

perf is stopped

◆ PmuHwId

enum PmuHwId

Common hardware pmu events

枚举值
PERF_COUNT_HW_CPU_CYCLES 

cpu cycle event

PERF_COUNT_HW_INSTRUCTIONS 

instruction event

PERF_COUNT_HW_DCACHE_REFERENCES 

dcache access event

PERF_COUNT_HW_DCACHE_MISSES 

dcache miss event

PERF_COUNT_HW_ICACHE_REFERENCES 

icache access event

PERF_COUNT_HW_ICACHE_MISSES 

icache miss event

PERF_COUNT_HW_BRANCH_INSTRUCTIONS 

software change of pc event

PERF_COUNT_HW_BRANCH_MISSES 

branch miss event

PERF_COUNT_HW_MAX 

◆ PmuSwId

enum PmuSwId

Common software pmu events

枚举值
PERF_COUNT_SW_TASK_SWITCH 

task switch event

PERF_COUNT_SW_IRQ_RESPONSE 

irq response event

PERF_COUNT_SW_MEM_ALLOC 

memory alloc event

PERF_COUNT_SW_MUX_PEND 

mutex pend event

PERF_COUNT_SW_MAX 

◆ PmuTimedId

enum PmuTimedId

Common hrtimer timed events

枚举值
PERF_COUNT_CPU_CLOCK 

hrtimer timed event

函数说明

◆ LOS_PerfConfig()

UINT32 LOS_PerfConfig ( PerfConfigAttr attr)

Config perf parameters.

Description
Config perf parameters before sample, for example, sample event, sample task, etc. it need to be called before LOS_PerfStart.
注意
None.
参数
attr[IN] Address of a perf event attr struct.
返回值
LOS_ERRNO_PERF_STATUS_INVALIDPerf in a wrong status.
LOS_ERRNO_PERF_CONFIG_NULLAttr is null.
LOS_ERRNO_PERF_INVALID_PMUConfig perf pmu with error type.
LOS_ERRNO_PERF_PMU_CONFIG_ERRORConfig perf events fail with invalid event id, event period or event number.
LOS_ERRNO_PERF_CONFIG_TASK_FILTER_ERRORConfig perf task filter fail with parameters invalid.
LOS_OKConfig success.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfDataRead()

UINT32 LOS_PerfDataRead ( CHAR dest,
UINT32  size 
)

Read data from perf sample data buffer.

Description
Because perf sample data buffer is a ringbuffer, the data may be covered after user read ringbuffer.
注意
None.
参数
dest[IN] The destination address.
size[IN] Read size.
返回值
UINT32The really read bytes.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfDeinit()

UINT32 LOS_PerfDeinit ( void  )

Deinit perf.

Description:
  • Used to deinit the perf module, including deinitializing the PMU etc., which is called during the phase of no longer used the module, or want to reinitialize Perf.
注意
  • Perf can be deinitialized only when it is stopped.
参数
None.
返回值
LOS_ERRNO_PERF_STATUS_INVALIDPerf in a wrong status.
LOS_OKPerf Deinit success.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS 207.0.0

◆ LOS_PerfFlushHookReg()

void LOS_PerfFlushHookReg ( const PERF_BUF_FLUSH_HOOK  func)

Register perf sample data buffer flush hook function.

Description
  • Register perf sample data buffer flush hook function.
  • The flush hook will be called when the buffer be read or written.
注意
None.
参数
func[IN] Buffer flush hook function.
返回值
None.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfInit()

UINT32 LOS_PerfInit ( void *  buf,
UINT32  size 
)

Init perf.

Description:
  • Used to initialize the perf module, including initializing the PMU, initializing the output buf, etc.,which is called by user.
注意
  • user must ensure buf is not null and size is the same as buf's length. Otherwise, Perf init will fail.
参数
buf[IN] Pointer of sample data buffer; The validity of the buffer is guaranteed by the user.
size[IN] Length of sample data buffer;
返回值
LOS_ERRNO_PERF_STATUS_INVALIDPerf in a wrong status.
LOS_ERRNO_PERF_HW_INIT_ERRORPerf hardware pmu init fail.
LOS_ERRNO_PERF_TIMED_INIT_ERRORPerf timed pmu init fail.
LOS_ERRNO_PERF_SW_INIT_ERRORPerf software pmu init fail.
LOS_ERRNO_PERF_BUF_ERRORPerf buffer init fail.
LOS_OKPerf init success.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfNotifyHookReg()

void LOS_PerfNotifyHookReg ( const PERF_BUF_NOTIFY_HOOK  func)

Register perf sample data buffer water mark hook function.

Description
  • Register perf sample data buffer water mark hook function.
  • The registered hook will be called when buffer reaches the water mark./li>
注意
None.
参数
func[IN] Buffer water mark hook function.
返回值
None.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfStart()

void LOS_PerfStart ( UINT32  sectionId)

Start perf sampling.

Description
Start perf sampling.
注意
None.
参数
sectionId[IN] Set the section id for marking this piece of data in the perf sample data buffer.
返回值
None.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

◆ LOS_PerfStop()

void LOS_PerfStop ( void  )

Stop perf sampling.

Description
Stop perf sampling.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_perf.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00