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 42const PerfEvent g_events[] = { 43#ifdef LOSCFG_PERF_HW_PMU 44 { 45 .name = "cycles", 46 .event = PERF_COUNT_HW_CPU_CYCLES, 47 .type = PERF_EVENT_TYPE_HW, 48 }, 49 { 50 .name = "instruction", 51 .event = PERF_COUNT_HW_INSTRUCTIONS, 52 .type = PERF_EVENT_TYPE_HW, 53 }, 54 { 55 .name = "dcache", 56 .event = PERF_COUNT_HW_DCACHE_REFERENCES, 57 .type = PERF_EVENT_TYPE_HW, 58 }, 59 { 60 .name = "dcache-miss", 61 .event = PERF_COUNT_HW_DCACHE_MISSES, 62 .type = PERF_EVENT_TYPE_HW, 63 }, 64 { 65 .name = "icache", 66 .event = PERF_COUNT_HW_ICACHE_REFERENCES, 67 .type = PERF_EVENT_TYPE_HW, 68 }, 69 { 70 .name = "icache-miss", 71 .event = PERF_COUNT_HW_ICACHE_MISSES, 72 .type = PERF_EVENT_TYPE_HW, 73 }, 74 { 75 .name = "branch", 76 .event = PERF_COUNT_HW_BRANCH_INSTRUCTIONS, 77 .type = PERF_EVENT_TYPE_HW, 78 }, 79 { 80 .name = "branch-miss", 81 .event = PERF_COUNT_HW_BRANCH_MISSES, 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, 89 .type = PERF_EVENT_TYPE_TIMED, 90 }, 91#endif 92#ifdef LOSCFG_PERF_SW_PMU 93 { 94 .name = "task-switch", 95 .event = PERF_COUNT_SW_TASK_SWITCH, 96 .type = PERF_EVENT_TYPE_SW, 97 }, 98 { 99 .name = "irq-in", 100 .event = PERF_COUNT_SW_IRQ_RESPONSE, 101 .type = PERF_EVENT_TYPE_SW, 102 }, 103 { 104 .name = "mem-alloc", 105 .event = PERF_COUNT_SW_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} 130