更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
perf_sw_pmu.c 文件参考

浏览源代码.

函数

VOID OsPerfHook (UINT32 eventType)
 
STATIC VOID LOS_PerfMemAlloc (VOID *pool, VOID *ptr, UINT32 size)
 
STATIC VOID LOS_PerfMuxPend (const LosMux *muxCB, UINT32 timeout)
 
STATIC VOID LOS_PerfIsrEnter (UINT32 hwiNum)
 
STATIC VOID LOS_PerfTaskSwitchedIn (const LosTaskCB *newTask, const LosTaskCB *runTask)
 
STATIC VOID OsPerfCnvInit (VOID)
 
STATIC UINT32 OsPerfSwConfig (VOID)
 
STATIC UINT32 OsPerfSwStart (VOID)
 
STATIC UINT32 OsPerfSwStop (VOID)
 
STATIC CHAROsPerfGetEventName (Event *event)
 
UINT32 OsSwPmuInit (VOID)
 

变量

STATIC SwPmu g_perfSw
 
STATIC CHARg_eventName [PERF_COUNT_SW_MAX]
 
STATIC UINT32 g_traceEventMap [PERF_COUNT_SW_MAX]
 

函数说明

◆ LOS_PerfIsrEnter()

STATIC VOID LOS_PerfIsrEnter ( UINT32  hwiNum)

在文件 perf_sw_pmu.c87 行定义.

88{
89 OsPerfHook(LOS_HOOK_TYPE_ISR_ENTER);
90}
VOID OsPerfHook(UINT32 eventType)
Definition: perf_sw_pmu.c:50
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PerfMemAlloc()

STATIC VOID LOS_PerfMemAlloc ( VOID *  pool,
VOID *  ptr,
UINT32  size 
)

在文件 perf_sw_pmu.c77 行定义.

78{
79 OsPerfHook(LOS_HOOK_TYPE_MEM_ALLOC);
80}
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PerfMuxPend()

STATIC VOID LOS_PerfMuxPend ( const LosMux muxCB,
UINT32  timeout 
)

在文件 perf_sw_pmu.c82 行定义.

83{
84 OsPerfHook(LOS_HOOK_TYPE_MUX_PEND);
85}
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PerfTaskSwitchedIn()

STATIC VOID LOS_PerfTaskSwitchedIn ( const LosTaskCB newTask,
const LosTaskCB runTask 
)

在文件 perf_sw_pmu.c92 行定义.

93{
94 OsPerfHook(LOS_HOOK_TYPE_TASK_SWITCHEDIN);
95}
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfCnvInit()

STATIC VOID OsPerfCnvInit ( VOID  )

在文件 perf_sw_pmu.c97 行定义.

98{
99 LOS_HookReg(LOS_HOOK_TYPE_MEM_ALLOC, LOS_PerfMemAlloc);
100 LOS_HookReg(LOS_HOOK_TYPE_MUX_PEND, LOS_PerfMuxPend);
101 LOS_HookReg(LOS_HOOK_TYPE_ISR_ENTER, LOS_PerfIsrEnter);
102 LOS_HookReg(LOS_HOOK_TYPE_TASK_SWITCHEDIN, LOS_PerfTaskSwitchedIn);
103}
STATIC VOID LOS_PerfTaskSwitchedIn(const LosTaskCB *newTask, const LosTaskCB *runTask)
Definition: perf_sw_pmu.c:92
STATIC VOID LOS_PerfMuxPend(const LosMux *muxCB, UINT32 timeout)
Definition: perf_sw_pmu.c:82
STATIC VOID LOS_PerfMemAlloc(VOID *pool, VOID *ptr, UINT32 size)
Definition: perf_sw_pmu.c:77
STATIC VOID LOS_PerfIsrEnter(UINT32 hwiNum)
Definition: perf_sw_pmu.c:87
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfGetEventName()

STATIC CHAR * OsPerfGetEventName ( Event event)

在文件 perf_sw_pmu.c144 行定义.

145{
146 UINT32 eventId = event->eventId;
147 if (eventId < PERF_COUNT_SW_MAX) {
148 return g_eventName[eventId];
149 }
150 return "unknown";
151}
@ PERF_COUNT_SW_MAX
Definition: perf.h:97
unsigned int UINT32
Definition: los_typedef.h:57
STATIC CHAR * g_eventName[PERF_COUNT_SW_MAX]
Definition: perf_sw_pmu.c:36
这是这个函数的调用关系图:

◆ OsPerfHook()

VOID OsPerfHook ( UINT32  eventType)

在文件 perf_sw_pmu.c50 行定义.

51{
52 if (!g_perfSw.enable) {
53 return;
54 }
55
56 PerfEvent *events = &g_perfSw.pmu.events;
57 UINT32 eventNum = events->nr;
58
59 UINT32 i;
60 PerfRegs regs;
61
62 (VOID)memset_s(&regs, sizeof(PerfRegs), 0, sizeof(PerfRegs));
63
64 for (i = 0; i < eventNum; i++) {
65 Event *event = &(events->per[i]);
66 if (event->counter == eventType) {
67 OsPerfUpdateEventCount(event, 1);
68 if (event->count[ArchCurrCpuid()] % event->period == 0) {
70 OsPerfHandleOverFlow(event, &regs);
71 }
72 return;
73 }
74 }
75}
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
VOID OsPerfHandleOverFlow(Event *event, PerfRegs *regs)
Definition: los_perf.c:350
VOID OsPerfUpdateEventCount(Event *event, UINT32 value)
Definition: los_perf.c:342
STATIC INLINE VOID OsPerfFetchCallerRegs(PerfRegs *regs)
Definition: los_perf_pri.h:142
STATIC SwPmu g_perfSw
Definition: perf_sw_pmu.c:35
UINT8 nr
Definition: los_perf_pri.h:96
Event per[PERF_MAX_EVENT]
Definition: los_perf_pri.h:95
PerfEvent events
Definition: los_perf_pri.h:102
Pmu pmu
Definition: perf_pmu_pri.h:62
BOOL enable
Definition: perf_pmu_pri.h:65
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfSwConfig()

