summaryrefslogtreecommitdiff
path: root/power-libperfmgr
diff options
context:
space:
mode:
authorMisha Wagner <mishaw@google.com>2022-05-16 15:51:33 +0100
committerMisha Wagner <mishaw@google.com>2022-05-16 15:52:53 +0100
commit5faeaac9be33d81c63efd97474476c853edc14cc (patch)
tree8fd4a565ba68d5bb6d7dcfc3df3f283fd50e897a /power-libperfmgr
parent61028bdd31bf57cd288ac2827c864e650b799f4d (diff)
Fix cancelling hints when refreshing expiring hints.
When choose a new throttle option, we: 1. Send the new hints. 2. Cancel the old hints. After b/230316778, we also sometimes do this when the hint *doesn't change*, so we can "refresh" the hint if it's about to expire. This send & immediately cancels the same hints, which essentially just cancels the hint. The solution is to only do step #1 from above when refreshing the hint. Bug: 232782573 Test: manual Change-Id: I2a6d83a29b683d7e1f8d71b8fff700b51d1839cf
Diffstat (limited to 'power-libperfmgr')
-rw-r--r--power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp b/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
index 16b4028..0ad9639 100644
--- a/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
+++ b/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
@@ -177,22 +177,29 @@ void AdaptiveCpu::RunMainLoop() {
LOG(VERBOSE) << "Model decision: " << static_cast<uint32_t>(throttleDecision);
ATRACE_INT("AdaptiveCpu_throttleDecision", static_cast<uint32_t>(throttleDecision));
- const auto now = mTimeSource.GetTime();
- // Resend the throttle hints, even if they've not changed, if the previous send is close to
- // timing out. We define "close to" as half the hint timeout, as we can't guarantee we will
- // run again before the actual timeout.
- const bool throttleHintMayTimeout = now - mLastThrottleHintTime > mConfig.hintTimeout / 2;
- if (throttleDecision != previousThrottleDecision || throttleHintMayTimeout) {
- mLastThrottleHintTime = now;
+ {
ATRACE_NAME("sendHints");
- for (const auto &hintName : THROTTLE_DECISION_TO_HINT_NAMES.at(throttleDecision)) {
- HintManager::GetInstance()->DoHint(hintName, mConfig.hintTimeout);
+ const auto now = mTimeSource.GetTime();
+ // Resend the throttle hints, even if they've not changed, if the previous send is close
+ // to timing out. We define "close to" as half the hint timeout, as we can't guarantee
+ // we will run again before the actual timeout.
+ const bool throttleHintMayTimeout =
+ now - mLastThrottleHintTime > mConfig.hintTimeout / 2;
+ if (throttleDecision != previousThrottleDecision || throttleHintMayTimeout) {
+ ATRACE_NAME("sendNewHints");
+ mLastThrottleHintTime = now;
+ for (const auto &hintName : THROTTLE_DECISION_TO_HINT_NAMES.at(throttleDecision)) {
+ HintManager::GetInstance()->DoHint(hintName, mConfig.hintTimeout);
+ }
}
- for (const auto &hintName :
- THROTTLE_DECISION_TO_HINT_NAMES.at(previousThrottleDecision)) {
- HintManager::GetInstance()->EndHint(hintName);
+ if (throttleDecision != previousThrottleDecision) {
+ ATRACE_NAME("endOldHints");
+ for (const auto &hintName :
+ THROTTLE_DECISION_TO_HINT_NAMES.at(previousThrottleDecision)) {
+ HintManager::GetInstance()->EndHint(hintName);
+ }
+ previousThrottleDecision = throttleDecision;
}
- previousThrottleDecision = throttleDecision;
}
mAdaptiveCpuStats.RegisterSuccessfulRun(previousThrottleDecision, throttleDecision,