power: 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
This commit is contained in:
parent
035ad6c78d
commit
4453055456
@ -376,33 +376,6 @@ void PowerHintSession::setStale() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerHintSession::wakeup() {
|
|
||||||
std::lock_guard<std::mutex> 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> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
|
|
||||||
mDescriptor->current_min =
|
|
||||||
std::max(mDescriptor->current_min, static_cast<int>(adpfConfig->mUclampMinInit));
|
|
||||||
|
|
||||||
if (ATRACE_ENABLED()) {
|
|
||||||
traceSessionVal("min", mDescriptor->current_min);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PowerHintSession::StaleTimerHandler::updateTimer() {
|
void PowerHintSession::StaleTimerHandler::updateTimer() {
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
nanoseconds staleDuration = std::chrono::nanoseconds(
|
nanoseconds staleDuration = std::chrono::nanoseconds(
|
||||||
|
@ -79,7 +79,6 @@ class PowerHintSession : public BnPowerHintSession {
|
|||||||
const std::vector<WorkDuration> &actualDurations) override;
|
const std::vector<WorkDuration> &actualDurations) override;
|
||||||
bool isActive();
|
bool isActive();
|
||||||
bool isTimeout();
|
bool isTimeout();
|
||||||
void wakeup();
|
|
||||||
void setStale();
|
void setStale();
|
||||||
// Is this hint session for a user application
|
// Is this hint session for a user application
|
||||||
bool isAppSession();
|
bool isAppSession();
|
||||||
|
@ -97,37 +97,6 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura
|
|||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(),
|
ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(),
|
||||||
durationMs);
|
durationMs);
|
||||||
if (boost.compare("DISPLAY_UPDATE_IMMINENT") == 0) {
|
|
||||||
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mWakeupHandler, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PowerSessionManager::wakeSessions() {
|
|
||||||
std::lock_guard<std::mutex> guard(mLock);
|
|
||||||
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
|
|
||||||
std::unordered_set<PowerHintSession *> wakeupList;
|
|
||||||
const int wakeupBoostValue = static_cast<int>(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() {
|
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) {
|
void PowerSessionManager::dumpToFd(int fd) {
|
||||||
std::ostringstream dump_buf;
|
std::ostringstream dump_buf;
|
||||||
std::lock_guard<std::mutex> guard(mLock);
|
std::lock_guard<std::mutex> guard(mLock);
|
||||||
|
@ -62,14 +62,6 @@ class PowerSessionManager : public MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class WakeupHandler : public MessageHandler {
|
|
||||||
public:
|
|
||||||
WakeupHandler() {}
|
|
||||||
void handleMessage(const Message &message) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
void wakeSessions();
|
|
||||||
std::optional<bool> isAnyAppSessionActive();
|
std::optional<bool> isAnyAppSessionActive();
|
||||||
void disableSystemTopAppBoost();
|
void disableSystemTopAppBoost();
|
||||||
void enableSystemTopAppBoost();
|
void enableSystemTopAppBoost();
|
||||||
@ -78,7 +70,6 @@ class PowerSessionManager : public MessageHandler {
|
|||||||
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
|
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
|
||||||
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
|
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
|
||||||
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
|
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
|
||||||
sp<WakeupHandler> mWakeupHandler;
|
|
||||||
bool mActive; // protected by mLock
|
bool mActive; // protected by mLock
|
||||||
/**
|
/**
|
||||||
* mLock to pretect the above data objects opertions.
|
* mLock to pretect the above data objects opertions.
|
||||||
@ -90,9 +81,7 @@ class PowerSessionManager : public MessageHandler {
|
|||||||
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
|
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
|
||||||
"ADPF_DISABLE_TA_BOOST")),
|
"ADPF_DISABLE_TA_BOOST")),
|
||||||
mActive(false),
|
mActive(false),
|
||||||
mDisplayRefreshRate(60) {
|
mDisplayRefreshRate(60) {}
|
||||||
mWakeupHandler = sp<WakeupHandler>(new WakeupHandler());
|
|
||||||
}
|
|
||||||
PowerSessionManager(PowerSessionManager const &) = delete;
|
PowerSessionManager(PowerSessionManager const &) = delete;
|
||||||
void operator=(PowerSessionManager const &) = delete;
|
void operator=(PowerSessionManager const &) = delete;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user