WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_perf_pri.h
浏览该文件的文档.
1/*----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2017-2020. All rights reserved.
3 * Description: LiteOS Performance Monitor Module Implementation
4 * Author: Huawei LiteOS Team
5 * Create: 2017-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *---------------------------------------------------------------------------*/
28
29#ifndef _LOS_PERF_PRI_H
30#define _LOS_PERF_PRI_H
31
32#include "los_perf.h"
33#include "arch/perf.h"
34#include "los_mp_pri.h"
35#include "los_task_pri.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif /* __cplusplus */
40
41#define OS_MIN(x, y) (((x) <= (y)) ? (x) : (y))
42
43#define PERF_EVENT_TO_CODE 0
44#define PERF_CODE_TO_EVENT 1
45#define PERF_DATA_MAGIC_WORD 0xEFEFEF00
46
47#define SMP_CALL_PERF_FUNC(func) OsMpFuncCall(OS_MP_CPU_ALL, (SMP_FUNC_CALL)func, NULL)
48
53
54typedef struct {
57} PerfRegs;
58
63
64typedef struct {
65 UINT32 cpuid; /* cpu id */
66 UINT32 taskId; /* task id */
67 UINT32 eventId; /* record type */
68 UINT32 period; /* record period */
69 UINT64 time; /* record time */
70 UINTPTR pc; /* instruction pointer */
71 PerfBackTrace callChain; /* number of callChain ips */
73
74typedef struct {
75 UINT32 magic; /* magic number */
76 UINT32 eventType; /* enum PerfEventType */
77 UINT32 len; /* sample data file length */
78 UINT32 sampleType; /* IP | TID | TIMESTAMP... */
79 UINT32 sectionId; /* section id */
81
82typedef struct {
87#ifdef LOSCFG_ARCH_RISCV32
88 UINT64 prevOverflowCount;
89#endif
91} Event;
92
98
99typedef struct {
102
103 /* Parse user config to initialize events. */
104 UINT32 (*config)(PerfEvent *events, const PerfEventConfig *config);
105 /* Start pmu on current core.
106 * If restart is true, pmu shall in intial state after started, and resources shall initialized.
107 */
108 UINT32 (*start)(PerfEvent *events, BOOL restart);
109 /* Stop pmu on current core and update event counts.
110 * If update is true, pmu shall in final state after stoped, and resources can be released.
111 * Whether update is used, the event counts shall always updated.
112 */
113 UINT32 (*stop)(PerfEvent *events, BOOL update);
114 /* convert event to name */
115 CHAR *(*getName)(Event *event);
116} Pmu;
117
118typedef struct {
119 /* time info */
122
123 /* instrumentation status */
125 enum PmuStatus pmuStatusPerCpu[LOSCFG_KERNEL_CORE_NUM];
126
127 /* configuration info */
133} PerfCB;
134
135#ifndef OsPerfArchFetchIrqRegs
137{
138 (VOID)regs;
139 (VOID)curTask;
140}
141#endif
142
144{
145 LosTaskCB *curTask = OsCurrTaskGet();
146 OsPerfArchFetchIrqRegs(regs, curTask);
147 PRINT_DEBUG("pc = 0x%x, fp = 0x%x\n", regs->pc, regs->fp);
148}
149
150#ifndef OsPerfArchFetchCallerRegs
155#endif
156
158{
160 PRINT_DEBUG("pc = 0x%x, fp = 0x%x\n", regs->pc, regs->fp);
161}
162
169extern VOID OsPerfTaskSwitch(LosTaskCB *runTask, LosTaskCB *newTask);
170extern VOID *OsPerfIrqEnter(UINT32 hwiNum);
171extern VOID OsPerfIrqExit(UINT32 hwiNum, VOID *state);
174
175#ifdef __cplusplus
176}
177#endif /* __cplusplus */
178
179#endif /* _LOS_PERF_PRI_H */
#define STATIC
Definition common_def.h:57
#define INLINE
Definition common_def.h:65
#define LOSCFG_KERNEL_CORE_NUM
Definition los_config.h:258
PerfEventType
Definition los_perf.h:197
#define PERF_MAX_EVENT
Definition los_perf.h:53
#define PERF_MAX_FILTER_TSKS
Definition los_perf.h:47
#define PERF_MAX_CALLCHAIN_DEPTH
Definition los_perf.h:59
PerfStatus
Definition los_perf.h:71
#define PRINT_DEBUG(fmt,...)
Format and print debug log.
Definition los_printf.h:146
VOID OsPerfHwReadAllCounter(PerfEvent *events)
VOID OsPerfTaskSwitch(LosTaskCB *runTask, LosTaskCB *newTask)
PmuStatus
Definition los_perf_pri.h:49
@ PERF_PMU_STOPED
Definition los_perf_pri.h:50
@ PERF_PMU_STARTED
Definition los_perf_pri.h:51
STATIC INLINE VOID OsPerfFetchIrqRegs(PerfRegs *regs)
Definition los_perf_pri.h:143
VOID OsPerfTaskCreate(LosTaskCB *taskCB)
VOID * OsPerfIrqEnter(UINT32 hwiNum)
STATIC INLINE VOID OsPerfFetchCallerRegs(PerfRegs *regs)
Definition los_perf_pri.h:157
PerfEvent * OsPerfIrqEventsGet(UINT32 cpuId)
PerfEvent * OsPerfTaskEventsGet(UINT32 taskId)
VOID OsPerfTaskDelete(LosTaskCB *taskCB)
VOID OsPerfIrqExit(UINT32 hwiNum, VOID *state)
VOID OsPerfHandleOverFlow(Event *event, PerfRegs *regs)
VOID OsPerfUpdateEventCount(Event *event, UINT32 value)
STATIC INLINE VOID OsPerfArchFetchCallerRegs(PerfRegs *regs)
Definition los_perf_pri.h:151
VOID OsPerfSetIrqRegs(UINTPTR pc, UINTPTR fp)
STATIC INLINE VOID OsPerfArchFetchIrqRegs(PerfRegs *regs, LosTaskCB *curTask)
Definition los_perf_pri.h:136
STATIC INLINE LosTaskCB * OsCurrTaskGet(VOID)
Definition los_task_pri.h:118
unsigned long long UINT64
Definition los_typedef.h:72
#define VOID
Definition los_typedef.h:88
unsigned char UINT8
Definition los_typedef.h:50
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
size_t BOOL
Definition los_typedef.h:83
Definition los_perf_pri.h:82
UINT64 prevCount
Definition los_perf_pri.h:86
UINT64 count
Definition los_perf_pri.h:90
UINT32 counter
Definition los_perf_pri.h:83
UINT32 period
Definition los_perf_pri.h:85
UINT32 eventId
Definition los_perf_pri.h:84
Definition los_perf_pri.h:59
UINT32 ipNr
Definition los_perf_pri.h:60
Definition los_perf_pri.h:118
UINT8 taskIdsNr
Definition los_perf_pri.h:130
UINT8 taskFilterEnable
Definition los_perf_pri.h:132
enum PerfStatus status
Definition los_perf_pri.h:124
UINT64 endTime
Definition los_perf_pri.h:121
UINT64 startTime
Definition los_perf_pri.h:120
UINT32 sampleType
Definition los_perf_pri.h:128
UINT8 needSample
Definition los_perf_pri.h:131
Definition los_perf_pri.h:74
UINT32 len
Definition los_perf_pri.h:77
UINT32 sampleType
Definition los_perf_pri.h:78
UINT32 eventType
Definition los_perf_pri.h:76
UINT32 magic
Definition los_perf_pri.h:75
UINT32 sectionId
Definition los_perf_pri.h:79
Definition los_perf.h:265
Definition los_perf_pri.h:93
UINT8 nr
Definition los_perf_pri.h:95
UINT8 cntDivided
Definition los_perf_pri.h:96
Definition los_perf_pri.h:54
UINTPTR fp
Definition los_perf_pri.h:56
UINTPTR pc
Definition los_perf_pri.h:55
Definition los_perf_pri.h:64
UINT32 taskId
Definition los_perf_pri.h:66
PerfBackTrace callChain
Definition los_perf_pri.h:71
UINT64 time
Definition los_perf_pri.h:69
UINT32 eventId
Definition los_perf_pri.h:67
UINT32 period
Definition los_perf_pri.h:68
UINT32 cpuid
Definition los_perf_pri.h:65
UINTPTR pc
Definition los_perf_pri.h:70
Definition los_perf_pri.h:99
UINT32(* config)(PerfEvent *events, const PerfEventConfig *config)
Definition los_perf_pri.h:104
enum PerfEventType type
Definition los_perf_pri.h:100
Definition los_task_base.h:131