diff --git a/pmu/perf_counter.cpp b/pmu/perf_counter.cpp index 3ad6339caa1932d5b7c7c48a594b236859b4268e..9cf08f5470b5eeedcbf88da7d2afe92b89d533c1 100644 --- a/pmu/perf_counter.cpp +++ b/pmu/perf_counter.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "pmu.h" #include "linked_list.h" #include "pfm_event.h" @@ -73,6 +74,7 @@ int KUNPENG_PMU::PerfCounter::Read(EventData &eventData) namespace KUNPENG_PMU { static int PerfMmapReadSelf(const std::shared_ptr &countMmap, struct ReadFormat &perfCountValue) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) uint32_t seq; uint32_t idx; uint32_t timeMult = 0; @@ -134,6 +136,7 @@ static int PerfMmapReadSelf(const std::shared_ptr &countMmap, struct R } } perfCountValue.value = cnt; +#endif return SUCCESS; } } // namespace KUNPENG_PMU diff --git a/pmu/pmu.cpp b/pmu/pmu.cpp index 715db5227c365ac128d61a2d92f64b351829fdc1..4ec171483e6ad2f45696968b5700c0328f319773 100644 --- a/pmu/pmu.cpp +++ b/pmu/pmu.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "common.h" #include "pfm.h" @@ -269,6 +270,10 @@ static int CheckUserAccess(enum PmuTaskType collectType, struct PmuAttr *attr) if (!attr->enableUserAccess) { return SUCCESS; } + if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) { + New(LIBPERF_ERR_CHECK_USER_ACCESS, "Pmuv3 is supported after linux-kernel-v6.6"); + return LIBPERF_ERR_CHECK_USER_ACCESS; + } if (attr->numPid != 1 || attr->pidList[0] != 0) { New(LIBPERF_ERR_CHECK_USER_ACCESS, "The pidList is incorrectly set!"); return LIBPERF_ERR_CHECK_USER_ACCESS;