power-libperfmgr: Fix boost timer resetting stale timer
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
diff --git a/power-libperfmgr/aidl/PowerHintSession.cpp b/power-libperfmgr/aidl/PowerHintSession.cpp
index 8ecb10d..4debfce 100644
--- a/power-libperfmgr/aidl/PowerHintSession.cpp
+++ b/power-libperfmgr/aidl/PowerHintSession.cpp
@@ -179,12 +179,12 @@
}
}
-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);
@@ -337,6 +337,7 @@
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;
@@ -518,7 +519,7 @@
void PowerHintSession::BoostTimerHandler::onTimeout() {
if (mSession->disableTemporaryBoost()) {
- mSession->setSessionUclampMin(mSession->getUclampMin());
+ mSession->setSessionUclampMin(mSession->getUclampMin(), false);
}
}
diff --git a/power-libperfmgr/aidl/PowerHintSession.h b/power-libperfmgr/aidl/PowerHintSession.h
index 7ab87b1..e1c2523 100644
--- a/power-libperfmgr/aidl/PowerHintSession.h
+++ b/power-libperfmgr/aidl/PowerHintSession.h
@@ -129,7 +129,7 @@
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;