diff --git a/README.en.md b/README.en.md index 6644bc3b0cfd8e8e87060622cb691dd4a4f870a0..ffc0d1350f1700a063556f80cb2a057f2478e86c 100644 --- a/README.en.md +++ b/README.en.md @@ -84,12 +84,25 @@ To build a python package: bash build.sh install_path=/path/to/install python=true ``` +If the environment contains multiple Python versions, you need to specify the Python interpreter to be installed +```shell +bash build.sh python=true python_exe=$(which python3) +``` + To uninstall python package: ```shell python3 -m pip uninstall -y libkperf ``` +If a Python module runtime error similar to the following is reported: +OSERROR: /usr/lib/python3.9/site-packages/_libkperf/libsym.so: cannot open shared object file: No such file or directory +The Python installation fails due to an incompatible setuptool version. This can be resolved by downgrading. +```shell +python3 -m pip uninstall setuptools +python3 -m pip install setuptools=58 +``` + TO build a Go package: ```shell diff --git a/README.md b/README.md index a0e33c62e152c8d02b0de33e8e43c8f9256c2b40..c441df5939842e08be436c77b21e039204ea3310 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,12 @@ bash build.sh install_path=/path/to/install build_type=debug 如果想要编译python包: ```shell -bash build.sh install_path=/path/to/install python=true +bash build.sh install_path=/path/to/install python=true +``` + +假如环境中包含多个python版本,需要指定要安装的python解释器 +```shell +bash build.sh python=true python_exe=$(which python3) ``` 安装后若需要卸载python库, 可以执行下述命令 @@ -73,6 +78,14 @@ bash build.sh install_path=/path/to/install python=true python3 -m pip uninstall -y libkperf ``` +python模块运行时报错若类似如下 +OSERROR: /usr/lib/python3.9/site-packages/_libkperf/libsym.so: cannot open shared object file: No such file or directory +python安装setuptool版本不适配问题导致安装失败,目前可采用降级的方式解决 +```shell +python3 -m pip uninstall setuptools +python3 -m pip install setuptools=58 +``` + 想要编译go的包 ```shell bash build.sh go=true diff --git a/pmu/evt.cpp b/pmu/evt.cpp index c9a27ae6e741d56c95b2fe35a9e9aa1eab04c55f..992258289b6528cd2d80e3010e8f5ba32865efbe 100644 --- a/pmu/evt.cpp +++ b/pmu/evt.cpp @@ -22,14 +22,7 @@ #include "pcerrc.h" #include "evt.h" -enum class HEAD_SIZE { - HEAD_SIZE_ONE = 1, - HEAD_SIZE_TWO = 2, - HEAD_SIZE_FOUR = 4, - HEAD_SIZE_EIGHT = 8, -}; - -static constexpr double CUT_OFF_PERCENT = 0.05; + int KUNPENG_PMU::PerfEventOpen(struct perf_event_attr *attr, pid_t pid, int cpu, int groupFd, unsigned long flags) { return syscall(__NR_perf_event_open, attr, pid, cpu, groupFd, flags); diff --git a/pmu/evt_list_default.cpp b/pmu/evt_list_default.cpp index 6f96e88c2965ae7669537835a3c3a14cb05b8f83..5b050a4f6f2ba135ff5bfb4b5b8061414481a211 100644 --- a/pmu/evt_list_default.cpp +++ b/pmu/evt_list_default.cpp @@ -71,6 +71,9 @@ void KUNPENG_PMU::EvtListDefault::AdaptErrInfo(int err, PerfEvtPtr perfEvt) case LIBPERF_ERR_COUNTER_INDEX_IS_ZERO: pcerr::SetCustomErr(err, "There are too many open events. No registers are available."); break; + case LIBPERF_ERR_OPEN_INVALID_FILE: + pcerr::SetCustomErr(err, "The kernel cannot find the corresponding file or directory when loading the event: " +perfEvt->GetEvtName()); + break; case UNKNOWN_ERROR: pcerr::SetCustomErr(err, std::string{strerror(errno)}); break; diff --git a/pmu/perf_counter_default.cpp b/pmu/perf_counter_default.cpp index 0dd1ec599e5cf037633f0920a44417e84e1d0f33..f34f23c9ccae7075dc9fd275b589a5da29299ddd 100644 --- a/pmu/perf_counter_default.cpp +++ b/pmu/perf_counter_default.cpp @@ -36,7 +36,6 @@ using namespace std; using namespace pcerr; -static constexpr int MAX_ATTR_SIZE = 120; struct GroupReadFormat { __u64 nr; diff --git a/pmu/pmu.cpp b/pmu/pmu.cpp index b83c4afa4c0704d1ef6134ab6f84ff86106eeea7..7d234f236238ada3dd8dd5bfe643f97cf769730e 100644 --- a/pmu/pmu.cpp +++ b/pmu/pmu.cpp @@ -38,7 +38,6 @@ using namespace std; static unordered_map runningStatus; static SafeHandler pdMutex; static pair uncoreEventPair; -static std::set onLineCpuIds; #define REQUEST_USER_ACCESS 0x2 @@ -1194,4 +1193,3 @@ struct SampleRawField *PmuGetFieldExp(struct SampleRawData *rawData, const char return rt; #endif } - diff --git a/pmu/pmu_event.cpp b/pmu/pmu_event.cpp index 21324a681645573117f386a0e1c6a28348ac8f50..046e4c5ad406ec7795a24a3909379c745a1c7a6c 100644 --- a/pmu/pmu_event.cpp +++ b/pmu/pmu_event.cpp @@ -20,6 +20,8 @@ namespace KUNPENG_PMU { { switch (sysErr) { case EPERM: + case ENOENT: + return LIBPERF_ERR_OPEN_INVALID_FILE; case EACCES: return LIBPERF_ERR_NO_PERMISSION; case EBUSY: diff --git a/pmu/pmu_metric.cpp b/pmu/pmu_metric.cpp index 7a99acdb40aa978164052bb98be6c6e0a078c9be..22d4ae2903a0406bbb04a352dd0bab922703d6d8 100644 --- a/pmu/pmu_metric.cpp +++ b/pmu/pmu_metric.cpp @@ -39,9 +39,6 @@ using namespace std; using namespace pcerr; using IdxMap = unordered_map>; -static unsigned maxCpuNum = 0; -static vector coreArray; - static std::mutex pmuBdfListMtx; static std::mutex pmuDeviceDataMtx; diff --git a/pmu/sample_process.cpp b/pmu/sample_process.cpp index 3eef6c6a7d6ed49a2daef81cec060d9a387e4d70..57989e7089f315b1b6a28adefa370b5604261135 100644 --- a/pmu/sample_process.cpp +++ b/pmu/sample_process.cpp @@ -21,8 +21,6 @@ #include "sample_process.h" #define PAGE_SIZE (sysconf(_SC_PAGESIZE)) -#define MB() asm volatile("dmb ish" ::: "memory") -static constexpr int MAX_DATA_SIZE = 8192; using namespace pcerr; diff --git a/pmu/sampler.h b/pmu/sampler.h index ba0711a95aa73d3c1fff0e1daa75a6013de4cecc..af4d19847b9fcff4e68b2eec2ea8fd442f01dd50 100644 --- a/pmu/sampler.h +++ b/pmu/sampler.h @@ -28,10 +28,6 @@ #include "symbol.h" namespace KUNPENG_PMU { - struct MmapParam { - int prot; - __u64 mask; - }; static constexpr int SAMPLE_PAGE_SIZE = 4096; static constexpr int DEFAULT_SAMPLE_PAGES = 128; diff --git a/pmu/spe_sampler.cpp b/pmu/spe_sampler.cpp index b316baf96f24531bb462a658d6e58688146c8f1e..253839e1bafb24622fcb6a0be5414fa8f8bffab9 100644 --- a/pmu/spe_sampler.cpp +++ b/pmu/spe_sampler.cpp @@ -24,13 +24,6 @@ #include "spe_sampler.h" #include "pcerr.h" -#define MB() asm volatile("dsb sy"); -#define rmb() asm volatile("dsb ld"); -#define wmb() asm volatile("dsb st"); - -static constexpr int CYCLES_FREQ = 100; -static constexpr int SPE_PERIOD = 100; - using namespace std; namespace KUNPENG_PMU {