diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 470f9916..c8d7e034 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -3062,6 +3062,7 @@ PCM::PCM() : #ifdef PCM_USE_PERF canUsePerf = true; perfEventHandle.resize(num_cores, std::vector(PERF_MAX_COUNTERS, -1)); + std::fill(perfTopDownPos.begin(), perfTopDownPos.end(), 0); #endif for (int32 i = 0; i < num_cores; ++i) diff --git a/src/pcm-accel-common.cpp b/src/pcm-accel-common.cpp index c702e93c..dfd3f4ab 100644 --- a/src/pcm-accel-common.cpp +++ b/src/pcm-accel-common.cpp @@ -351,13 +351,16 @@ void readAccelCounters(SystemCounterState& sycs_) } AcceleratorCounterState* AcceleratorCounterState::instance = NULL; + +std::mutex instanceCreationMutexForAcceleratorCounterState{}; + AcceleratorCounterState * AcceleratorCounterState::getInstance() { // lock-free read // cppcheck-suppress identicalConditionAfterEarlyExit if (instance) return instance; - std::unique_lock instanceCreationMutex; + std::unique_lock _(instanceCreationMutexForAcceleratorCounterState); // cppcheck-suppress identicalConditionAfterEarlyExit if (instance) return instance;