Skip to content

Commit

Permalink
power-libperfmgr: Fix boost timer resetting stale timer
Browse files Browse the repository at this point in the history
Currently the boost timer resets the stale timer when it turns off.
That's less than ideal, but this should fix it.

This also adds code to prevent multiple sequential boosts from re-using
uclamp.min values when calculating what to return to once the boost ends

Bug: 267385642
Bug: 267391322
Test: manual
Change-Id: I70d835f4add242c10788aa893fb2f49774e1a538
  • Loading branch information
AndroidMatt1 authored and rayavanindra committed Jul 20, 2024
1 parent 7b8c5fc commit d6de212
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions power-libperfmgr/aidl/PowerHintSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ void PowerHintSession::tryToSendPowerHint(std::string hint) {
}
}

int PowerHintSession::setSessionUclampMin(int32_t min) {
int PowerHintSession::setSessionUclampMin(int32_t min, bool resetStale) {
{
std::lock_guard<std::mutex> guard(mSessionLock);
mDescriptor->current_min = min;
}
if (min) {
if (min != 0 && resetStale) {
mStaleTimerHandler->updateTimer();
}
PowerSessionManager::getInstance()->setUclampMin(this, min);
Expand Down Expand Up @@ -337,6 +337,7 @@ ndk::ScopedAStatus PowerHintSession::sendHint(SessionHint hint) {
ALOGE("Error: session is dead");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
disableTemporaryBoost();
// The amount we boost threads that have unexpected workloads
// Consider adding this value to the powerhint.json and using that value directly
constexpr int kRelativeBoost = 150;
Expand Down Expand Up @@ -518,7 +519,7 @@ void PowerHintSession::StaleTimerHandler::onTimeout() {

void PowerHintSession::BoostTimerHandler::onTimeout() {
if (mSession->disableTemporaryBoost()) {
mSession->setSessionUclampMin(mSession->getUclampMin());
mSession->setSessionUclampMin(mSession->getUclampMin(), false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion power-libperfmgr/aidl/PowerHintSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PowerHintSession : public BnPowerHintSession {

private:
void updateUniveralBoostMode();
int setSessionUclampMin(int32_t min);
int setSessionUclampMin(int32_t min, bool resetStale = true);
void tryToSendPowerHint(std::string hint);
int64_t convertWorkDurationToBoostByPid(const std::vector<WorkDuration> &actualDurations);
void traceSessionVal(char const *identifier, int64_t val) const;
Expand Down

0 comments on commit d6de212

Please sign in to comment.