From 52688779af3adcbdea8e6b49c5ede72207a4ac09 Mon Sep 17 00:00:00 2001 From: doublefree Date: Tue, 5 Aug 2025 11:10:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5=E6=A0=87?= =?UTF-8?q?=E8=AF=86user=20access?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pmu/perf_counter.cpp | 6 +++--- pmu/pmu.cpp | 1 + pmu/pmu_event.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pmu/perf_counter.cpp b/pmu/perf_counter.cpp index 9cf08f5..fda8d08 100644 --- a/pmu/perf_counter.cpp +++ b/pmu/perf_counter.cpp @@ -144,7 +144,7 @@ static int PerfMmapReadSelf(const std::shared_ptr &countMmap, struct R int KUNPENG_PMU::PerfCounter::ReadSingleEvent(std::vector &data) { ReadFormat perfCountValue; - if (this->evt->config1 & REQUEST_USER_ACCESS) { + if (this->evt->enableUserAccess) { int err = PerfMmapReadSelf(this->countMmap, perfCountValue); if (err != SUCCESS) { return err; @@ -225,7 +225,7 @@ int KUNPENG_PMU::PerfCounter::CountValueToData(const __u64 value, const __u64 ti // counting value (https://perf.wiki.kernel.org/index.php/Tutorial) double percent = 0.0; uint64_t increCount; - if (this->evt->config1 & REQUEST_USER_ACCESS) { + if (this->evt->enableUserAccess) { percent = 1; increCount = static_cast(value - accumCount); } else if ((value == accumCount) || (timeRunning == running)) { @@ -259,7 +259,7 @@ int KUNPENG_PMU::PerfCounter::CountValueToData(const __u64 value, const __u64 ti int KUNPENG_PMU::PerfCounter::Init(const bool groupEnable, const int groupFd, const int resetOutputFd) { int err = SUCCESS; - if (this->evt->config1 & REQUEST_USER_ACCESS) { // user access + if (this->evt->enableUserAccess) { // user access err = this->MapPerfAttrUserAccess(); if (err != SUCCESS) { return err; diff --git a/pmu/pmu.cpp b/pmu/pmu.cpp index 4ec1714..9798ca5 100644 --- a/pmu/pmu.cpp +++ b/pmu/pmu.cpp @@ -987,6 +987,7 @@ static struct PmuTaskAttr* AssignTaskParam(PmuTaskType collectType, PmuAttr *att if (cgroupName != nullptr) { taskParam->pmuEvt->cgroupName = cgroupName; } + taskParam->pmuEvt->enableUserAccess = attr->enableUserAccess; if (attr->enableUserAccess) { taskParam->pmuEvt->config1 = REQUEST_USER_ACCESS; } diff --git a/pmu/pmu_event.h b/pmu/pmu_event.h index 981d136..6a7f8cb 100644 --- a/pmu/pmu_event.h +++ b/pmu/pmu_event.h @@ -51,6 +51,7 @@ struct PmuEvt { unsigned includeNewFork : 1; // count new fork tid int cgroupFd; std::string cgroupName; + unsigned enableUserAccess : 1; // avoid uncore (config1 & 0x2) == 0x2 }; namespace KUNPENG_PMU { -- Gitee