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

浏览源代码.

函数

STATIC BOOL OsPerfTimedPeriodValid (UINT32 period)
 
STATIC UINT32 OsPerfTimedStart (VOID)
 
STATIC UINT32 OsPerfTimedConfig (VOID)
 
STATIC UINT32 OsPerfTimedStop (VOID)
 
STATIC VOID OsPerfTimedHandle (VOID)
 
STATIC enum hrtimer_restart OsPerfHrtimer (struct hrtimer *hrtimer)
 
STATIC CHAROsPerfGetEventName (Event *event)
 
UINT32 OsTimedPmuInit (VOID)
 

变量

STATIC SwPmu g_perfTimed
 

函数说明

◆ OsPerfGetEventName()

STATIC CHAR * OsPerfGetEventName ( Event event)

在文件 perf_timed_pmu.c141 行定义.

142{
143 if (event->eventId == PERF_COUNT_CPU_CLOCK) {
144 return "timed";
145 } else {
146 return "unknown";
147 }
148}
@ PERF_COUNT_CPU_CLOCK
Definition: perf.h:85
UINT32 eventId
Definition: los_perf_pri.h:89
这是这个函数的调用关系图:

◆ OsPerfHrtimer()

STATIC enum hrtimer_restart OsPerfHrtimer ( struct hrtimer *  hrtimer)

在文件 perf_timed_pmu.c135 行定义.

136{
137 SMP_CALL_PERF_FUNC(OsPerfTimedHandle); /* send to all cpu to collect data */
138 return HRTIMER_RESTART;
139}
STATIC VOID OsPerfTimedHandle(VOID)
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfTimedConfig()

STATIC UINT32 OsPerfTimedConfig ( VOID  )

在文件 perf_timed_pmu.c74 行定义.

75{
76 UINT32 i;
78 UINT32 eventNum = events->nr;
79
80 for (i = 0; i < eventNum; i++) {
81 Event *event = &(events->per[i]);
82 UINT32 period = event->period;
83 if (event->eventId == PERF_COUNT_CPU_CLOCK) {
84 if (!OsPerfTimedPeriodValid(period)) {
85 period = TIMER_PERIOD_LOWER_BOUND_US;
86 PRINT_ERR("config period invalid, should be >= 100, use default period:%u us\n", period);
87 }
88
89 g_perfTimed.cfgTime = (union ktime) {
90 .tv.sec = period / US_PER_SECOND,
91 .tv.usec = period % US_PER_SECOND
92 };
93 PRINT_INFO("hrtimer config period - sec:%d, usec:%d\n", g_perfTimed.cfgTime.tv.sec,
94 g_perfTimed.cfgTime.tv.usec);
95 return LOS_OK;
96 }
97 }
98 return LOS_NOK;
99}
unsigned int UINT32
Definition: los_typedef.h:57
STATIC SwPmu g_perfTimed
STATIC BOOL OsPerfTimedPeriodValid(UINT32 period)
UINT32 period
Definition: los_perf_pri.h:90
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
union ktime cfgTime
Definition: perf_pmu_pri.h:71
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfTimedHandle()

STATIC VOID OsPerfTimedHandle ( VOID  )

在文件 perf_timed_pmu.c117 行定义.

118{
119 UINT32 index;
120 PerfRegs regs;
121
122 PerfEvent *events = &g_perfTimed.pmu.events;
123 UINT32 eventNum = events->nr;
124
125 (VOID)memset_s(&regs, sizeof(PerfRegs), 0, sizeof(PerfRegs));
126 OsPerfFetchIrqRegs(&regs);
127
128 for (index = 0; index < eventNum; index++) {
129 Event *event = &(events->per[index]);
130 OsPerfUpdateEventCount(event, 1); /* eventCount += 1 every once */
131 OsPerfHandleOverFlow(event, &regs);
132 }
133}
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 OsPerfFetchIrqRegs(PerfRegs *regs)
Definition: los_perf_pri.h:131
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfTimedPeriodValid()

STATIC BOOL OsPerfTimedPeriodValid ( UINT32  period)

