From c0f264b813529f9440c1cd3db1672e7199509027 Mon Sep 17 00:00:00 2001 From: Matt Buckley Date: Thu, 18 Jul 2024 20:16:00 +0530 Subject: [PATCH] sm6375-common: power-libperfmgr: Remove wakeup behavior from PowerHintSession and PowerSessionManager Currently, all sessions get boosted any time DISPLAY_UPDATE_IMMINENT is sent from SurfaceFlinger which can lead to large, unnecessary boosts. This patch aims to change that by removing the wakeup behavior, relying instead on sessions to boost themselves with new load change hints. * Remove wakeup() from PowerHintSession * Remove wakeSessions from PowerSessionManager * Remove related timers and message handlers * Remove DISPLAY_UPDATE_IMMINENT behavior entirely Test: manual Bug: b/260136431 Change-Id: I4610edfefe8fcbef7d4cdbf5768830a9392a54f7 --- power-libperfmgr/PowerHintSession.cpp | 27 ------------------ power-libperfmgr/PowerHintSession.h | 1 - power-libperfmgr/PowerSessionManager.cpp | 35 ------------------------ power-libperfmgr/PowerSessionManager.h | 13 +-------- 4 files changed, 1 insertion(+), 75 deletions(-) diff --git a/power-libperfmgr/PowerHintSession.cpp b/power-libperfmgr/PowerHintSession.cpp index 15ebe37..c481977 100644 --- a/power-libperfmgr/PowerHintSession.cpp +++ b/power-libperfmgr/PowerHintSession.cpp @@ -376,33 +376,6 @@ void PowerHintSession::setStale() { } } -void PowerHintSession::wakeup() { - std::lock_guard guard(mSessionLock); - - // We only wake up non-paused session - if (mSessionClosed || !isActive()) { - return; - } - // Update session's timer - mStaleTimerHandler->updateTimer(); - // Skip uclamp update for stale session - if (!isTimeout()) { - return; - } - if (ATRACE_ENABLED()) { - std::string tag = - StringPrintf("wakeup.%s(a:%d,s:%d)", mIdString.c_str(), isActive(), isTimeout()); - ATRACE_NAME(tag.c_str()); - } - std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); - mDescriptor->current_min = - std::max(mDescriptor->current_min, static_cast(adpfConfig->mUclampMinInit)); - - if (ATRACE_ENABLED()) { - traceSessionVal("min", mDescriptor->current_min); - } -} - void PowerHintSession::StaleTimerHandler::updateTimer() { auto now = std::chrono::steady_clock::now(); nanoseconds staleDuration = std::chrono::nanoseconds( diff --git a/power-libperfmgr/PowerHintSession.h b/power-libperfmgr/PowerHintSession.h index f1c16f4..2a187ef 100644 --- a/power-libperfmgr/PowerHintSession.h +++ b/power-libperfmgr/PowerHintSession.h @@ -79,7 +79,6 @@ class PowerHintSession : public BnPowerHintSession { const std::vector &actualDurations) override; bool isActive(); bool isTimeout(); - void wakeup(); void setStale(); // Is this hint session for a user application bool isAppSession(); diff --git a/power-libperfmgr/PowerSessionManager.cpp b/power-libperfmgr/PowerSessionManager.cpp index 947208b..35bf300 100644 --- a/power-libperfmgr/PowerSessionManager.cpp +++ b/power-libperfmgr/PowerSessionManager.cpp @@ -97,37 +97,6 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura ATRACE_CALL(); ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(), durationMs); - if (boost.compare("DISPLAY_UPDATE_IMMINENT") == 0) { - PowerHintMonitor::getInstance()->getLooper()->sendMessage(mWakeupHandler, NULL); - } -} - -void PowerSessionManager::wakeSessions() { - std::lock_guard guard(mLock); - std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); - std::unordered_set wakeupList; - const int wakeupBoostValue = static_cast(adpfConfig->mUclampMinInit); - for (auto &it : mTidSessionListMap) { - int tid = it.first; - int maxboost = -1; - // Find the max boost value among all the sessions that include the same TID. - for (PowerHintSession *s : it.second) { - if (!s->isActive()) - continue; - // all active sessions need to be awakened. - wakeupList.insert(s); - if (s->isTimeout()) { - maxboost = std::max(maxboost, s->getUclampMin()); - } - } - // Found the max boost and actally set to the task. - if (maxboost != -1) { - set_uclamp_min(tid, std::max(maxboost, wakeupBoostValue)); - } - } - for (PowerHintSession *s : wakeupList) { - s->wakeup(); - } } int PowerSessionManager::getDisplayRefreshRate() { @@ -223,10 +192,6 @@ void PowerSessionManager::handleMessage(const Message &) { } } -void PowerSessionManager::WakeupHandler::handleMessage(const Message &) { - PowerSessionManager::getInstance()->wakeSessions(); -} - void PowerSessionManager::dumpToFd(int fd) { std::ostringstream dump_buf; std::lock_guard guard(mLock); diff --git a/power-libperfmgr/PowerSessionManager.h b/power-libperfmgr/PowerSessionManager.h index 6cd0886..e65e58e 100644 --- a/power-libperfmgr/PowerSessionManager.h +++ b/power-libperfmgr/PowerSessionManager.h @@ -62,14 +62,6 @@ class PowerSessionManager : public MessageHandler { } private: - class WakeupHandler : public MessageHandler { - public: - WakeupHandler() {} - void handleMessage(const Message &message) override; - }; - - private: - void wakeSessions(); std::optional isAnyAppSessionActive(); void disableSystemTopAppBoost(); void enableSystemTopAppBoost(); @@ -78,7 +70,6 @@ class PowerSessionManager : public MessageHandler { std::unordered_set mSessions; // protected by mLock std::unordered_map mTidRefCountMap; // protected by mLock std::unordered_map> mTidSessionListMap; - sp mWakeupHandler; bool mActive; // protected by mLock /** * mLock to pretect the above data objects opertions. @@ -90,9 +81,7 @@ class PowerSessionManager : public MessageHandler { : kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost, "ADPF_DISABLE_TA_BOOST")), mActive(false), - mDisplayRefreshRate(60) { - mWakeupHandler = sp(new WakeupHandler()); - } + mDisplayRefreshRate(60) {} PowerSessionManager(PowerSessionManager const &) = delete; void operator=(PowerSessionManager const &) = delete; };