更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
perf_list.c
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <stdio.h>
33#include "perf.h"
34#include "perf_list.h"
35
36static const char *g_eventTypeStr[] = {
37 "[Hardware event]",
38 "[Timed event]",
39 "[Software event]",
40};
41
43#ifdef LOSCFG_PERF_HW_PMU
44 {
45 .name = "cycles",
47 .type = PERF_EVENT_TYPE_HW,
48 },
49 {
50 .name = "instruction",
52 .type = PERF_EVENT_TYPE_HW,
53 },
54 {
55 .name = "dcache",
57 .type = PERF_EVENT_TYPE_HW,
58 },
59 {
60 .name = "dcache-miss",
62 .type = PERF_EVENT_TYPE_HW,
63 },
64 {
65 .name = "icache",
67 .type = PERF_EVENT_TYPE_HW,
68 },
69 {
70 .name = "icache-miss",
72 .type = PERF_EVENT_TYPE_HW,
73 },
74 {
75 .name = "branch",
77 .type = PERF_EVENT_TYPE_HW,
78 },
79 {
80 .name = "branch-miss",
82 .type = PERF_EVENT_TYPE_HW,
83 },
84#endif
85#ifdef LOSCFG_PERF_TIMED_PMU
86 {
87 .name = "clock",
88 .event = PERF_COUNT_CPU_CLOCK,
90 },
91#endif
92#ifdef LOSCFG_PERF_SW_PMU
93 {
94 .name = "task-switch",
96 .type = PERF_EVENT_TYPE_SW,
97 },
98 {
99 .name = "irq-in",
101 .type = PERF_EVENT_TYPE_SW,
102 },
103 {
104 .name = "mem-alloc",
106 .type = PERF_EVENT_TYPE_SW,
107 },
108 {
109 .name = "mux-pend",
110 .event = PERF_COUNT_SW_MUX_PEND,
111 .type = PERF_EVENT_TYPE_SW,
112 },
113#endif
114 {
115 .name = "",
116 .event = -1,
117 .type = PERF_EVENT_TYPE_MAX,
118 }
119};
120
121void PerfList(void)
122{
123 const PerfEvent *evt = &g_events[0];
124 printf("\n");
125 for (; evt->event != -1; evt++) {
126 printf("\t %-25s%30s\n", evt->name, g_eventTypeStr[evt->type]);
127 }
128 printf("\n");
129}
@ PERF_COUNT_CPU_CLOCK
Definition: perf.h:85
@ PERF_EVENT_TYPE_SW
Definition: perf.h:59
@ PERF_EVENT_TYPE_HW
Definition: perf.h:57
@ PERF_EVENT_TYPE_MAX
Definition: perf.h:62
@ PERF_EVENT_TYPE_TIMED
Definition: perf.h:58
@ PERF_COUNT_SW_IRQ_RESPONSE
Definition: perf.h:93
@ PERF_COUNT_SW_MUX_PEND
Definition: perf.h:95
@ PERF_COUNT_SW_TASK_SWITCH
Definition: perf.h:92
@ PERF_COUNT_SW_MEM_ALLOC
Definition: perf.h:94
@ PERF_COUNT_HW_BRANCH_INSTRUCTIONS
Definition: perf.h:75
@ PERF_COUNT_HW_DCACHE_MISSES
Definition: perf.h:72
@ PERF_COUNT_HW_DCACHE_REFERENCES
Definition: perf.h:71
@ PERF_COUNT_HW_BRANCH_MISSES
Definition: perf.h:76
@ PERF_COUNT_HW_ICACHE_MISSES
Definition: perf.h:74
@ PERF_COUNT_HW_ICACHE_REFERENCES
Definition: perf.h:73
@ PERF_COUNT_HW_CPU_CYCLES
Definition: perf.h:69
@ PERF_COUNT_HW_INSTRUCTIONS
Definition: perf.h:70
const PerfEvent g_events[]
Definition: perf_list.c:42
void PerfList(void)
Definition: perf_list.c:121
static const char * g_eventTypeStr[]
Definition: perf_list.c:36
int event
Definition: perf_list.h:44
int type
Definition: perf_list.h:45
const char * name
Definition: perf_list.h:43