STATIC UINT32 OsPerfSwConfig ( VOID  )

在文件 perf_sw_pmu.c105 行定义.

106{
107 UINT32 i;
108 PerfEvent *events = &g_perfSw.pmu.events;
109 UINT32 eventNum = events->nr;
110
111 for (i = 0; i < eventNum; i++) {
112 Event *event = &(events->per[i]);
113 if ((event->eventId < PERF_COUNT_SW_TASK_SWITCH) || (event->eventId >= PERF_COUNT_SW_MAX) ||
114 (event->period == 0)) {
115 return LOS_NOK;
116 }
117 event->counter = g_traceEventMap[event->eventId];
118 }
119 return LOS_OK;
120}
@ PERF_COUNT_SW_TASK_SWITCH
Definition: perf.h:92
STATIC UINT32 g_traceEventMap[PERF_COUNT_SW_MAX]
Definition: perf_sw_pmu.c:43
UINT32 counter
Definition: los_perf_pri.h:88
这是这个函数的调用关系图:

◆ OsPerfSwStart()

STATIC UINT32 OsPerfSwStart ( VOID  )

在文件 perf_sw_pmu.c122 行定义.

123{
124 UINT32 i;
125 UINT32 cpuid = ArchCurrCpuid();
126 PerfEvent *events = &g_perfSw.pmu.events;
127 UINT32 eventNum = events->nr;
128
129 for (i = 0; i < eventNum; i++) {
130 Event *event = &(events->per[i]);
131 event->count[cpuid] = 0;
132 }
133
134 g_perfSw.enable = TRUE;
135 return LOS_OK;
136}
UINT64 count[LOSCFG_KERNEL_CORE_NUM]
Definition: los_perf_pri.h:91
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfSwStop()

STATIC UINT32 OsPerfSwStop ( VOID  )

在文件 perf_sw_pmu.c138 行定义.

139{
140 g_perfSw.enable = FALSE;
141 return LOS_OK;
142}
这是这个函数的调用关系图:

◆ OsSwPmuInit()

UINT32 OsSwPmuInit ( VOID  )

在文件 perf_sw_pmu.c153 行定义.

154{
155 g_perfSw.pmu = (Pmu) {
157 .config = OsPerfSwConfig,
158 .start = OsPerfSwStart,
159 .stop = OsPerfSwStop,
160 .getName = OsPerfGetEventName,
161 };
162
163 g_perfSw.enable = FALSE;
164
166
167 (VOID)memset_s(&g_perfSw.pmu.events, sizeof(PerfEvent), 0, sizeof(PerfEvent));
169}
@ PERF_EVENT_TYPE_SW
Definition: perf.h:59
UINT32 OsPerfPmuRegister(Pmu *pmu)
Definition: perf_pmu.c:36
STATIC VOID OsPerfCnvInit(VOID)
Definition: perf_sw_pmu.c:97
STATIC UINT32 OsPerfSwStop(VOID)
Definition: perf_sw_pmu.c:138
STATIC UINT32 OsPerfSwConfig(VOID)
Definition: perf_sw_pmu.c:105
STATIC CHAR * OsPerfGetEventName(Event *event)
Definition: perf_sw_pmu.c:144
STATIC UINT32 OsPerfSwStart(VOID)
Definition: perf_sw_pmu.c:122
enum PerfEventType type
Definition: los_perf_pri.h:101
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_eventName

STATIC CHAR* g_eventName[PERF_COUNT_SW_MAX]
初始值:
= {
[PERF_COUNT_SW_TASK_SWITCH] = "task switch",
[PERF_COUNT_SW_IRQ_RESPONSE] = "irq response",
[PERF_COUNT_SW_MEM_ALLOC] = "mem alloc",
[PERF_COUNT_SW_MUX_PEND] = "mux pend",
}
@ PERF_COUNT_SW_IRQ_RESPONSE
Definition: perf.h:93
@ PERF_COUNT_SW_MUX_PEND
Definition: perf.h:95
@ PERF_COUNT_SW_MEM_ALLOC
Definition: perf.h:94

在文件 perf_sw_pmu.c36 行定义.

◆ g_perfSw

STATIC SwPmu g_perfSw

在文件 perf_sw_pmu.c35 行定义.

◆ g_traceEventMap

STATIC UINT32 g_traceEventMap[PERF_COUNT_SW_MAX]
初始值:
= {
[PERF_COUNT_SW_TASK_SWITCH] = LOS_HOOK_TYPE_TASK_SWITCHEDIN,
[PERF_COUNT_SW_IRQ_RESPONSE] = LOS_HOOK_TYPE_ISR_ENTER,
[PERF_COUNT_SW_MEM_ALLOC] = LOS_HOOK_TYPE_MEM_ALLOC,
[PERF_COUNT_SW_MUX_PEND] = LOS_HOOK_TYPE_MUX_PEND,
}

在文件 perf_sw_pmu.c43 行定义.