From 70f302588ea43cabc812531b8646173ebd5b100d Mon Sep 17 00:00:00 2001 From: doublefree Date: Fri, 1 Aug 2025 17:07:26 +0800 Subject: [PATCH] =?UTF-8?q?pmuv3=E5=A2=9E=E5=8A=A0=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pmu/perf_counter.cpp | 3 +++ pmu/pmu.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/pmu/perf_counter.cpp b/pmu/perf_counter.cpp index 3ad6339..9cf08f5 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 715db52..4ec1714 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; -- Gitee