diff --git a/pmu/perf_counter.cpp b/pmu/perf_counter.cpp index 9cf08f5470b5eeedcbf88da7d2afe92b89d533c1..fda8d082039ab74842d6ab679f5fc8cac15ee4ba 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 4ec171483e6ad2f45696968b5700c0328f319773..9798ca5171861459633892f79cd3a474c5249412 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 981d13626feca95b6389539a34bf0a2761c255ed..6a7f8cb5a28cb8244292986b9fba1d792162179f 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 {