在文件 perf_timed_pmu.c39 行定义.

40{
41 return period >= TIMER_PERIOD_LOWER_BOUND_US;
42}
这是这个函数的调用关系图:

◆ OsPerfTimedStart()

STATIC UINT32 OsPerfTimedStart ( VOID  )

在文件 perf_timed_pmu.c44 行定义.

45{
46 UINT32 i;
47 UINT32 cpuid = ArchCurrCpuid();
49 UINT32 eventNum = events->nr;
50
51 for (i = 0; i < eventNum; i++) {
52 Event *event = &(events->per[i]);
53 event->count[cpuid] = 0;
54 }
55
56 if (cpuid != 0) { /* only need start on one core */
57 return LOS_OK;
58 }
59
60 if (hrtimer_start(&g_perfTimed.hrtimer, g_perfTimed.time, HRTIMER_MODE_REL) != 0) {
61 PRINT_ERR("Hrtimer start failed\n");
62 return LOS_NOK;
63 }
64
65 if (hrtimer_forward(&g_perfTimed.hrtimer, g_perfTimed.cfgTime) == 0) {
66 PRINT_ERR("Hrtimer forward failed\n");
67 return LOS_NOK;
68 }
69
71 return LOS_OK;
72}
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
UINT64 count[LOSCFG_KERNEL_CORE_NUM]
Definition: los_perf_pri.h:91
struct hrtimer hrtimer
Definition: perf_pmu_pri.h:69
union ktime time
Definition: perf_pmu_pri.h:70
函数调用图:
这是这个函数的调用关系图:

◆ OsPerfTimedStop()

STATIC UINT32 OsPerfTimedStop ( VOID  )

在文件 perf_timed_pmu.c101 行定义.

102{
103 UINT32 ret;
104
105 if (ArchCurrCpuid() != 0) { /* only need stop on one core */
106 return LOS_OK;
107 }
108
109 ret = hrtimer_cancel(&g_perfTimed.hrtimer);
110 if (ret != 1) {
111 PRINT_ERR("Hrtimer stop failed!, 0x%x\n", ret);
112 return LOS_NOK;
113 }
114 return LOS_OK;
115}
函数调用图:
这是这个函数的调用关系图:

◆ OsTimedPmuInit()

UINT32 OsTimedPmuInit ( VOID  )

在文件 perf_timed_pmu.c150 行定义.

151{
152 UINT32 ret;
153
154 g_perfTimed.time = (union ktime) {
155 .tv.sec = 0,
156 .tv.usec = HRTIMER_DEFAULT_PERIOD_US,
157 };
158
159 hrtimer_init(&g_perfTimed.hrtimer, 1, HRTIMER_MODE_REL);
160
161 ret = hrtimer_create(&g_perfTimed.hrtimer, g_perfTimed.time, OsPerfHrtimer);
162 if (ret != LOS_OK) {
163 return ret;
164 }
165
166 g_perfTimed.pmu = (Pmu) {
168 .config = OsPerfTimedConfig,
169 .start = OsPerfTimedStart,
170 .stop = OsPerfTimedStop,
171 .getName = OsPerfGetEventName,
172 };
173
174 (VOID)memset_s(&g_perfTimed.pmu.events, sizeof(PerfEvent), 0, sizeof(PerfEvent));
176 return ret;
177}
@ PERF_EVENT_TYPE_TIMED
Definition: perf.h:58
UINT32 OsPerfPmuRegister(Pmu *pmu)
Definition: perf_pmu.c:36
STATIC enum hrtimer_restart OsPerfHrtimer(struct hrtimer *hrtimer)
STATIC UINT32 OsPerfTimedConfig(VOID)
STATIC UINT32 OsPerfTimedStop(VOID)
STATIC UINT32 OsPerfTimedStart(VOID)
STATIC CHAR * OsPerfGetEventName(Event *event)
enum PerfEventType type
Definition: los_perf_pri.h:101
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_perfTimed

STATIC SwPmu g_perfTimed

在文件 perf_timed_pmu.c37 行定义.