power-libperfmgr: Remove mTidRefCountMap
mTidSessionListMap alone can be used to check the ref count.
Bug: b/268744922
Test: n/a
Change-Id: Ic7a3aa32560790683e402253e9e04eadb288e1f7
diff --git a/power-libperfmgr/aidl/PowerSessionManager.cpp b/power-libperfmgr/aidl/PowerSessionManager.cpp
index f4b2f91..d697c6a 100644
--- a/power-libperfmgr/aidl/PowerSessionManager.cpp
+++ b/power-libperfmgr/aidl/PowerSessionManager.cpp
@@ -122,37 +122,23 @@
void PowerSessionManager::addThreadsFromPowerSession(PowerHintSession *session) {
std::lock_guard<std::mutex> guard(mLock);
for (auto t : session->getTidList()) {
- mTidSessionListMap[t].insert(session);
- if (mTidRefCountMap.find(t) == mTidRefCountMap.end()) {
+ if (mTidSessionListMap[t].empty()) {
if (!SetTaskProfiles(t, {"ResetUclampGrp"})) {
ALOGW("Failed to set ResetUclampGrp task profile for tid:%d", t);
- } else {
- mTidRefCountMap[t] = 1;
}
- continue;
}
- if (mTidRefCountMap[t] <= 0) {
- ALOGE("Error! Unexpected zero/negative RefCount:%d for tid:%d", mTidRefCountMap[t], t);
- continue;
- }
- mTidRefCountMap[t]++;
+ mTidSessionListMap[t].insert(session);
}
}
void PowerSessionManager::removeThreadsFromPowerSession(PowerHintSession *session) {
std::lock_guard<std::mutex> guard(mLock);
for (auto t : session->getTidList()) {
- if (mTidRefCountMap.find(t) == mTidRefCountMap.end()) {
- ALOGE("Unexpected Error! Failed to look up tid:%d in TidRefCountMap", t);
- continue;
- }
mTidSessionListMap[t].erase(session);
- mTidRefCountMap[t]--;
- if (mTidRefCountMap[t] <= 0) {
+ if (mTidSessionListMap[t].empty()) {
if (!SetTaskProfiles(t, {"NoResetUclampGrp"})) {
ALOGW("Failed to set NoResetUclampGrp task profile for tid:%d", t);
}
- mTidRefCountMap.erase(t);
}
}
}
diff --git a/power-libperfmgr/aidl/PowerSessionManager.h b/power-libperfmgr/aidl/PowerSessionManager.h
index 4246053..1c2733a 100644
--- a/power-libperfmgr/aidl/PowerSessionManager.h
+++ b/power-libperfmgr/aidl/PowerSessionManager.h
@@ -70,7 +70,6 @@
const std::string kDisableBoostHintName;
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
- std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
bool mActive; // protected by mLock
/**