From 7d951169995a182610b00cb2a3ef2318605e097b Mon Sep 17 00:00:00 2001 From: zhoukaiqi Date: Tue, 30 Apr 2024 15:53:59 +0800 Subject: [PATCH] remove pmu.h and pcerrc.h --- pmu/CMakeLists.txt | 1 - pmu/include/pcerrc.h | 88 -------------------- pmu/include/pmu.h | 189 ------------------------------------------- 3 files changed, 278 deletions(-) delete mode 100644 pmu/include/pcerrc.h delete mode 100644 pmu/include/pmu.h diff --git a/pmu/CMakeLists.txt b/pmu/CMakeLists.txt index c16bb51..b84a77e 100644 --- a/pmu/CMakeLists.txt +++ b/pmu/CMakeLists.txt @@ -30,7 +30,6 @@ add_library(pmu SHARED ${pmu_src}) include_directories(pmu PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/plugin ${LIB_KPERF_INCPATH} ) diff --git a/pmu/include/pcerrc.h b/pmu/include/pcerrc.h deleted file mode 100644 index bcdf187..0000000 --- a/pmu/include/pcerrc.h +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. - * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: Mr.Gan - * Create: 2024-04-03 - * Description: global error codes of perf.so - ******************************************************************************/ -#ifndef PCERRC_H -#define PCERRC_H -#ifdef __cplusplus -extern "C" { -#endif -// default code -#define SUCCESS 0 -#define COMMON_ERR_NOMEM 1 // not enough memory - -// libsym 100-1000 -#define LIBSYM_ERR_BASE 100 -#define LIBSYM_ERR_KALLSYMS_INVALID LIBSYM_ERR_BASE -#define LIBSYM_ERR_DWARF_FORMAT_FAILED 101 -#define LIBSYM_ERR_ELFIN_FOMAT_FAILED 102 -#define LIBSYM_ERR_OPEN_FILE_FAILED 103 -#define LIBSYM_ERR_NOT_FIND_PID 104 -#define LIBSYM_ERR_MAP_ADDR_MODULE_FAILED 105 -#define LIBSYM_ERR_MAP_KERNAL_ADDR_FAILED 106 -#define LIBSYM_ERR_PARAM_PID_INVALID 107 -#define LIBSYM_ERR_STRCPY_OPERATE_FAILED 108 -#define LIBSYM_ERR_SNPRINF_OPERATE_FAILED 109 -#define LIBSYM_ERR_MAP_CODE_KERNEL_NOT_SUPPORT 110 -#define LIBSYM_ERR_MAP_CODE_FIND_ELF_FAILED 111 -#define LIBSYM_ERR_CMD_OPERATE_FAILED 112 -#define LIBSYM_ERR_FILE_NOT_RGE 113 -#define LIBSYM_ERR_START_SMALLER_END 114 -#define LIBSYM_ERR_STOUL_OPERATE_FAILED 115 -#define LIBSYM_ERR_FILE_INVALID 116 -// libperf 1000-3000 -#define LIBPERF_ERR_NO_AVAIL_PD 1000 -#define LIBPERF_ERR_CHIP_TYPE_INVALID 1001 -#define LIBPERF_ERR_FAIL_LISTEN_PROC 1002 -#define LIBPERF_ERR_INVALID_CPULIST 1003 -#define LIBPERF_ERR_INVALID_PIDLIST 1004 -#define LIBPERF_ERR_INVALID_EVTLIST 1005 -#define LIBPERF_ERR_INVALID_PD 1006 -#define LIBPERF_ERR_INVALID_EVENT 1007 -#define LIBPERF_ERR_SPE_UNAVAIL 1008 -#define LIBPERF_ERR_FAIL_GET_CPU 1009 -#define LIBPERF_ERR_FAIL_GET_PROC 1010 -#define LIBPERF_ERR_NO_PERMISSION 1011 -#define LIBPERF_ERR_DEVICE_BUSY 1012 -#define LIBPERF_ERR_DEVICE_INVAL 1013 -#define LIBPERF_ERR_FAIL_MMAP 1014 -#define LIBPERF_ERR_FAIL_RESOLVE_MODULE 1015 -#define LIBPERF_ERR_KERNEL_NOT_SUPPORT 1016 -#define LIBPERF_ERR_INVALID_METRIC_TYPE 1017 -#define LIBPERF_ERR_INVALID_PID 1018 -#define LIBPERF_ERR_INVALID_TASK_TYPE 1019 -#define LIBPERF_ERR_INVALID_TIME 1020 -#define LIBPERF_ERR_NO_PROC 1021 -#define LIBPERF_ERR_TOO_MANY_FD 1022 -#define LIBPERF_ERR_RAISE_FD 1023 -#define LIBPERF_ERR_INVALID_PMU_DATA 1024 -#define LIBPERF_ERR_FAILED_PMU_ENABLE 1025 -#define LIBPERF_ERR_FAILED_PMU_DISABLE 1026 -#define LIBPERF_ERR_FAILED_PMU_RESET 1027 -#define LIBPERF_ERR_NOT_OPENED 1028 - -#define UNKNOWN_ERROR 9999 - -/** -* @brief Obtaining error codes -*/ -int Perrorno(); - -/** -* @brief Obtaining Error Information -*/ -const char* Perror(); -#ifdef __cplusplus -} -#endif -#endif diff --git a/pmu/include/pmu.h b/pmu/include/pmu.h deleted file mode 100644 index f8a79ba..0000000 --- a/pmu/include/pmu.h +++ /dev/null @@ -1,189 +0,0 @@ -/****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. - * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: Mr.Gan - * Create: 2024-04-03 - * Description: declarations and definitions of interfaces and data structures exposed by perf.so - ******************************************************************************/ -#ifndef PMU_DATA_STRUCT_H -#define PMU_DATA_STRUCT_H -#include -#include -#ifdef __cplusplus -extern "C" { -#endif -#pragma GCC visibility push(default) - -enum PmuTaskType { - COUNTING = 0, // pmu counting task - SAMPLING = 1, // pmu sampling task - SPE_SAMPLING = 2, // spe sampling task - MAX_TASK_TYPE -}; - -enum AggregateType { - PER_SYSTEM, - PER_CORE, - PER_NUMA, - PER_SOCKET, - PER_THREAD, -}; - -enum SpeFilter { - SPE_FILTER_NONE = 0, - TS_ENABLE = 1UL << 0, // enable timestamping with value of generic timer - PA_ENABLE = 1UL << 1, // collect physical address (as well as VA) of loads/stores - PCT_ENABLE = 1UL << 2, // collect physical timestamp instead of virtual timestamp - JITTER = 1UL << 16, // use jitter to avoid resonance when sampling - BRANCH_FILTER = 1UL << 32, // collect branches only - LOAD_FILTER = 1UL << 33, // collect loads only - STORE_FILTER = 1UL << 34, // collect stores only - SPE_DATA_ALL = TS_ENABLE | PA_ENABLE | PCT_ENABLE | JITTER | BRANCH_FILTER | LOAD_FILTER | STORE_FILTER -}; - -enum SpeEventFilter { - SPE_EVENT_NONE = 0, - SPE_EVENT_RETIRED = 0x2, // instruction retired - SPE_EVENT_L1DMISS = 0x8, // L1D refill - SPE_EVENT_TLB_WALK = 0x20, // TLB refill - SPE_EVENT_MISPREDICTED = 0x80, // mispredict -}; - -struct PmuAttr { - char** evtList; // event list - unsigned numEvt; // length of event list - int* pidList; // pid list - unsigned numPid; // length of pid list - int* cpuList; // cpu id list - unsigned numCpu; // length of cpu id list - - union { - unsigned period; // sample period - unsigned freq; // sample frequency - }; - unsigned useFreq : 1; - unsigned excludeUser : 1; // don't count user - unsigned excludeKernel : 1; // don't count kernel - - // SPE related fields. - enum SpeFilter dataFilter; // spe data filter - enum SpeEventFilter evFilter; // spe event filter - unsigned long minLatency; // collect only samples with latency or higher -}; - -struct PmuDataExt { - unsigned long pa; // physical address - unsigned long va; // virtual address - unsigned long event; // event id -}; - -struct PmuData { - struct Stack* stack; // call stack - const char *evt; // event name - int64_t ts; // time stamp - pid_t pid; // process id - int tid; // thread id - unsigned cpu; // cpu id - struct CpuTopology *cpuTopo; // cpu topology - const char *comm; // process command - int period; // number of Samples - union { - uint64_t count; // event count. Only available for Counting. - struct PmuDataExt *ext; // extension. Only available for Spe. - }; -}; - -/** - * @brief - * Initialize the collection target. - * @param collectType collection typr. - * @param evtList array of event IDs - * @param numEvt length of evtList. - * @param pidList list of PIDs to be collected. Information about subprocess and subthreads of PIDs is collected. If - * the value is NULL, all process/threads are collected - * @param numPid length of pidList. - * @param cpuList CPU ID list. If the value is NULL, all CPUs are collected. - * @param numCpu cpuList length. - * @return int - */ -int PmuOpen(enum PmuTaskType collectType, struct PmuAttr *attr); - -/** - * @brief - * Enable counting or sampling of task . - * On error, -1 is returned. - */ -int PmuEnable(int pd); - -/** - * @brief - * Disable counting or sampling of task . - * On error, -1 is returned. - */ -int PmuDisable(int pd); - -/** - * @brief - * Collect milliseconds. If is equal to - 1 and the PID list is not empty, the collection - * is performed until all processes are complete. - * @param milliseconds - * @return int - */ -int PmuCollect(int pd, int milliseconds); - -/** - * @brief - * Similar to , and accepts multiple pds. - * @param milliseconds - * @return int - */ -int PmuCollectV(int *pd, unsigned len, int milliseconds); - -/** - * @brief stop a sampling task in asynchronous mode - * @param pd pmu descriptor. - */ -void PmuStop(int pd); - -/** - * @brief - * Collect data. If the value is NULL and the error code is 0, no data is available in the current collection time. If - * the value is NULL and the error code is not 0, an error occurs in the collection process and data cannot be read. - * @param struct PmuData* - */ -int PmuRead(int pd, struct PmuData** pmuData); - -/** - * @brief - * Append data list to another data list <*toData>. - * The pointer of data list <*toData> will be refreshed after this function is called. - * On success, length of <*toData> is returned. - * On error, -1 is returned. - * @param fromData data list which will be copied to <*toData> - * @param toData pointer to target data list. If data list <*toData> is NULL, a new list will be created. - */ -int PmuAppendData(struct PmuData *fromData, struct PmuData **toData); - -/** - * @brief Close all the file descriptor opened during collecting process - */ -void PmuClose(int pd); - -/** - * @brief Free PmuData pointer. - * @param pmuData - */ -void PmuDataFree(struct PmuData* pmuData); - -#pragma GCC visibility pop -#ifdef __cplusplus -} -#endif -#endif -- 2.27.0